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:
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
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.
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
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
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.
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.