Openhab 3 Send simple mqtt message

Hi,

I just installed openhab 3 and wondered why my items with mqtt channels don’t work anymore. In Openhab 2 with the MQTT Binding (1.X) openhab sent the values of my items to the respectively topic linked in the .items file - now nothing happens. I didn’t define any .thing files - is this necessary now ? The Binding MQTT Binding 3.0.0 is installed. Mqtt works from the shell with the commands: mosquito_pub / _sub, …
Seems I didn’t link mosquitto and openhab correctly.

.items:

Number light_5 "Sitzecke" <light> { mqtt=">[mosquitto:sitzecke:state:*:default]" }

Thanks !

Raspberry Pi 4, Raspbian, manual installation

It’s because you did not install MQTT binding version 1. You can’t, because it’s not supported in OH3.

Yes. (or defining via UI, but yes you must use Things and channels)
The actual binding is version 2, running under OH3.
You’ll find lots of threads in this forum offering help with MQTT v1 to v2 conversion.

Yes. V1 bindings don’t work in openHAB 3.

The compatibility layer is gone, so 1.x add-ons will no longer work. If you rely on them and there isn’t a new add-on in openHAB 3 for it (yet), you can make use of the new remote openHAB binding, which allows to keep an old openHAB 2 instance running with the required add-ons and include it into an openHAB 3 setup.

This link might help to convert, or you can use the UI.

Thanks for the advice. To me the “new” MQTT workflow seems to be more complicated and longer than before, as items and things are now required even though they contain (some) the same information, which is not logical for me. What is the benefit of that ?
Do I have to define both x things and x items, when I want to control x lamps, e.g. ?

That’s probably recommended. Note that Things contain Channels which are the link to a physical property of your device, such as a relay switch, or a temperature. It’s these Channels which are linked to your Items. So, technically, you could have one Thing, and have a separate Channel for each device, which links to an Item each. But it’s cleaner to create a separate Thing (with Channel(s)) for each device.

For more information, have a look at the general concepts documentation.

Is there a possibility to downgrade from Openhab3 to Openhab 2.x ? For me, the structure of the MQTT Binding 1.x is simpler and I don’t want to spend time in the migration.