Helpful tip when bringing up MQTT binding

Here’s something I did to get confidence that I had the MQTT binding configured correctly with a Mosquitto broker.

I created an item:

String MQTT_Uptime "MQTT Uptime [%s]" {mqtt="<[local:$SYS/broker/uptime:state:default]"}

You’ll need to change “local” to whatever broker id you used in your “mqtt.cfg” file.

This produces a message in the “events.log” every 11 seconds (for my Mosquitto setup) showing that the binding is working.

2018-01-05 22:46:38.210 [vent.ItemStateChangedEvent] - MQTT_Uptime changed from 269260 seconds to 269271 seconds
2018-01-05 22:46:49.131 [vent.ItemStateChangedEvent] - MQTT_Uptime changed from 269271 seconds to 269282 seconds
2018-01-05 22:47:00.165 [vent.ItemStateChangedEvent] - MQTT_Uptime changed from 269282 seconds to 269293 seconds
1 Like