Last updated on August 31, 2024
Get your IR devices working again
After I updated to a more recent version of ESPHome and flashed my fan controller, it stopped being able to control the fan. After a bit of troubleshooting and searching, I found the culprit.
Note
In version 2021.12, the order of transferring bits was corrected from MSB to LSB in accordance with the NEC standard. Therefore, if the the configuration file has come from an earlier version of ESPhome, it is necessary to reverse the order of the address and command bits when moving to 2021.12 or above. For example, address: 0x84ED, command: 0x13EC becomes 0xB721 and 0x37C8 respectively.
Remote transmitter docs
Clearly, I don’t read all of the release notes…
So after reading this, I was confused. And if you’re here, you are probably confused. So here’s what I did to solve it. In my case, I used the python3 command line inside of my ESPHome docker container, but this should work anywhere you have python3 installed.
Steps for updaing the address and command values
- CLI into container
- Type
python3
- Type
bin(<value>)
and replace value with the hex or decimal value. - Reverse this value right to left:
abc
becomescba
, the0b
stays at the front. - Count the number of digits, if it’s less than 16 digits, add zero’s at the end to make it 16 digits
- Type
hex(0b<value>)
and replace value with the reversed binary. - Resulting hex should work as your
command
.
Example
Below are the steps I used to convert my Fan Oscillation values:
1 2 3 4 5 6 |
- platform: template name: Fan Oscillation turn_on_action: remote_transmitter.transmit_nec: address: 255 command: 25245 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
root@cbd65cf7857e:/config# python3 Python 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information. >>> bin(255) '0b11111111' >>> # 11111111 reversed is 11111111 >>> # 11111111 is 8 digits, so add eight zeros to the end = 1111111100000000 >>> hex(0b1111111100000000) '0xff00' >>> >>> >>> >>> >>> bin(25245) '0b110001010011101' >>> # 110001010011101 reversed is 101110010100011 >>> # 101110010100011 is 15 digits, so add one zero to the end = 1011100101000110 >>> hex(0b1011100101000110) '0xb946' |
So the new command is:
1 2 3 4 5 6 |
- platform: template name: Fan Oscillation turn_on_action: remote_transmitter.transmit_nec: address: 0xFF00 command: 0xB946 |
Be First to Comment