optimal (most stable) method to handle a "heartbeat" from a sensor


I’ve created a water detection sensor using MySensors and successfully connected it to my VeraPlus and all is working OK. Now, I would like to add a “heartbeat” function to announce when something might be wrong with the sensor.

I have not decided on the final heartbeat rate but I was thinking about something in the 1 or 2 minute range. Given the relatively slow rate I thought there might be several ways to monitor this is Vera.

My concept is to have the heartbeat created every minute then verify it occurred every 2 minutes.

My question is what would be the best approach?. I believe PLEG could accomplish this easily however I would prefer to handle it without an add on.

I see a few ways:

[ol][li]Run a scene every 2 minutes and check if the heartbeat was set to 1 or maybe true. It could be stored in a local variable or a MyString entry.[/li]
[li]Use the luup.call_timer and somehow sense the heartbeat state. I’m not sure how this would be implemented but I don’t mind learning how. I think the docs can help me here.[/li][/ol]



I’ll go for something very similar to door sensors.
Just log LastTripTime and run a scene to check the amount of minutes passed from the last trip.
I use a very similar approach for a virtual sensor.

thanks, but how do you know the sensor is still “alive” and functioning in between trips?

Use tripped to save the current state and lasttripped to save the last heartbeat date and time.
So, basically, you’d save last time the sensor reported and use a scene to make a calculation.
If the last time the sensor reported is 15 minutes ago (or what you prefer), you can alert yourself.

Take a look at this if you want to find standard variables to use


I see what you are suggesting. So it’s really being “monitored” by a scene.

Thanks for the reference I’d not seen it before (or forgot).