Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Heartbeat signal

Heartbeat signal

Scheduled Pinned Locked Moved Development
11 Posts 6 Posters 7.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SparkmanS Offline
    SparkmanS Offline
    Sparkman
    Hero Member
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • tbowmoT Offline
      tbowmoT Offline
      tbowmo
      Admin
      wrote on last edited by
      #2

      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.

      /

      SparkmanS 1 Reply Last reply
      0
      • TD22057T Offline
        TD22057T Offline
        TD22057
        Hardware Contributor
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          0
          • sundberg84S Offline
            sundberg84S Offline
            sundberg84
            Hardware Contributor
            wrote on last edited by
            #5

            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
            
            

            Controller: Proxmox VM - Home Assistant
            MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
            MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
            RFLink GW - Arduino Mega + RFLink Shield, 433mhz

            1 Reply Last reply
            0
            • tbowmoT Offline
              tbowmoT Offline
              tbowmo
              Admin
              wrote on last edited by tbowmo
              #6

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

              1 Reply Last reply
              1
              • tbowmoT tbowmo

                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.

                /

                SparkmanS Offline
                SparkmanS Offline
                Sparkman
                Hero Member
                wrote on last edited by Sparkman
                #7

                @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

                1 Reply Last reply
                0
                • hekH Offline
                  hekH Offline
                  hek
                  Admin
                  wrote on last edited by
                  #8

                  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.

                  SparkmanS 1 Reply Last reply
                  0
                  • hekH hek

                    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.

                    SparkmanS Offline
                    SparkmanS Offline
                    Sparkman
                    Hero Member
                    wrote on last edited by
                    #9

                    @hek That sounds great to me!

                    Thanks
                    Al

                    1 Reply Last reply
                    0
                    • hekH Offline
                      hekH Offline
                      hek
                      Admin
                      wrote on last edited by
                      #10

                      I skipped the destination argument...

                      https://github.com/mysensors/Arduino/commit/2343d8ae8fb72bdcab467b158eb77c09af6fda5d

                      SparkmanS 1 Reply Last reply
                      0
                      • hekH hek

                        I skipped the destination argument...

                        https://github.com/mysensors/Arduino/commit/2343d8ae8fb72bdcab467b158eb77c09af6fda5d

                        SparkmanS Offline
                        SparkmanS Offline
                        Sparkman
                        Hero Member
                        wrote on last edited by
                        #11

                        @hek Thanks!

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        17

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.1k

                        Posts


                        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular