Note, in OH 4+, the MQTT Broker Thing supports publishing a “Birth” message which takes the place of this rule template.
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:
|MQTT Broker Thing||Select the MQTT Broker Thing with an LWT configured.|
|LWT Topic||The full LWT topic configured in the MQTT Broker Thing|
- 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
- In OH 4 the Nashorn add-on must be separately installed or change the script type to
- adjusted for breaking change, will no longer work for versions of OH prior to December 15th
- Made compatible with both Nashorn and JSScripting
NOTE: Will remove support for Nashorn sometime after OH 3.2 release.
- initial release