openHAB does not publish to a topic

Hi,
I have a problem with publishing messages, I managed to start openHAB finally and I see that it publishes messages to the broker when I run “mosquitto_sub -h 192.168.0.102 -p 1883 -t #” whenever I press a button in openHAB the message shows, but when i subscribe to a topic “inTopic/LED” nothing happens. My item file:
“Group All
Switch mqttsw1 “Switch 1” (all) {mqtt=”>
[broker:/inTopic/LED:command:off:OFF],>
[broker:/inTopic/LED:command:on:ON]"}"

My openhab.cfg only contains those 2 lines, maybe this is the issue?
“mqtt:broker.url=tcp://192.168.0.102:1883
mqtt:broker.clientId=openhab”

My sitemap file, for the reference:
“sitemap demo label=“Main Menu”
{
Frame label=“MQTT” {
Switch item=mqttsw1 label=“MQTT Switch 1”
Switch item=mqttsw2 label=“MQTT Switch 2”
}”

Can someone tell me where is it publishing and how to change it?

Thanks.

Are your outbound command item bindings formatted correctly – should they be off:OFF or instead OFF:off? Also, try the mosquitto_sub with the leading / character in the topic to see if it makes a difference.

Hi, You nailed it in the first try :slight_smile: The issue was with the leading “/”. Every item example I checked had the leading “/” in topic, so I assumed this is how the application reads the topic, with the starting [:/i, so I didn’t even think about it, I guess I would have eventually figured it out one day, but you saved me a lot of time and frustration. Thanks a lot for your help.

1 Like