Mosquitto (MQTT) set up in new version (openHAB 2.5.0-1 Release Build)

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:

  1. Added MQTT Binding (binding-mqtt - 2.5.0)
  2. Manually created a MQTT Broker Thing, and completed the configuration parameters.
  3. Verified Mosquitto service is running by executing on the command line:
    sudo systemctl status mosquitto
  4. 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)
  5. 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.
  6. In the generic MQTT Thing, added a channel with a channel type of “On/Off Switch”
  7. Edited the channel (Configure Channel), adding MQTT State Topic “stat/floorlamp/POWER” and MQTT Command Topic “cmnd/floorlamp/POWER”.
  8. Under the On/Off Switch Channel, added a new linked item with a Switch type (named FloorLampLivingRoom)
  9. FloorLampLivingRoom is then added to HABPanel and operates the Sonoff switch, and rules can be used as with any other switch.
2 Likes

You do not need to enable Is Command if there are no other channels linked to the item
Is Command will pass the value received on the state topic as a command to other linked channels to the same item

1 Like

Thank you. I removed that part from the example.

It is not possible now to declarate the MQTT topics in the items file?

I have updated to 2.5 openhabian, but MQTT does not work.