Author Topic: optimal (most stable) method to handle a "heartbeat" from a sensor  (Read 172 times)

Offline JohnRob

  • Full Member
  • ***
  • Posts: 227
  • Karma: +11/-4
Hi,

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:

  • 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.
  • 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.

Thanks,

John


Offline therealdb

  • Sr. Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
  • Automate all the things!
Re: optimal (most stable) method to handle a "heartbeat" from a sensor
« Reply #1 on: April 14, 2018, 05:50:56 pm »
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.
Vera, dozen of ZWave devices, Raspberry PI running my own integrations, 3 Nest, Harmony Hub, Personal Weather Station and a lot of code

Offline JohnRob

  • Full Member
  • ***
  • Posts: 227
  • Karma: +11/-4
Re: optimal (most stable) method to handle a "heartbeat" from a sensor
« Reply #2 on: April 14, 2018, 06:11:56 pm »
thanks, but how do you know the sensor is still "alive" and functioning in between trips?

Offline therealdb

  • Sr. Newbie
  • *
  • Posts: 45
  • Karma: +0/-0
  • Automate all the things!
Re: optimal (most stable) method to handle a "heartbeat" from a sensor
« Reply #3 on: April 15, 2018, 01:54:25 am »
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
http://wiki.micasaverde.com/index.php/Luup_UPnP_Variables_and_Actions
Vera, dozen of ZWave devices, Raspberry PI running my own integrations, 3 Nest, Harmony Hub, Personal Weather Station and a lot of code

Offline JohnRob

  • Full Member
  • ***
  • Posts: 227
  • Karma: +11/-4
Re: optimal (most stable) method to handle a "heartbeat" from a sensor
« Reply #4 on: April 15, 2018, 08:14:08 pm »
@therealdb,

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).