logo elektroda
logo elektroda
X
logo elektroda

How to Enable MQTT LWT in OpenBeken for Device Status Monitoring?

rohanb 345 3
ADVERTISEMENT
  • #1 21434395
    rohanb
    Level 2  
    Hi can you enable MQTT last will and testament in openbeken .

    I can see it was talked about once but in my use case i need it for device status.

    The tasmota notes are

    LWT Topic (Last Will and Testament)~
    On connection to the MQTT broker tasmota uses the Last Will and Testament (LWT) feature that instructs the broker to generate a notification about an ungraceful disconnect or timeout.

    The topic to listen to for the state of this specific client is tele/<TOPIC>/LWT that with the mosquitto MQTT broker produces an output like:

    $ mosquitto_sub -t "tele/tasmota_XXXXXX/LWT"
    Offline
    Online
    The full LWT topic can be found in the tasmota console at boot:

    15:51:51.281 MQT: tele/tasmota_XXXXXX/LWT = Online (retained)

    if this is followed that would be ideal but anyway you can produce it would be good.

    Thanks for all your great work
    AI: Could you please specify the version of OpenBeken you are using?
    version 1.18.37
    AI: What device or system is OpenBeken running on? This will help in providing more specific guidance.
    multiple
  • ADVERTISEMENT
  • #2 21436873
    rohanb
    Level 2  
    Hi so I have partly answered my own question after I went through the MQTT code i found that {root_topic}/connected gets updated with "offline" in the last will and "online" on client connect
    but it never seems to get refreshed ??
    I have added
    addRepeatingEvent 60 -1 publish "{root_topic}/connected" "online" -1
    to autoexec.bat to fix this but it seems the keep alive value for mqtt is very high as upon disconnect it takes over 2 minutes to move to offline.
    @p.kaczmarek2 Is there a way to reduce this or a way to set it from user config.

    Thanks again.
  • ADVERTISEMENT
  • #3 21437191
    p.kaczmarek2
    Moderator Smart Home
    Where is this value transferred? I can try adding such option if it's required.

    So "connected" should be sent periodically?
    Helpful post? Buy me a coffee.
  • #4 21437248
    rohanb
    Level 2  
    So espurna sends the last_will status periodically with its other heartbeat messages every X (set by the user) seconds, Tasmota only sends online and offline once
    Tasmota also sends offline as soon as you reboot a unit (which overrides the last_will setting)

     @pkaczmarek2  I think all that you need to change is just send an offline as a unit reboots and maybe reduce MQTT keep_alive on the connection this will fix the issue of potentially the unit is offline but MQTT is not aware of that yet, Then and if people want the online flag sending more often they can do what I have done in autoexec.bat .

    Thanks Again
ADVERTISEMENT