MQTT Online Status

logo

Force a refresh

A simple rule to publish a retained message “ONLINE” to a configured topic when the MQTT Broker Thing changes to ONLINE. The topic is expected to be the same topic configured in the MQTT Broker Thing as the LWT message. The Broker Thing should also be configured to publish the “OFFLINE” message as retained so all clients will know the status of openHAB at all times whether or not they were subscribed to the topic when OH actually went online/offline.

The rule has two parameters:

Parameter Purpose
MQTT Broker Thing Select the MQTT Broker Thing with an LWT configured.
LWT Topic The full LWT topic configured in the MQTT Broker Thing

Language: Nashorn JavaScript

Dependencies:

  • MQTT binding installed
  • MQTT Broker Thing created and configured
  • LWT configured on the MQTT Broker Thing
  • LWT message configured to be sent as retained on the MQTT Broker Thing

Changelog

Version 0.1

  • initial release

Resources

https://raw.githubusercontent.com/rkoshak/openhab-rules-tools/main/mqtt_eb/template/mqtt_status.yaml