There is actually an example in the docs that shows you how to define and how to increment a global variable:
Please read, try and I will help, if you get stuck.
There is actually an example in the docs that shows you how to define and how to increment a global variable:
Please read, try and I will help, if you get stuck.
Thank you so much!
So I did this
binary_sensor:
- platform: gpio
id: reset_button
pin: GPIO26
- platform: template
name: Device State Sensor
id: device_state
device_class: power
lambda: |-
if ( id(my_global_int)>1) {
return true;
}
else {
return false;
};
sensor:
- platform: uptime
name: Uptime
text_sensor:
- platform: wifi_info
ip_address:
id: ip_address
name: IP Address
globals:
- id: my_global_int
type: int
restore_value: no
initial_value: '0'
remote_receiver:
id: receiver
dump: all
pin:
number: GPIO8
inverted: true
mode: INPUT_PULLUP
on_pronto:
then:
- lambda: |-
id(my_global_int) += 1;
ESP_LOGD("main", "Reset counter: %d", id(my_global_int));
remote_transmitter:
id: transmitter
pin: GPIO7
carrier_duty_percent: 50%
button:
- platform: restart
id: restart_button
name: Restart
- platform: safe_mode
id: safe_mode_button
name: Safe Mode
- platform: template
name: "TV On/Off"
on_press:
- remote_transmitter.transmit_pioneer:
rc_code_1: 0x0212
- lambda: |-
id(my_global_int) = 0;
ESP_LOGD("main", "Reset counter: %d", id(my_global_int));
But the reset counter is not initializing! I coudn;t figure out how to add the delay, may be thats why. the Sensor stays on.
[17:31:55][I][ota:113]: Boot seems successful, resetting boot loop counter.
[17:31:55][D][lt.preferences:104]: Saving 1 preferences to flash...
[17:31:55][D][lt.preferences:132]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[17:32:28][D][main:082]: Reset counter: 1
[17:32:28][I][remote.jvc:049]: Received JVC: data=0x02FD
[17:32:28][I][remote.lg:054]: Received LG: data=0x02FD48B7, nbits=32
[17:32:28][I][remote.nec:070]: Received NEC: address=0xBF40, command=0xED12
[17:32:28][I][remote.pioneer:149]: Received Pioneer: rc_code_X=0x0212
[17:32:28][I][remote.pronto:237]: Received Pronto: data=0000 006D 0022 0000 0155 00AE 0015 0016 0015 0018 0015 0016 0017 0018 0013 0016 0013 0018 0014 0043 0015 0015 0016 0043 0015 0043 0016 0041 0015 0042 0016 0043 0016 0042 0015 0017 0015 0040 0017 0016 0014 0043 0016 0016 0017 0015
[17:32:28][I][remote.pronto:239]: 0015 0042 0016 0016 0016 0016 0015 0017 0015 0043 0016 0015 0016 0042 0016 0041 0015 0016 0015 0043 0015 0042 0015 0042 0016 0181 06C3
[17:32:29][W][component:204]: Component remote_receiver took a long time for an operation (0.06 s).
[17:32:29][W][component:205]: Components should block for at most 20-30ms.
[17:32:29][D][main:082]: Reset counter: 2
[17:32:29][I][remote.pronto:237]: Received Pronto: data=0000 006D 0002 0000 0159 0054 0016 0181 06C3
[17:32:29][D][binary_sensor:036]: 'Device State Sensor': Sending state ON
[17:32:29][D][main:082]: Reset counter: 3
[17:32:29][I][remote.pronto:237]: Received Pronto: data=0000 006D 0003 0000 0075 000B 0016 002F 0096 0181 06C3
[17:32:46][D][main:082]: Reset counter: 4
[17:32:46][I][remote.jvc:049]: Received JVC: data=0x02FD
[17:32:46][I][remote.lg:054]: Received LG: data=0x02FD48B7, nbits=32
[17:32:46][I][remote.nec:070]: Received NEC: address=0xBF40, command=0xED12
[17:32:46][I][remote.pioneer:149]: Received Pioneer: rc_code_X=0x0212
[17:32:46][I][remote.pronto:237]: Received Pronto: data=0000 006D 0022 0000 0155 00AE 0015 0016 0016 0015 0016 0016 0016 0016 0015 0017 0015 0015 0015 0044 0015 0016 0016 0041 0015 0042 0016 0042 0017 0042 0017 0041 0017 0041 0014 0015 0016 0042 0018 0014 0016 0041 0016 0018 0014 0016
[17:32:46][I][remote.pronto:239]: 0015 0042 0017 0016 0014 0018 0014 0018 0015 0043 0016 0016 0015 0043 0015 0043 0015 0017 0014 0043 0016 0041 0015 0042 0017 0181 06C3
[17:32:46][W][component:204]: Component remote_receiver took a long time for an operation (0.06 s).
[17:32:46][W][component:205]: Components should block for at most 20-30ms.
[17:32:46][D][main:082]: Reset counter: 5
[17:32:46][I][remote.pronto:237]: Received Pronto: data=0000 006D 0002 0000 0155 0057 0016 0181 06C3
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:
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
@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.
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:
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.
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?