I’m using a motion sensor that broadcasts at 433 MHz, with a RF Bridge. When the sensor triggers, the Bridge publishes a state of true for the associated sensor. But the sensor doesn’t send anything when there is no motion, so I want the sensor to timeout to false if no code has been received within a set time. Here is the code so far:
rf_bridge:
on_code_received:
then:
- homeassistant.event:
event: esphome.rf_code_received
data:
sync: !lambda 'return format_hex(data.sync);'
low: !lambda 'return format_hex(data.low);'
high: !lambda 'return format_hex(data.high);'
code: !lambda 'return format_hex(data.code);'
- lambda: |-
if (data.code == 0x5f3577) {
id(living_room_motion).publish_state(true);
}
binary_sensor:
- platform: template
id: living_room_motion
name: "Living Room Motion"
device_class: motion
filters:
- timeout: 10s
value: false
There are two problems. First, the compiler reports a mapping error on the value line. I also tried this way with the sensor:
- platform: template
id: living_room_motion
name: "Living Room Motion"
device_class: motion
filters:
- timeout:
timeout: 10s
value: false
but that gives an invalid option, though this is the example given in the docs. so my first question is, what is the proper format for this sensor to timeout after 10 seconds and update to false after timeout?
If I write the sensor this way:
- platform: template
id: living_room_motion
name: "Living Room Motion"
device_class: motion
filters:
- timeout: 10s
then it will compile and flash, but the sensor never updates to NaN or false, just remains at true. I don’t know why. Any help is appreciated.
