Faking an IR remote control using ESPHome

BTW, I also noticed, when the TV is turned on, it returns pronto.239 in the second line. If its turned off, it only returns pronto.237. And turnon pronto has a lot more value than turnoff. but values are totally random. I think we cant use the values but may the length of the value and prono.239 can determine if its on or off state

This is a great guide, thanks!! If anyone decides to use the esp8285 combo board from aliexpress for $3-4, it works but is a bit directional due to only having one IR Led.

Board:
esp_ir_tr
https://www.aliexpress.us/item/2255800823582816.html

Micro Usb Power:
https://www.aliexpress.us/item/2255800599055502.html

Case:

USB Programmer:
https://www.aliexpress.us/item/2251832343422714.html

Esphome Code with Dump (passwords changed to ???, pioneer codes worked best for me):

esphome:
  name: irremote1
  friendly_name: IRremote1
esp8266:
  board: esp8285
# Enable logging
logger:
# Enable Home Assistant API
api:
  encryption:
    key: "???"
ota:
  password: "???"
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Irremote1 Fallback Hotspot"
    password: "???"
captive_portal:
remote_receiver:
  pin:
    number: GPIO14
    inverted: true
  dump: all
remote_transmitter:
  pin: GPIO4
  carrier_duty_percent: 50%

# Example to turn on/off a Hisense TV
button:
  - platform: template
    name: "On/Off Pioneer"
    on_press:
      - remote_transmitter.transmit_pioneer:
          rc_code_1: 0x2008
4 Likes

@soubhik reading through all you texts again I am a bit confused. Do I get you right that what you receive here happens after you send from ESPhome? It looks like that in your very first posting. But in the second the transmit lines are missing. Did you cut them out?
From your first example I conclude that what you are receiving here is not a response of the controlled device but simply the IR data that you sent out yourself from ESPhome. The receiver unit of ESPhome receives IR from is own transmitter LED. If this is the case then there is no way that on and off can be different. It must be by accident / IR noise. Please do some more testing out explain what exactly we are seeing here. (Who sent the data? Did you press the remote or did you send from ESP? What happens if you only use the remote?)

BTW: the two lines of data are actually just one line that is wrapped around because it contains too much data. 237 and 239 are line numbers in the python code. 237 is the first line output code and 239 is where the wrapping into additional lines is coded.

Hi, Jƶrg.

First of all, thanks a lot for the invaluable information youā€™ve already provided here.

Iā€™m running into issues with the data codes I currently have, so Iā€™d like to understand what is the best course of action.

Iā€™ve captured a handful of codes from one Denon and one Sony remotes using LIRC in my Intel NUC running Ubuntu. The NUC has a built-in IR receiver, which I could set to ā€˜generic remote controllerā€™ via the BIOS. It worked just fine, and I got all the codes I needed.

Now Iā€™m trying to use my Sony codes to configure the IR transmitter in an M5Stack Atom Echo, which is primarily set up as a voice assistant.

The problem is that ESPHome throws the following error when I input my Sony codes:

value must be at most 4294967295.

As you can see below, the three codes I captured have the same length:

  • KEY_POWER
    0x8A00000100022B

  • KEY_VOLUMEUP
    0x7000000100049C

  • KEY_VOLUMEDOWN
    0x70000001000493

All of these codes are longer than the Sony code posted by jbvioix, for example. Is this due to the fact that I used LIRC instead of the method described here?

The Pi Iā€™m using to run Home Assistant OS is enclosed in an Argon One M.2, which also has an IR receiver. However, I believe itā€™s not possible to access it via ESPHome, so Iā€™m stuck with LIRC for now. Would configuring the NUCā€™s IR receiver as RC6 instead of ā€˜generic remote controllerā€™ produce codes I can actually use?

Thanks in advance!

Hi @guilster,
sorry, but I canā€™t help you on this one.
4294967295 is the maximum value of an unsigned integer value in C++ (4 bytes). The data property of remote_transmitter.transmit_sony is in fact of type unsigned int. So you will not be able to send larger ints like 0x8A00000100022B which would require 7 bytes.
I read that lirc uses another code system than ESPhome and that there are ways to convert from lirc to Pronto codes (which ESPhome in fact can use and send). But I never tried or needed that.
Maybe your best option is to buy a cheap IR receiver PCB like the one shown in my guide and temporarily attach it to your M5Stack. This way you can receive and analyze the remote codes directly with ESPhome.

1 Like

Thanks a lot for looking into it, @jpsy. Itā€™s much appreciated.

Iā€™ve just read about converting LIRC codes to Pronto codes on remotecentral.com, but the solutions mentioned are all fairly tricky. I reckon the best course of action is to indeed buy a receiver for this project.

Thanks again!

I just logged onto the forum for the first time in a while. Does anyone still need my help?

Hi yes; can i ask:

Iā€™m using the broadlink RM4 to send IR signals and now in a second room I am going to send IR signals to RGB LEDā€™s with an ESPHOME.

Question: how to send the learned broadlink IR codes with the ESPHOME to my LEDā€™s ?
The format learned is a long (150 or so) string.

Thanks

What is the learned protocall. Maybe a log output?

If you had not posted this I would have given up. I thought the code received was the first line in the log and tried that but failed every time. No I see you used the other lines as well and combined them.
I have spent a good 8 hours just trying to get my goldair remote to work.
No I can test for a final time combining the multiple lines of logoutput. Feeling positive about this.

I had an old dvd player. Strip out the IR receiver. It works.
Had an old car head unit with IR receiver. Works as well.
Another receiver I used was from a dish decoder box.
My current receiver is from an old amplifier Sakyno. Works good

@Jpsy Thank you for the writeup on this project. It was very helpful.

Also, for those who may be interested, here is a case if you want to print one for the components used in this project:

Wemos D1 Mini Case | Printables.com

2 Likes

Iā€™ve got an old toshiba mini-split (or high-wall) air conditioner. I have it working with one of those esp8285 boards from aliexpress same as @jumon - https://www.aliexpress.us/item/2255800823582816.html

So far it is working well with this configuration. However, one function missing from the remote is the ability to configure the vane swinging. The AC has both vertical & horizontal, but I only care about vertical. So I enabled logger level: verbose and dump: all and tried to capture:

remote_receiver:
  id: ir_receiver 
  pin:
    number: GPIO14
    inverted: True
    mode:
      input: true
      pullup: true
  tolerance: 55%
  dump: all
 
remote_transmitter:
  id: ir_transmit
  pin: GPIO4
  carrier_duty_percent: 50%
 
climate:
  - platform: hitachi_ac424
    name: "livingrm-ac"
    id: climate_ac
    transmitter_id: ir_transmit
    receiver_id: ir_receiver
    sensor: temp
logger: 
  level: VERBOSE

Then pressed the virtical vane swing button on my remote a few times, and got a bunch of pronto/panasonic/AEHA codes in the logs. I tried the Panasonic/AEHA codes (these appear consistent each time) but my AC does not respond to either.

And I donā€™t think I can use the pronto code - it seems to change each time. I tried sending snippets, but it says ā€œPronto - Inconsistent data, not sendingā€.

What am I missing?

[16:17:45][I][remote.pronto:237]: Received Pronto: data=0000 006D 012A 0000 0081 0040 0010 0030 0010 0011 000F 0012 000F 0012 000F 0012 000F 0012 000F 0013 000F 0012 000F 0012 000F 0012 000F 0012 000F 0012 0010 0030 000F 0012 000F 0012 000F 0012 000F 0012 000F 0012 0010 0012 000F 0012
[16:17:45][I][remote.pronto:239]: 0010 0012 000F 0012 000F 0012 0010 0012 000F 0012 0010 0011 0010 0012 000F 0013 000F 0012 0010 0012 000F 0031 000F 0012 0010 0031 000F 002F 000F 0030 0010 002F 0010 002F 0010 0030 000F 0013 000E 0030 000F 0030 000F 0030 000F 0030 000F 0030 0010 0030 0010 002F 000F 0030 000F 0030 0010 0011 0010 0012 0010 0012 000F 0012 000F 0012 000F 0013 000F 0012 0010 0012 000F 0012 000F 0012 000F 0030 000F 0030 0010 0012 000F 0012 000F 0030 000F 0030 000F 0030 0010 002F 000F 0012 0010 00
[16:17:45][V][remote.drayton:176]: Decode Drayton: Fail 1, - 0
[16:17:45][I][remote.panasonic:070]: Received Panasonic: address=0x8008, command=0x0002FDFF
[16:17:45][I][remote.aeha:099]: Received AEHA: address=0x8008, data=[0x00,0x02,0xFD,0xFF,0x00,0x33,0xCC,0x19,0xE6,0x81,0x7E,0x2A,0xD5,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC8,0x37,0x8F,0x70,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC0,0x3F]
[16:17:45][W][component:214]: Component remote_receiver took a long time for an operation (0.11 s).
[16:17:45][W][component:215]: Components should block for at most 20-30ms.
[16:17:47][I][remote.pronto:237]: Received Pronto: data=0000 006D 012A 0000 0080 0040 000F 0030 0010 0012 000F 0012 000F 0012 0010 0012 0010 0011 0010 0012 000F 0012 0010 0012 0010 0012 000F 0012 000F 0012 0010 0030 000F 0012 000F 0012 0010 0012 000F 0012 000F 0012 000F 0012 0010 0012
[16:17:47][I][remote.pronto:239]: 0010 0012 0010 0012 0010 0012 000F 0012 0010 0012 000F 0012 000F 0012 0010 0012 000F 0012 0010 0012 000F 0030 0010 0012 0010 002F 000F 0030 0010 002F 0010 002F 0010 0030 000F 0030 000F 0012 000F 0030 0010 0030 0010 0030 000F 0030 000F 0030 000F 0030 0010 0030 0010 002F 0010 0030 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 000F 0012 000F 0012 0010 0011 0010 0012 000F 0030 0010 0030 000F 0012 0010 0012 0010 0030 0010 0030 0010 0030 000F 0030 000F 0012 000F 00
[16:17:47][V][remote.drayton:176]: Decode Drayton: Fail 1, - 0
[16:17:47][I][remote.panasonic:070]: Received Panasonic: address=0x8008, command=0x0002FDFF
[16:17:47][I][remote.aeha:099]: Received AEHA: address=0x8008, data=[0x00,0x02,0xFD,0xFF,0x00,0x33,0xCC,0x19,0xE6,0x81,0x7E,0x2A,0xD5,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC8,0x37,0x8F,0x70,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC0,0x3F]
[16:17:47][W][component:214]: Component remote_receiver took a long time for an operation (0.11 s).
[16:17:47][W][component:215]: Components should block for at most 20-30ms.
[16:17:51][I][remote.pronto:237]: Received Pronto: data=0000 006D 012A 0000 0081 0040 0010 0030 000F 0012 0010 0012 000F 0012 0010 0012 000F 0012 000F 0013 000E 0012 000F 0012 0010 0012 000F 0012 000F 0012 000F 0030 000F 0012 0010 0011 0010 0012 0010 0011 000F 0012 0010 0012 000E 0012
[16:17:51][I][remote.pronto:239]: 000F 0012 0010 0012 000E 0012 000F 0012 000F 0012 000F 0012 000F 0013 000E 0012 000F 0012 0010 0011 000F 0030 000F 0012 000F 0030 000F 0030 0010 0030 000F 0030 0010 0030 0010 002F 000F 0012 000F 0030 000F 0031 000E 0030 000F 0030 000F 0030 000F 0031 000E 0030 000F 0030 000F 0030 0010 0011 000F 0012 000F 0012 000F 0012 000F 0012 0010 0013 000E 0013 000F 0011 000F 0012 0010 0011 000F 0030 000F 0030 000F 0012 000F 0012 0010 0030 000F 0030 0010 002F 000F 0030 000F 0012 000F 00
[16:17:51][V][remote.drayton:176]: Decode Drayton: Fail 1, - 0
[16:17:51][I][remote.panasonic:070]: Received Panasonic: address=0x8008, command=0x0002FDFF
[16:17:51][I][remote.aeha:099]: Received AEHA: address=0x8008, data=[0x00,0x02,0xFD,0xFF,0x00,0x33,0xCC,0x19,0xE6,0x81,0x7E,0x2A,0xD5,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC8,0x37,0x8F,0x70,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC0,0x3F]
[16:17:51][W][component:214]: Component remote_receiver took a long time for an operation (0.11 s).
[16:17:51][W][component:215]: Components should block for at most 20-30ms.
[16:32:28][I][remote.pronto:237]: Received Pronto: data=0000 006D 012A 0000 0081 0040 0010 002F 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 002F 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012
[16:32:28][I][remote.pronto:239]: 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 002F 0010 0012 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 0012 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 002F 0010 0030 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 0012 0010 002F 0010 002F 0010 0012 0010 0012 0010 002F 0010 0030 0010 002F 0010 002F 0010 0012 0010 00
[16:32:28][V][remote.drayton:176]: Decode Drayton: Fail 1, - 0
[16:32:28][I][remote.panasonic:070]: Received Panasonic: address=0x8008, command=0x0002FDFF
[16:32:28][I][remote.aeha:099]: Received AEHA: address=0x8008, data=[0x00,0x02,0xFD,0xFF,0x00,0x33,0xCC,0x19,0xE6,0x81,0x7E,0x2A,0xD5,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC8,0x37,0x8F,0x70,0x00,0xFF,0x00,0xFF,0x00,0xFF,0xC0,0x3F]
[16:32:28][W][component:214]: Component remote_receiver took a long time for an operation (0.11 s).

how do I get a proper switch with on and off function?
with this configuration my switch.irreciever_bose_power_send states is always off
thank you very much!

remote_receiver:
  pin:
    number: GPIO016
    inverted: true
  dump: all

remote_transmitter:
  pin: GPIO17
  carrier_duty_percent: 50%

switch:
  - platform: template
    name: "Bose Power send"
    id: bose_power_send
    icon: mdi:power
    turn_on_action:
      remote_transmitter.transmit_nec:
        address: 0xA0BA
        command: 0xB34C
    turn_off_action:
      remote_transmitter.transmit_nec:
        address: 0xA0BA
        command: 0xB34C

This has nothing to do with IR and should go into a separate question. But for what itā€™s worth try:

optimistic: true

Is your control LED blinking when you send? If no such LED you might check for a faint glow from the IR LED(s) in total dark.

Point your smartphone camera at the IR LED. Nearly every modern smartphone will detect IR LEDs much more reliably than our eyeballs. The phone will detect in the light or the dark, and our eyes will be iffy, even in the dark.

2 Likes

Hi Jorg. Thanks for the wonderful post and the details you have shared. I have recently converted few of the IR blasters using Libretiny successfully. Now the IR blasters are running with esphome. This guide is really useful while updating the IR Transmitter and Receiver as a first time user of the IR devices running with esphome.

I have a query though. One of my device (STB) is giving pronto as the output, if I press any key in the remote when the setting is dump: all. I tried to use the pronto code as it is received in the log, but I was getting error in the log Pronto - Inconsistent data, not sending.

After reading this and couple of other threads, I have changed the setting to dump: raw. I am able to get the raw codes but they are very short codes, different value each time when I press the same key again.

I could find similar model of STB mentioned at this URL(https://gist.github.com/bengtmartensson/1ec8f5d31b6b88f8ea097fef72fe324a). From the configuration available in the link, Protocol used is Nokia32 (rcmm), however I could not find any such protocol with esphome.

Below given are the configurations I have tried so far. I tried to put 5 of the received raw codes as well. I could see the IR LED is emitting light when I press the corresponding button from esphome web URL of the device, using my mobile phone camera. However the STB is not responding.
I have successfully connected and able to control all the IR devices that I use, except this one. Are there any other thing I have to check? What I am missing?

Digit 1
  - platform: template
    name: "Num1"
    id: Num1
    turn_on_action:
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 36kHz
          code: [333, -253, 216, -218, 219, -593, 219, -406, 187, -625, 188, -218, 219, -281, 219, -225, 180, -282, 218, -219, 218, -594, 187, -438, 187, -781, 219, -187, 258, -210, 219, -250, 187, -438, 187]

Digit 1
  - platform: template
    name: "Num1"
    id: Num1
    turn_on_action:
      - remote_transmitter.transmit_pronto:
          repeat:
            times: 5
            wait_time: 2 ms
          data: "0000 006D 0010 0000 0008 0020 0008 0046 000A 0020 0008 0020 0008 001E 000A 001E 000A 0046 000A 001E 0008 0020 0008 0020 0008 0046 000A 0046 000A 0046 000A 001E 000A 001E 0008 06C3"

Multi line raw codes:
  - platform: template
    name: "Num1"
    id: Num1
    turn_on_action:
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 36kHz
          code: [  349, -222, 253, -211, 189, -625, 219, -406, 219, -562, 219, -219, 225, -212, 219, -281, 226, -212, 187, -625, 219, -563, 239, -386, 190, -788, 209, -188, 256, -215, 219, -247, 219, -406, 219 ]
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 36kHz
          code: [  344, -218, 219, -250, 188, -625, 219, -406, 219, -576, 205, -219, 187, -281, 188, -281, 235, -203, 187, -282, 187, -594, 219, -409, 184, -782, 218, -219, 188, -281, 187, -282, 187, -438, 218 ]
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 36kHz
          code: [  337, -250, 225, -212, 219, -594, 218, -407, 187, -613, 200, -219, 218, -250, 188, -281, 197, -272, 188, -250, 187, -625, 219, -418, 175, -750, 219, -219, 219, -259, 178, -282, 187, -438, 218 ]
      - remote_transmitter.transmit_raw:
          repeat:
            times: 15
            wait_time: 16 ms
          carrier_frequency: 36kHz
          code: [  352, -249, 231, -209, 216, -594, 218, -406, 241, -571, 219, -187, 250, -219, 219, -249, 231, -208, 217, -625, 187, -615, 198, -405, 188, -749, 219, -237, 207, -282, 211, -187, 219, -437, 219 ]

Several months ago I used the original post to set up an D1-mini to turn my LG oled tv off and on via an automation.
The receiver worked very well and showed me codes for several different manufacturers. The one that worked most reliably was a pioneer code so I used that one.

In the last couple of days I have set up a new D1-mini using the same code and the same ir receiver and all I get now is pronto codes. Doesnā€™t matter which remote control I use (Denon avr, LG oled tv, led strip controller) they only ever give pronto codes.
I have tried inverted true and false, no different.

Iā€™m not sure what has changed. Anyone care to guess?

Hi, Have you changed the Dump: option to pioneer or raw format and checked? Can you share your YAML in ā€˜Preformatted Textā€™?

Iā€™m trying to transition my ESP from a program I made to ESPHome and this helped me a lot!
Bit annoying that NEC codes are different between remote_transmitter and arduinoā€™s IrSender.sendNEC because of the parity bits, but I got it working in the end.

But now Iā€™m wondering. Is possible to make some kind of virtual analog control of brightness in ESPHome YAML?

You see, thereā€™s 9 steps between the dimmest and the brightest setting on my RGB strip.
When I booted the ESP with my program, it would send 9 times code to dim the light and then it knew the brightness is 0.
And when I wanted to change the brightness, Iā€™d send request ā€œsetBrightness=5ā€ and it would send 5 times the code to brighten the light. If Iā€™d decided to change the brightness again to 2, it would send 3 codes to dim the light.

Is possible to do something like this in ESPHome too? I tried looking in the docs and googling, but I wasnā€™t successful, probably because I have no idea how I would call this function.