Platform information: RPi3
- openHAB version: Latest as of openhabianpi 03-18-2019
Issue: I’m trying to get a working MQTT setup using the new 2.x binding.
I have Mosquito installed and can connect to the broker using MQTT.fx and when I publish a topic I receive it when subscribed to all. I think my problem is with things. I haven’t worked with things much since everything I’ve needed openhab to do used 1.x bindings for the most part.
So my question is what advantages are their to using the 2.x MQTT binding verses the 1.x?
Should I have a MQTT.cfg file for the 2.x binding?
And after installing the Binding and adding the MQTT Broker Configuration to be the loopback address do I need to setup Channels for the Broker?
I added my MQTT publisher devices as things do I need to setup channels for the ESP things?
So many questions so few guides for this.
Thanks for any information you can provide.
Advantages / Disadvantages…
Well, at least mqtt2 is the more recent version, it’s the version that will be maintained.
In contrast to other bindings, one can use mqtt1 and mqtt2 at the same time, so it’s possible to move mqtt1 step by step to mqtt2 in a productive system
The configuration through Things is the more recent approach.
There may be some downers, e.g. you can’t set more than one topic to a channel, but that is only a little
problem as it’s easy to link more than one channel to an Item so no problem at all.
There is no configuration file like
mqtt.cfg, because, if configuring through text files, the hardware part is stored in a
mqtt.things file (of course you could use any other name, as long as the file extension is
You don’t need to setup channels for the broker.
You will need at least one Thing as child of the mqtt broker bridge.
This Thing needs one channel per received or transmitted topic. Of course you could use one channel to send and receive a pair of topics such as a switch + its status.
Thanks for the super fast response and the information.
So I have a ESP8266 publishing it’s name ESP_000/Relay/State:1
In OH2 I need a Generic MQTT Thing Configured with 1 Channel that looks like this correct?
I know the state is published because I can see it in MQTT.fx but it’s not changing the state of the OH2 switch.
Seems ok to me.
Did you setup the correct broker to the Thing?
Is the Broker online?
Is the Thing online?
I figured it out. I hadn’t selected the item to link to the Channel.
I figured that was set by creating a MQTT Thing with the same name as the item.
Thanks again for helping me get my first device working with MQTT 2.x binding.
The MQTT 2 binding will continue to be maintained and receive new features. MQTT 1 will become deprecated at some point I’ve little doubt.
This is more opinion, but the MQTT 2 approach is more OH 2 like in how it works.
MQTT 2 can be configured and managed wholly within PaperUI.
MQTT 2 supports chaining transformations (the first binding to support this as far as I’m aware).
MQTT 2 comes with an Action to publish to arbitrary topics within Rules, MQTT 1 Action needs to be installed separately.
There is a slight caveat to this. You can have different subscribe and publish topics on a single Thing. But you cannot have more than one subscribe or more than one publish topic. And indeed, linking multiple channels to the same Item and using profiles gives you pretty much all the flexibility of defining multiple mqtt binding configs on one Item.
Once again you’re very helpful.
Thanks for the links to the guides. I was trying to follow the MQTT 2.x Binding Documentation and should have just started with looking on here. I think the documentation would serve us non programmers better if it had a link to @Sascha_Billian Migrating MQTT1 intems to MQTT2.4 items