NodeRed check for timeouts on ESPHome messages? (ESPhome watchdog)

Hi,
Is there a good way in NodeRed to detect that an ESPHome device is no longer sending messages?
I have a sensor that sends temperature data every x-minutes
I wanted to create an alarm if there were no messages in e.g. 3x-minutes
I found the Timeout node, but how do I check for “new ESPHome message”?
thoughts ?
thanks,
chrisV

I would follow a route where you check the age of the last update. This might provide some useful hints:

Mmm… right MQTT…
I am using the “native API” protocol in ESPHome (Native API Component — ESPHome), not MQTT (MQTT Client Component — ESPHome )
A timeout solution (a watchdog) for MQTT is described here by Andreas Spiess (https://youtu.be/KJRMjUzlHI8?t=1015)
I would like to do the same thing, but on the native API protocol.

chris

MQTT or API does not matter as far as I know.
You should always have a last_changed property on the state information.

I checked with three entities on my system. These came in through the ESPHome API, MQTT and a direct HTTP POST to the Home Assistant API. For all three, I can query the last_changed property to find their age.

Aha… I completely misunderstood the timeout node. My bad (I am not a programmer… it shows)
I setup this test flow and it works
[{"id":"bb10ad44.dd3e8","type":"timeout","z":"3adeccff.3a62c4","name":"LivingroomTempSensor","outtopic":"testtopic001","outsafe":"Safe","outwarning":"","outunsafe":"","warning":"","timer":"10","repeat":false,"again":false,"x":200,"y":180,"wires":[["7e295d7c.682abc"]]},{"id":"7e295d7c.682abc","type":"debug","z":"3adeccff.3a62c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":440,"y":120,"wires":[]},{"id":"3bf2ef0.6c20992","type":"inject","z":"3adeccff.3a62c4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"11","crontab":"","once":true,"onceDelay":"5","topic":"testtopic001","payload":"","payloadType":"date","x":160,"y":100,"wires":[["bb10ad44.dd3e8"]]}]
Test:
Set the repeat interval in the injectNode to e.g. 4 seconds, then the timeout node restarts its counter before it reaches zero. Which is as expected
Set the repeat interval in the injectNode to e.g. 11 seconds, then the timeout node reaches 0 and generates an alert signal. Which is what I wanted

@mmakaay thank you for making me see the light here :wink:
chrisV

Halejuja! :innocent:
Well done!

@mmakaay Can you elaborate on how you got the events from ESPHome?

My nodeMCU sends events every 10 seconds and I want an alert if i missed 2 events.
I cannot find a Node that shows the events from ESPHome (which are not necessary state-changed events)
thoughts?
thanks,
chrisV

I get state updates that are published from ESPHome. Your opening post talks about “temperature data every x-minutes”, so that sounds a lot like regular state updates to me, which would match what I was looking at on my system.

What kind of events should I think about here?

Without knowing the details, if you’re talking about device-based triggers for example, those would not be visible this way. To track those, you could however create an automation, that updates a DateTime helper or possibly resets a Timer helper.

Hi Maurice (@mmakaay )
I have attached a screenshot of the ESPHome “events” that I mentioned.
My nodeMCU sends those events every 10 seconds (high frequency just for testing).
The goal is to trigger an event/alert in Home-Assistant if it misses e.g. 2 events.
I was hoping to see an Home-Assistant event for every event that nodeMCU sends to Home Assistant. It turned out to be wishful thinking :innocent:

Maybe @frenck has an idea. The capability to alert if a node is offline (watchdog) seems like a fundamental capability to me. But I’m not a programmer, I’m not sure if it can be done technically
Thanks a lot,
chrisV

Those are simply state updates. I would not name those “events”. These uodates are sent to HA, where they end up in entities that are related to the device. For these entities I would suspect that you can access last_changed.

If you go to Configuration → Integrations → ESPHome device, do you see these measurements indeed as entities for the device?