Hello community. Having problems getting Openhab2, Mosquitto, and my Sonoff basic talking. I’m pretty sure it comes down to my ignorance about how to pub - sub topics. I have a working Mosquitto tested through “Hello World” and a working connection to Openhab tested with Dim’s instructions:
Open a ssh login in one window and subscribe to all topics under openhab:
mosquitto_sub -u openhab -P habopen -t openhab/#
Open another ssh login in another window and publish a message (e.g. ON) to a topic (e.g. command) under openhab:
mosquitto_pub -u openhab -P habopen -t openhab/command -m ON
I even got MQTTlens working after a little learning curve.
However (I hate to admit it), I can’t for the life of me figure out how to publish or subscribe topics. I know some of the following configurations already have topics but, how the heck do I publish or subscribe to them? Is there another file to create? Is it all command line. Everything I’ve found in the last weeks refers to what -v or -p means or what commands to use. Then it says publish or subscribe but nothing about how. I’m sure once I get it I’ll feel even more foolish. But for now I am at a loss. If anyone can give a step by step (possibly using info provided below) I would greatly appreciate it.
mqtt.cfg
mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhabian
//mosquitto.user=openhabian
mosquitto.qos=1
mosquitto.retain=true
mosquitto.async=false
cord.items
Switch cord1 “Cord” {mqtt="<[mosquitto:diana/lights/cord1:state:default], >[mosquitto:diana/lights/cord1:command:ON:1], >[mosquitto:diana/lights/cord1:command:OFF:0]"}
lights.sitemap
sitemap lights label=“diana_lane” {
Frame label=“Date” {
Text item=Date
}
Frame label=“Lights” {
Switch item=cord1 label=“Cord”
}
}
On my Sonoff Basic Module
MQTT parameters
Host (domus1)
openhabianpi
Port (1883)
1883
Client Id (DVES_9702D5)
cord1
User (DVES_USER)
openhabian
Password
•••••••••
Topic = %topic% (sonoff)
lights
Full Topic (%prefix%/%topic%/)
diana/lights/cord/power
( I’m thinking I need to change the full topic of the Sonoff to:
diana/lights/cord1/power