Pi + MQTT + openhab2 + ESP8266 WeMos d1 mini + HOMIE Framework ALMOST THERE!

I got the pi3 running openhab2 with mosquitto.
After reading a lot, i finally manage to control the LED on my Wemos d1mini and NodeMCU boards from the Pi via MQTT over WiFi

Im runnig HOMIE framework on the nodes.

So far, if I type in pi console:

mosquitto_pub -t 'devices/home/light/on/set' -m true

The LED turn on

mosquitto_pub -t 'devices/home/light/on/set' -m false

The LED turn off

so far so good! :smiley:

Now im trying to put a switch on openhab2
Here is my config:

mqtt.cfg

mqtt:mosquitto.url=tcp://localhost:1883
mqtt:mosquitto.clientId=openhab

mqtt-eventbus.cfg

broker=mosquitto

demo.sitemap

sitemap demo label="Main Menu" {
    Switch icon="present" label="lamp1" item=lamp1
    Switch icon="present" label="lamp2" item=lamp2
    Switch icon="present" label="lamp3" item=lamp3
    Switch icon="present" label="lamp4" item=lamp4
}

demo.item

Switch lamp1 { mqtt=">[mosquitto:devices/home/light/on/set:command:on:true],>[mosquitto:devices/home/light/on/set:command:off:false]"}
Switch lamp2 { mqtt=">[mosquitto:devices/home/light/on/set:command:on:1],>[mosquitto:devices/home/light/on/set:command:off:0]"}
Switch lamp3 { mqtt=">[openhab:devices/home/light/on/set:command:on:true],>[openhab:devices/home/light/on/set:command:off:false]"}
Switch lamp4 { mqtt=">[openhab:devices/home/light/on/set:command:on:1],>[openhab:devices/home/light/on/set:command:off:0]"}

None of the combinations above worked so far. The requests won’t go to the nodes. Appreciate any advices. Need help for better debug this.

Thank you!

Since you are using OH2 (which version?)… I believe that the colons should be removed (take out mqtt: in the begging of the lines in mqtt.cfg)

Maybe you used an openHAB 1 guide to configure your system. In OH2, you don’t need that part in your config since the MQTT binding uses it’s own config file (not the openhab.cfg).
The /etc/openhab2/services/mqtt.cfg should look like:

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab

Check if OH2 delivers the messages (when you press the switch on your sitemap) to the MQTT broker by subscribing to the the respective topic from the pi3 shell.

mosquitto_sub -t devices/home/light/on/set

If the topic is not updated, check the logs for any errors and post an update :slight_smile: