Welcome to OH. Having just deployed mqtt yesterday, I’ll try to help (though I’m still learning). To get a basic deployment started you need to install the Matt binding (don’t install the actions binding) and edit the mqtt.cfg file in your conf/services directory to point OH at your mqtt broker.
Then you can start defining items as per the binding page or just sync your OH event bus (basic config below) to have all OH commands/state changes go to mqtt and subscribe to any commands/state changes you want to retrieve from Matt (though you will need OH items ready to receive those commands/state changes.
22:26:03.540 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/SonOff’ for the unknown item ‘SonOff’.
22:26:03.816 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/SonOff’ for the unknown item ‘SonOff’.
22:26:04.064 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/SonOff’ for the unknown item ‘SonOff’.
22:26:04.321 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/SonOff’ for the unknown item ‘SonOff’.
22:26:04.573 [INFO ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at ‘items/SonOff’ for the unknown item ‘SonOff’.
I believe hyphens in names have a special significance within openhab UI’s - they are used to select icons e.g. light-on, light-off etc.
For that reason you should avoid hyphens in Item names.
Use an underscore if you wish
My understanding (I’m just coming up the learning curve myself) is that you’ll want to configure an incoming subscribe for your item using the ‘<’ in your item definition.
Hey all. Sorry to pick this thread up with the same problem: I just can´t get openhab2 on my old Raspi B to cause any effect on the mqtt topic. Using Putty Mosquitto works just fine, so does MQTT.fx.
I did a fresh install of openhab, installed the MQTT binding from the binding menu inside Paper UI.
Here is the contents of my mqtt.cfg:
mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab
mosquitto.retain=true
mosquitto.async=false
And eventbus
broker=mosquitto
statePublishTopic=/openhab/out/${item}/command
commandPublishTopic=/openhab/out/${item}/command
stateSubscribeTopic=/openhab/in/${item}/state
commandSubscribeTopic=/openhab/in/${item}/command
I tried to have a switch on a demo.sitemap
sitemap default label=“My first sitemap”
{
Switch item=myswitch label=“Light”
}
the switch is: myswitch.item
Swtich myswitch {mqtt=">[mosquitto:/test/hello:command:ON:1],>[mosquitto:/test/hello:command:OFF:0]"}
Bear with me. I had to figure out what it actually means when someone write “We just create a switch item”. I have little to no knowledge about what I´m acutally doing
your openhab.log should be giving you an error about the misspelled Swtich
If this was a copy/paste error… check the contents of /var/lib/openhab2/config/org/openhab/mqtt.config
Ps: You don’t really need the mqtt-eventbus integration. You could comment out all the settings there.
Yep. Meanwhile I´ve found this typo too and changed around the variables. But I still have a problem while looking at the openhab log. Can´t get my head around this simple syntax. The log states:
Cannot retrieve item ‘cmd1’ for widget org.eclipse.smarthome.model.sitemap.Switch
Here is the items file:
Switch cmd1 {mqtt=">[mosquitto:/test/hello:command:ON:1],>[mosquitto:/test/hello:command:OFF:0]"}
and the sitemap:
sitemap test label=“test sitemap”
{
Frame label=“Stuff”{
Switch item=cmd1 label=“LightSW”
}
When I try to use the swtich that shows up in the Basic UI, the log says:
Received HTTP POST request at ‘items/cmd1’ for the unknown item ‘cmd1’
I think mqtt binding is actually working, but there is something wrong in my syntax that is just very simple. I´ve read through a lot of examples and pages, but can´t figure it out.