Different results from native rc-switch library vs ESPHome's rc-switch (remote_receiver) for 433MHz RF signals

I would like to use ESPHome to receive RF signals from a 433MHz remote.

Testing rc-switch in Arduino IDE
I connected an RF receiver to an ESP32 board and tested it with the rc-switch library in Arduino IDE using example ReceiveDemo_Simple. This is working perfectly and all remote button presses are registered properly as protocol 1, output for a single button press generally looks like this:

11:09:55.365 → Received 8213780 / 24bit Protocol: 1
11:09:55.433 → Received 8213780 / 24bit Protocol: 1
11:09:55.468 → Received 8213780 / 24bit Protocol: 1

Sometimes there are 2 presses registered and sometimes the received data deviates a little but on every press the decimal data contains at least 8213780 once for this button. So it’s very accurate and reliable.

In ESPHome
Using the exact same hardware and wiring I tried setting up a remote_receiver in ESPHome. After some Googling and trial and error with some settings in my yaml file I ended up with this:

remote_receiver:
  pin: 0
  dump:
    - rc_switch
  tolerance: 60%
  filter: 4us
  idle: 4ms

And the same button press is detected like:

[11:04:46][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=7 data=‘0111110101010101000101001’
[11:04:46][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=7 data=‘011111010101010101011111’
[11:04:46][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=7 data=‘0111110101010101010111111’
[11:04:46][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=7 data=‘011111010101010101011111’

There is a bit more variation in the data but usually on every press at least once 0111110101010101000101001 binary data is detected. Remove the 1 at the end (and the leading 0) from the binary data and it’s the same as the decimal data from the native rc-switch library in Arduino IDE (binary 11111010101010100010100 = decimal 8213780).

How to make ESPHome work like native rc-switch?
So why does ESPHome detect these button presses as protocol 7 when the native rc-switch library detects them as protocol 1 (while the actual data payload seems to be the same)?

I would like to achieve the same level of accuracy and performance in ESPHome as when using the native rc-switch library. Any tips on how to achieve this?

1 Like

I had this issue as well and submitted it to ESPHome’s github and looked for help on their Discord. Could never figure it out or get it to work reliably. Did you ever figure it out?

I can’t remember if I ever got a reliable solution or not but currently I’m using a Sonoff RF bridge with a dedicated RF chip (flashed with Portisch firmware) that is running ESPHome. The RF chip is very reliable so I don’t use rc-switch anymore. I found documentation for the RF component to be too brief so I had to play around a while to get it working but now that it does it is very reliable and nicely integrated into HA as well.

I also opened a Github issue for an RF regression in ESPHome but I don’t think that ever got resolved. Unfortunately RF just doesn’t have a priority in home automation.

Also the Sonoff RF bridge won’t help you for 315MHz I guess, sorry. Anyways good luck!

Ah, well, thanks anyway. I have a crappy semi-permanent setup that works well enough for 315 and 433. Just not super reliable.

I setup an esp to sniff codes using arduino IDE and the RCSwitch library to compare codes from an etekcity zap remote and an ESPhome ESP with a 433mhz transmitter running an RC-switch. Heres my configuration for the rc-switch in esphome:

    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '10101010001010111000011'
          protocol:
            inverted: false
            pulse_length: 181
          repeat:
            times: 10
            wait_time: 0s

Here are the results:

ESPhome : Received 5576131 / 23bit Protocol: 1 Pulse Length: 181
          Raw Dump: 1073672368
Etekcity Zap remote: Received 5576131 / 24bit Protocol: 1 Pulse Length: 179
         Raw Dump: 1073672368

Looks like the bit length was off by 1 :frowning:
I attempted to trick esphome into transmitting a longer bitlength by placing a zero in front of the code and presto!

ESPhome : Received 5576131 / 24bit Protocol: 1 Pulse Length: 181
          Raw Dump: 1073672368
Etekcity Zap remote: Received 5576131 / 24bit Protocol: 1 Pulse Length: 179
         Raw Dump: 1073672368

My etekcity outlets started responding! :smiley:
Here’s the final snippet for esphome that worked for the etekcity outlets, maybe for other things as well.

  - platform: template
    name: MP3d Aux Heater
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '010101010001010111000011'
          protocol:
            inverted: false
            pulse_length: 181

          repeat:
            times: 10
            wait_time: 0s
4 Likes

indeed your code works and my devices receive information. even sonoff RF bridge esphome received the code code=0x5515C3 From the passed code code: ‘010101010001010111000011’.

Just chiming in here to say that I FINALLY got my Etekcity Zap outlets working with Home Assistant as well. Thanks for your helpful post @unsplorer!

Just in case anybody else runs into the same issue, for some reason when receiving the codes in HA / ESPHome they show up with three leading zeroes. So my working code looks like this:

- platform: template
    name: "Living Room Power Strip" # button 3
    turn_on_action:
      remote_transmitter.transmit_rc_switch_raw:
        code: '000100010101011100000011'
        protocol:
          inverted: false
          pulse_length: 180

        repeat:
          times: 10
          wait_time: 0s
    
    turn_off_action:
      remote_transmitter.transmit_rc_switch_raw:
        code: '000100010101011100001100'
        protocol:
          inverted: false
          pulse_length: 180

        repeat:
          times: 10
          wait_time: 0s

I also needed to set my receiver like this in order to actually sniff the codes:

# RF Receiver
remote_receiver:
  pin: GPIO4 # Wemos D2
  dump: rc_switch
  tolerance: 60%
  filter: 4us
  idle: 4ms

I also had to jump through lots of other hoops to get here, but that’s for my own thread.

It works! Wheeee!

1 Like