Help trying to get 433 MHz door sensors to work with remote_receiver

I’m trying to get a couple of generic 433 MHz door sensors to work with an ESP32 board + SRX882 RF receiver module. I’ve gotten as far as determine what RAW values are sent on open and close. After this I’m stuck. I don’t understand how to implement these values as a switch/sensor. All I want is for these values to set a switch to on or off in Homeassistant so I can use the state for automation.

The only example in the documentation is for binary sensor which doesn’t seem to be the correct component to use for this application. Just for testing I tried it anyway like this:

binary_sensor:
  - platform: remote_receiver
    device_class: door
    name: "Fridge Door Open"
    rc_switch_raw:
      code: "000000110100010011100011"
      protocol: 6

This sets the sensor to ON every time the sensor sends the open RAW value. Problem is that it seems the sensor sends this value several times so the sensor’s ON/OFF state just flickers for a second and is set back to OFF at the end. My remote_receiver yaml looks like this:

remote_receiver:
  pin: 
    number: 26
    inverted: True
  dump:
    - rc_switch
  # Settings to optimize recognition of RF devices
  tolerance: 50%
  filter: 500us
  idle: 10ms
  buffer_size: 2kb

If anyone could point me in the right direction I would really appreciate it. I’ve looked through the documentation for hours but I’m not getting anywhere.

Well you’re pretty close.
To solve the flickering of the sensor you should use a filter, there is the delayed off for example, this will cause the sensor to be on and go off when you release the button, most likely.

Usually the sensors like window contacts should send a different code for opening and another for closing, so then you’ll have a bit of work, you’ll need to setup two binary_sensors platform remote_receiver and then one binary sensor platform template, then you do a on_press automation on each of the remote_receiver where you call the template binary sensor publish state message. I’m pretty sure you’ll get it working

Anyway we are here if you need more assistance!

Thank you for the response. Sorry, I’m really stupid when it comes to stuff like this, I just can’t get my head around it. Stupidly stubborn at the same time though …

Yes, it’s a door sensor and sends one code for opening and another for closing. I managed to make some progress by sifting through another thread. I have the following yaml right now:


binary_sensor:
  - platform: remote_receiver
    name: "Fridge Door Open signal"
    device_class: door
    internal: true
    on_press:
      then:
        - switch.template.publish:
            id: fridgeswitch
            state: OFF
    rc_switch_raw:
      code: "000000110100010011100011"
      protocol: 6
  - platform: remote_receiver
    name: "Fridge Door Close signal"
    device_class: door
    internal: true
    on_press:
      then:
        - switch.template.publish:
            id: fridgeswitch
            state: ON
    rc_switch_raw:
      code: "000000110100010011101001"
      protocol: 6

switch:
  - platform: template
    name: "Fridge door switch"
    id: fridgeswitch

Am I on the right path? While this kind of works (the switch state of “fridgeswitch” is properly set on and off) I still get the repeated ON/OFF switching of the binary sensor in the log like following:

[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][switch:045]: 'Fridge door switch': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[02:57:54][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF
[02:57:54][D][remote.rc_switch:240]: Received RCSwitch Raw: protocol=6 data='00000011010001001110100'

Could I solve this with delayed_off? I’m not sure why the same RAW data triggers state ON and OFF alternatively like that. It may not even matter but it feels wrong to see that in the log.

EDIT: Yes, setting delayed_off to 100ms results in the following and nothing else:

[03:24:51][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state ON
[03:24:51][D][switch:045]: 'Fridge door switch': Sending state ON
[03:24:52][D][binary_sensor:033]: 'Fridge Door Close signal': Sending state OFF

I don’t know if this is the correct solution but it seems to work.

1 Like

Read the docs :slight_smile:

It says:

Each time the pre-defined signal is received, the binary sensor will briefly go ON and then immediately OFF.

So basically your device is sending the signal repeatedly and this are interpreted as repeated presses.

I see you fixed the repeat issue.

Next step is you adding a sensor which actually tell’s you the door state: for that you’ll need a template binary_sensor with the following code more or less:

I see you added a switch, you don’t want that, you want a binary_sensor, but the rest seems ok

Switch are like something you can toggle from the UI, an output from the ESPHome, binary_sensors are digital inputs, you can only observe

1 Like

433mhz switches like this don’t get a feedback from the receiver when the data is received, so they might send the data several times just hope the receiver picks it at least once

1 Like

433mhz switches like this don’t get a feedback from the receiver when the data is received, so they might send the data several times just hope the receiver picks it at least once

I see, that makes sense. That would explain it. Yeah switch didn’t feel right, but it “worked”. I deleted that part and added the following under binary_sensor: (renamed the ID and swapped the ON and OFF raw code to properly represent open and closed state):

  - platform: template
    name: "Fridge door state"
    device_class: door
    id: fridgedoorstate

This seems to work. Now for implementing it in some automations. Thank you for helping an idiot like me.

My pleasure. Don’t be hard on yourself. It takes some time to grasp it. There is a lot to learn.
Happy homing

2 Likes

This is what I use for my door sensors:

  - platform: remote_receiver
    id: front_door_open
    internal: true
    rc_switch_raw:
      code: '000010100110101100001010'
      protocol: 2
    filters:
      delayed_off: 100ms
      

  - platform: remote_receiver
    id: front_door_closed
    internal: true
    rc_switch_raw:
      code: '000010100110101100001110'
      protocol: 2
    filters:
      delayed_off: 100ms

  - platform: template
    name: Front Door
    device_class: door
    lambda: |-
      if (id(front_door_open).state) {
        // front dooris open
        return true;
      } else if (id(front_door_closed).state) {
        // front door closed
        return false;
      } else {
        return {};
      }

BTW my door sensors have an open and closed code.

2 Likes

Hello @osen, hello @glmnet. After reading this thead, I’m almost done… This works with a reed switch but does not work with a remote control.
In log, I see codes of reed switch and remote controll, but only with reed switch I got state change of my template binary_sensor.

  - platform: remote_receiver
    name: rc1
    on_press:
      then:
        - binary_sensor.template.publish:
            id: alarm
            state: OFF
    rc_switch_raw:
      code: '101111101010100101010001'
      protocol: 2
  - platform: remote_receiver
    name: reed1
    on_press:
      then:
        - binary_sensor.template.publish:
           id: alarm
           state: ON
    rc_switch_raw:
      code: '000111011011111010010111'
      protocol: 2
  - platform: template
    name: Alarm
    id: alarm

The remote control code with this code does not work for me either. did you solve the problem?

See this post for a sensor with 2 RF codes for 2 states