Mysensors - Keep alive / LWT (last will, testament)?


  • Hardware Contributor

    Hi,

    i am evaluating mysensors and it's quite interesting and easy to understand! Just, what i was looking for!:) But i am missing a feature, which enables the gateway/controller to detect node-failures. At the moment i have a mqtt-client-gateway running very nicely. But i dont know how to configure /implement a feature, that i get a mail/info/note (red LED blink) when a node dies, goes "offline" or does not send sensor-values any more.
    In mqtt this is called LWT (last will, testament). Is there something comparable in mysensors?
    Any ideas howto get this?

    Sry for my english, i am native german 😉

    greetings

    Andreas


  • Mod

    @ahhk you could have the sensor send a value update at regular, known intervals. Track the arrival of these updated values from some client that subscribes to the mqtt topics. When no new value arrives within a certain time (e.g. 3 times the sensor update interval) you can consider the sensor to be off-line. When a new value does come in again from an offline sensor, the sensor is online again.
    This logic can easily be accomplished by e.g. node-red.


  • Admin

    Added a dedicated heartbeat message in the development branch a while ago. But you must actively send it from your node. So any "smart" gateway/controller implementation (with LWT functionality) should take normal messages into account also... as sending heartbeats should really only be needed when node doesn't have anything "real" to transmit.

    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MySensor.h#L226


  • Hardware Contributor

    Hi,

    sending a "heartbeat" or other value regularly is not a problem. The processing of this on gateway/controller-side is missing. I hoped to find a feature like:

    • Node presents sensor to controller/gateway WITH time-intervall-value
    • The controller /gateway sends alert-message if node doesnt send for >presented time-intervall-value...
      (-perhaps a manual "offline-switch"-function to disable alarm/node/sensor)

    This would be really great...does anybody know if something like this is on the roadmap for mysensors?

    I will take a look into scripting (mqtt+python?) to realise my alert-function...
    Greetings

    Andreas


  • Admin

    The gateway is stateless today and there is good reasons for keeping it that way.

    So it is really up to the controller plugin developer (or in your case using some scripting) to implement a "offline" feature when sensor hasn't reported any values in due time. What is a valid interval should probably be configurable per node.



  • Although i like the idea, it will force you to send a value even if it has not changed. Defeats a bit a battery optimized sensor node.



Suggested Topics

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts