Wee,
it finally works. Thank you everyone - I have spent way too many hours on this.
Hopefully my little summary will help others to more out of openhab2. Its very cool when it works :slight_smile
-
install mosquitto incl. mosquitto tools (e.g. apt-get install mosquitto_tools)
Configured mosquitto according to the 1.x tutorial. -
Created an MQTT test sender
#! /bin/bash
while true; do
echo "SWTest ON"
mosquitto_pub -t 'SWTest' -m "ON" -d
sleep 5
echo "SWTest OFF"
mosquitto_pub -t 'SWTest' -m "OFF" -d
sleep 5
done
- Verified that MQTT is received from a local client
mosquitto_sub -v -t 'SWTest' -d
(Please note that MQTT topics are case sensitive)
— if you don’t see the data from (2) here STOP. do not continue
- Installed the MQTT 2.x Binding via Paper-UI
a) Things > MQTT > MQTT Broker
b) Things > MQTT > ADD MANUALLY > Generic MQTT Thing
Add Switch
c) Link a new Switch into the MQTT Switch
In pictures MQTT Things:
Please note that the “IS COMMAND” had to be set (didn’t work for me without)
MQTT Thing linked to Switch
- Verify that (2) is able to update switch, relevant logs may be /var/log/openhab2/events.log
2018-12-07 14:45:31.732 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command OFF
2018-12-07 14:45:31.734 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become OFF
2018-12-07 14:45:31.735 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from ON to OFF
2018-12-07 14:45:35.505 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command ON
2018-12-07 14:45:35.506 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become ON
2018-12-07 14:45:35.507 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from OFF to ON
2018-12-07 14:45:39.277 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command OFF
2018-12-07 14:45:39.278 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become OFF
2018-12-07 14:45:39.279 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from ON to OFF