Binary Sensor, state reset using Node Red

Hi I’ve got a window sensor which only has a single output when components are separated. Is there a way using Node red to reset the state after say 5 seconds?

You can try an use an mqtt sensor. So when state of the device changes to no-contact publish to the mqtt sensor topic “on”, set delay 5 seconds then publish again to the same sensor this time “off”.
You will have to use the mqtt sensor for your automations.

As far as I know the ha node cannot set state to entities as we do in the ha front end.

1 Like

so you think i’ll need to do it in code rather than node red? I’ll have another play tonight

worked it out. MQTT platform has a offdelay function. thanks for your help

You create the mqtt binary sensor in ha yaml. But you manage the on,off and delay in nodered.

Hi Subzero79, You can just add the line off_delay: (time in seconds). Example below for 30sec.

- platform: mqtt
  name: "Garage Door"
  state_topic: "tele/RF_Bridge/RESULT"
  value_template: '{{value_json.RfReceived.Data}}'
  payload_on: "C98499"
  payload_off: "C98499off"
  device_class: Door
  optimistic: false
  qos: 1
  retain: false
  off_delay: 30