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 .things)
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.
Hi @Udo_Hartmann
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 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.
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.
Hi @rlkoshak
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_BillianMigrating MQTT1 intems to MQTT2.4 items