Another post targeted at beginning users (like me)…
Mosquitto (MQTT) set up in new version (openHAB 2.5.0-1 Release Build) using Sonoff devices with simple switches (Tasmota firmware added)
I found that Mosquitto was the most stable approach for implementing MQTT. I use openhabian on a raspberry pi 3, and I selected mosquitto using openhabian-config. In Paper UI:
- Added MQTT Binding (binding-mqtt - 2.5.0)
- Manually created a MQTT Broker Thing, and completed the configuration parameters.
- Verified Mosquitto service is running by executing on the command line:
sudo systemctl status mosquitto
- A Sonoff device configuration will be used as an example. Entered the IP address of the Sonoff into a browser, selected “Configure MQTT” then set MQTT parameters: Host (IP address of MQTT broker), Port (1883), Client (needs to be unique name, like livingroomlamp), User (openhabian), Password (your MQTT broker password), topic (meaningful name, like floorlamp)
- Manually created a Generic MQTT Thing in Paper UI for the Sonoff. In edit mode, labeled it, such as Living Room Floor Lamp, and selected the mqtt broker bridge.
- In the generic MQTT Thing, added a channel with a channel type of “On/Off Switch”
- Edited the channel (Configure Channel), adding MQTT State Topic “stat/floorlamp/POWER” and MQTT Command Topic “cmnd/floorlamp/POWER”.
- Under the On/Off Switch Channel, added a new linked item with a Switch type (named FloorLampLivingRoom)
- FloorLampLivingRoom is then added to HABPanel and operates the Sonoff switch, and rules can be used as with any other switch.