MQTT Setup

The docs for OH2 seem to be very light. I searched for the prescribed install method and the only this I found is this post:

So I copied the org.openhab.binding.mqtt-1.8.3.jar and org.openhab.io.transport.mqtt_1.8.3.jar from a 1.8.3 distro.

When OH2 starts up I see the following errors in the log:

Could not resolve module: org.openhab.io.transport.mqtt [189] Unresolved requirement: Import-Package: org.openhab.core.events

Could not resolve module: org.openhab.binding.mqtt [188] Unresolved requirement: Import-Package: org.openhab.core.binding

What is the actual correct way to install the MQTT support??

So I just found that it is required to do “feature:install openhab-runtime-compat1x”.

I suggest that this be done by default since using 1.x binding is a requirement.

When I started with OH2 a month ago, I just installed the binding through the PaperUI interface.
Nothing else was required (besides the configuration file of course), and all my mosquitto traffic works perfectly.

This may sound dumb, but I did as you did, nekmech: I installed the MQTT binding through the Paper UI. It seemed to go well, but I can’t find a way to configure things through the Paper UI. The Astro binding worked out of the box, as did the Tesla binding (not that I have one yet haha), but the MQTT binding doesn’t show up on the binding configuration page.

configure conf/services/mqtt.cfg with your broker:

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
openhab.url=tcp://localhost:1883

Then just set up your items (for example in conf/items/your_items_file.items):

String          mqtt_light_status       "mqtt message [%s]"     {mqtt="<[openhab:lumencache/status:state:REGEX(light\\:(.+))]"}

There is no further configuration required in PaperUI

1 Like

Indeed, my instructions are not needed anymore, as by now there Is the easier route via paperui.(If everything fails, you may use it as fallback)

Suggest to switch on logging in karaf, than you can see what happens when mqtt binding and transport are being installed. … and you need the cfg file as described above.

You are best to install the 1.9.0 snapshot via the Paper UI and you will need to delete the earlier versions from the addons directory. I would do this first and then restart OH2 prior to adding the 1.9.0 binding via the Paper UI.

After that follow @nekmech 's instruction above and then create your items in an item file.

Thanks everyone. Using the PaperUI does in fact work as expected. So I now have MQTT data flowing!