Heartbeat signal


  • Hero Member

    Hi all,

    I have a few sensors such as my lightning sensor that may not transmit actual sensor data for a long time. In case the sensor were to lock up, or have some other issue, I'd like my HA system to notify me. For the lightning sensor, I've added a heartbeat signal that sends a V_TRIPPED value once an hour and it alternates sending a 1 and a 0 and I've programmed my HA system to alert me if that value has not changed for a few hours. I'm just wondering if there's a more elegant way or what others have done. Ideas?

    Thanks
    Al


  • Admin

    I'm just sending the last state of the port and light, in my garage port opener, once every 60 minutes. In domoticz I can see when a sensor is seen the last time.. And this way I can check that it's alive.

    I admit, I have to look at it manually, no automation in warnings etc.

    /


  • Hardware Contributor

    I think the heartbeat is a reasonable way to do it. I'm designing my system to use an MQTT broker and I'm going to write a small client that listens to all the sensor messages as they come in. If no message is seen from a sensor in some elapsed time, the client will send out a "sensor down" message which can then be acted on.


  • Contest Winner

    @Sparkman

    How about a Sensor Sensor?

    From the Sensor Sensor send a message to each node that you need to check communication and wait for a bounceback.

    You could use a motion sensor to indicate probem, and show the trouble node in a V_VAR ...

    something to try


  • Hardware Contributor

    On my batterysensors i send batterlevel every 60min (4th sleep cycle) as a heartbeat.
    Probably a stupid question, but how do I code it in a node without sleep? It doesnt have a clock 🙂

    @tbowmo You probably knows, but using lua script you can let domoticz send you a notification (i really recommend notifymyandroid).
    Something like: (untested).

    -- script_time_garageport.lua
    -- Sends a warning if the garagedoor has been unseen more than 60 minutes.
    t1 = os.time()
    s = otherdevices_lastupdate['Garageport']
    -- returns a date time like 2013-07-11 17:23:12
     
    year = string.sub(s, 1, 4)
    month = string.sub(s, 6, 7)
    day = string.sub(s, 9, 10)
    hour = string.sub(s, 12, 13)
    minutes = string.sub(s, 15, 16)
    seconds = string.sub(s, 18, 19)
     
    commandArray = {}
     
    t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
    difference = (os.difftime (t1, t2))
    if (difference > 3600 and difference < 3900) then
       commandArray['SendNotification']='Garage door alert#The garage door has been stolen??'
    end 
     
    return commandArray
    
    

  • Admin

    @sundberg84

    Currently domoticz sends a private tweet to me, if it has any notifications, I chose twitter, as I don't have to pay for any license keys to use that.
    I just haven't come around to enable notifications, if sensors doesn't check in at a regular interval.

    If you want to ping your controller in a node that never sleeps, you could always use millis():

    unsigned long lastHeartbeat = 0;
    #define HEARTBEAT_INTERVAL 3600000
    
    void loop() {
      if (millis() - lastHeartbeat > HEARTBEAT_INTERVAL) {
          ... PING ....
          lastHeartbeat = millis();
      }
    }
    

    This will send a ping every 3600 seconds (once a hour). The first heartbeat will be 1 hour after startup.


  • Hero Member

    @tbowmo @TD22057 @BulldogLowell @sundberg84

    Thanks for the replies everyone. The HS3 MySensors plugin will only update the "last change time/date" if the value sent by the sensor actually changes, so I need to make sure what I send is different than before which is why I alternate 0's and 1's. I would like a common solution for both mains and battery powered devices, and therefore polling sensors won't work for sleeping battery powered sensors. Using the V_TRIPPED sensor type is a bit of a kludge, but seems to be working ok. Maybe a V_HEARTBEAT sensor type should be added to the protocol. @hek, any thoughts?

    Cheers
    Al


  • Admin

    Hmm. if this is something the community would find useful we could add it as an INTERNAL variable type (which reports it on the node-device). And API something like:

    gw.sendHeartbeat(<optional destination node (defaults to gateway/controlle)r>)

    Sends an incremental integer payload.


  • Hero Member

    @hek That sounds great to me!

    Thanks
    Al


  • Admin


  • Hero Member

    @hek Thanks!


Log in to reply
 

Suggested Topics

  • 1
  • 10
  • 6
  • 1
  • 1
  • 2

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts