Hi all,
I’m in the process of deploying D1 Mini-based IR transceivers wherever I have TV’s or anything else controlled with IR remote controls so that I can create automations and trigger them via Hassio. The hardware part of this works great for the most part. I’m having some challenges with the configuration side though - specifically what I believe are yaml size limitations or limitations on the number of entities as well as data type…challenges.
My first stab at this was to put all of the commands for the given location into the D1’s yaml config but this caused odd wifi behavior. I’d backed out a bunch of the IR command codes thinking a typo might be the problem and things started working again. This led to me to remove/comment out a number of commands that I think won’t be used often and then the D1 started working as expected again. The issues with this route are that even by limiting the number of items in the yaml to stabilize wifi the built in web server doesn’t seem to be able to serve up a page that large. As you can see from the screen shot, a number of button/switch entities are missing even though they’re in the yaml config. I know they’re working because they ALL show in the Hassio UI. Even if the ESPHome web server issue were fixed, I still can’t define entities for all of the remote commands I want to. As soon as I uncomment out the commands that are commented out in the yaml below, the code compiles but the D1 Mini has difficulty with wifi handshakes, establishing and maintaining connections (NOT the 5 minute reboot loop issue) and it never responds when you try and bring up its internal webpage nor does it show up in HA. Screenshot of the D1’s web page and the associated yaml config are below.
esphome:
name: ir_blaster_office
platform: ESP8266
board: d1_mini
wifi:
ssid: "my_wifi"
password: "my_pass"
fast_connect: on
power_save_mode: none
# Enable logging
logger:
# Example configuration entry
remote_receiver:
pin:
number: GPIO13
inverted: yes
mode: INPUT_PULLUP
dump: all
#dump: 'lg'
#dump: 'nec'
#dump: 'panasonic'
#dump: 'jvc'
#dump: 'samsung'
#dump: 'sony'
#dump: 'rc_switch'
#dump: 'rc5'
remote_transmitter:
pin: GPIO12
carrier_duty_percent: 50%
switch:
- platform: template
name: Samsung Mute
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E0F00F
- platform: template
name: Samsung Power
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E040BF
- platform: template
name: Samsung Left Arrow
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E0A659
- platform: template
name: Samsung Right Arrow
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E046B9
- platform: template
name: Samsung Up Arrow
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E006F9
- platform: template
name: Samsung Down Arrow
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E08679
- platform: template
name: Samsung Home
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E09E61
- platform: template
name: Samsung Enter
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E016E9
- platform: template
name: Samsung Return/Back
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E01AE5
- platform: template
name: Samsung Volume Up
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E0E01F
- platform: template
name: Samsung Volume Down
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0xE0E0D02F
- platform: template
name: PIP Switcher In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FE48B7
- platform: template
name: PIP Switcher In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FE58A7
- platform: template
name: PIP Switcher In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FE7887
- platform: template
name: PIP Switcher In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FE807F
- platform: template
name: PIP Switcher In Cycle
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FEC03F
- platform: template
name: PIP Switcher PIP
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FE50AF
- platform: template
name: PIP Switcher Select
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FED827
- platform: template
name: PIP Switcher Enter
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x01FEF807
- platform: template
name: HDMI 5 Switcher In 1
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0x1010F00F
- platform: template
name: HDMI 5 Switcher In 2
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0x101048B7
- platform: template
name: HDMI 5 Switcher In 3
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0x10109867
- platform: template
name: HDMI 5 Switcher In 4
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0x1010F807
- platform: template
name: HDMI 5 Switcher In 5
turn_on_action:
- remote_transmitter.transmit_samsung:
data: 0x101038C7
# - platform: template
# name: HDMI 5 Switcher Cycle Down
# turn_on_action:
# - remote_transmitter.transmit_samsung:
# data: 0x1010B04F
# - platform: template
# name: HDMI 5 Switcher Cycle Up
# turn_on_action:
# - remote_transmitter.transmit_samsung:
# data: 0x101030CF
- platform: template
name: HDMI 4 Switcher Power
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF629D
- platform: template
name: HDMI 4 Switcher In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF02FD
- platform: template
name: HDMI 4 Switcher In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFE01F
- platform: template
name: HDMI 4 Switcher In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF906F
- platform: template
name: HDMI 4 Switcher In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF9867
- platform: template
name: HDMI 4 Switcher Sound
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF30CF
- platform: template
name: HDMI 4 Switcher 720P/1080P
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF7A85
- platform: template
name: HDMI 4 Switcher Single View
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF10EF
- platform: template
name: HDMI 4 Switcher Quad 1+3 View
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF38C7
- platform: template
name: HDMI 4 Switcher Quad Matrix View
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF5AA5
- platform: template
name: HDMI 4 Matrix Switcher Power
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF28D7
- platform: template
name: HDMI 4 Matrix Switcher Out A – In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF906F
- platform: template
name: HDMI 4 Matrix Switcher Out A – In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFB847
- platform: template
name: HDMI 4 Matrix Switcher Out A – In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFF807
- platform: template
name: HDMI 4 Matrix Switcher Out A – In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFB04F
# - platform: template
# name: HDMI 4 Matrix Switcher Out A – Cycle Down
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FFD827
# - platform: template
# name: HDMI 4 Matrix Switcher Out A – Cycle Up
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FF8877
- platform: template
name: HDMI 4 Matrix Switcher Out B – In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFE817
- platform: template
name: HDMI 4 Matrix Switcher Out B – In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF48B7
- platform: template
name: HDMI 4 Matrix Switcher Out B – In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF9A65
- platform: template
name: HDMI 4 Matrix Switcher Out B – In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF10EF
# - platform: template
# name: HDMI 4 Matrix Switcher Out B – Cycle Down
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FFAA55
# - platform: template
# name: HDMI 4 Matrix Switcher Out B – Cycle Up
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FF12ED
- platform: template
name: HDMI 4 Matrix Switcher Out C – In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF7A85
- platform: template
name: HDMI 4 Matrix Switcher Out C – In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF609F
- platform: template
name: HDMI 4 Matrix Switcher Out C – In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFA05F
- platform: template
name: HDMI 4 Matrix Switcher Out C – In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFC03F
# - platform: template
# name: HDMI 4 Matrix Switcher Out C – Cycle Down
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FFE01F
# - platform: template
# name: HDMI 4 Matrix Switcher Out C – Cycle Up
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FF02FD
- platform: template
name: HDMI 4 Matrix Switcher Out D – In 1
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF18E7
- platform: template
name: HDMI 4 Matrix Switcher Out D – In 2
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF22DD
- platform: template
name: HDMI 4 Matrix Switcher Out D – In 3
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FFF00F
- platform: template
name: HDMI 4 Matrix Switcher Out D – In 4
turn_on_action:
- remote_transmitter.transmit_lg:
data: 0x00FF8A75
# - platform: template
# name: HDMI 4 Matrix Switcher Out D – Cycle Down
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FF7887
# - platform: template
# name: HDMI 4 Matrix Switcher Out D – Cycle Up
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x00FF708F
# - platform: template
# name: Apple TV Up Arrow
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E1D027
# - platform: template
# name: Apple TV Down Arrow
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E1B027
# - platform: template
# name: Apple TV Left Arrow
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E11027
# - platform: template
# name: Apple TV Right Arrow
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E1E027
# - platform: template
# name: Apple TV Enter
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E1BA27
# turn_off_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E12027
# - platform: template
# name: Apple TV Menu
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E14027
# - platform: template
# name: Apple TV Play/Pause
# turn_on_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E17A27
# turn_off_action:
# - remote_transmitter.transmit_lg:
# data: 0x77E12027
# Enable Home Assistant API
api:
ota:
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
…which gives this web page, with a number of switches/entities missing as well as the debug console, etc.
Thinking that I could shift the command codes to Hassio automations instead of keeping them all in the D1’s ESPHome yaml config, I think came up with this config yaml:
esphome:
name: ir_blaster_generic_1
platform: ESP8266
board: d1_mini
wifi:
ssid: "my_wifi"
password: "my_pass"
# Enable logging
logger:
remote_receiver:
pin:
number: GPIO13
inverted: yes
mode: INPUT_PULLUP
dump: all
remote_transmitter:
pin: GPIO12
carrier_duty_percent: 50%
# Enable Home Assistant API
api:
services:
- service: send_samsung_command
variables:
my_command: int
then:
- remote_transmitter.transmit_samsung:
data: !lambda 'return my_command;'
- service: send_lg_command
variables:
my_command: int
then:
- remote_transmitter.transmit_lg:
data: !lambda 'return my_command;'
ota:
I’d originally tried defining my_command as a string but got the error below on compile:
Compiling /data/ir_blaster_generic_1/.pioenvs/ir_blaster_generic_1/src/main.cpp.o
src/main.cpp: In lambda function:
src/main.cpp:179:14: error: cannot convert 'std::string {aka std::basic_string<char>}' to 'uint16_t {aka short unsigned int}' in return
return my_command;
^
…since there is no unsigned int data type for ESPHome according to its API documentation I changed them to int as you see in the yaml above. My challenge now is that I cannot call the service because when I try and pass in command codes such as 0xE0E0F00F HA tells me it’s not valid JSON so I quote it but then it errors out because it’s not an int (since the quotes make it a string).
I thought about logging a bug for the ESPHome web page and yaml size limitation issues but wanted to post here first in case anyone had any other alternative solutions as this first scenario (my office) will be the smaller of the configs. Once I get into the home theater config, I’m expecting many more IR commands needing to be defined.
Thanks,
-joni-