Node-Red Newbie, Binary State is triggered when my ESP home device goes off line, how do I trap it

As stated in the title I am detected an input on an ESP 32 device, it sometimes becomes unavailable for a few seconds (thats another issue). It does not trigger an event in HA but I have just added Node-Red to get an Alexa announcement and this gets triggered when my ESP is unavailable.

Is there a simple way around this, i.e. can I check for Availability. I am using “If State is True” as my Node-Red trigger

Regards Dave

Can you post you flow

image

[{"id":"20478e07.e445a2","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"39fed3bc.1db69c","type":"api-call-service","z":"20478e07.e445a2","name":"Turn Light On","server":"7f74e030.27ef9","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.socket_4","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":650,"y":300,"wires":[[]]},{"id":"36b820f6.0eaa6","type":"api-call-service","z":"20478e07.e445a2","name":"Turn Light Off","server":"7f74e030.27ef9","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.socket_4","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":660,"y":400,"wires":[[]]},{"id":"ac4b6c08.7c797","type":"server-state-changed","z":"20478e07.e445a2","name":"","server":"7f74e030.27ef9","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.garage_alarm_set","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":300,"y":340,"wires":[["39fed3bc.1db69c"],["36b820f6.0eaa6"]]},{"id":"7f74e030.27ef9","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

As you can see the Binary Alarm set went off line for < 1Min and Node-Red was triggered but my HA routine was not.

Use a switch node to stop all messages other than on or off

Hi, Thanks

I used a string output from the Events :State and the used “on” and “off” in the newly added switch node.

I could therefore add a 3rd output for “unavailable” which could notify me if a device goes off line.

Many thanks for your help.

Regards Dave