[SOLVED] MQTT Broker correct initialization

i tried to add a mqtt broker to openhab2.4 since it was changed recently.

Here is my topic which I want to subscribe to

qos : 0, retain : false, cmd : publish, dup : false, topic : weather/outTemp_C, messageId : , length : 33

Here is my approache but it is not working at all

Bridge mqtt:broker:mosquitto [ host="*******", secure=false ]
    Thing topic weather {
        Type number : outTemp_C "outTemp_C" [ stateTopic="weather/outTemp_C", commandTopic="weather/outTemp_C" ]

the broker itself is connected only the display of the value is not working

Is the broker thing online?
Is the weather thing online?
Your thing syntax doesn’t match mine:

Bridge mqtt:broker:mosquitto [ host="*******", secure=false ]
    Thing mqtt:topic:weather "weather" {
        Type number : outTemp_C "outTemp_C" [ stateTopic="weather/outTemp_C", commandTopic="weather/outTemp_C" ]

Next question, why do you need an outgoing command topic on a temperature sensor?

the paper ui display the broker thing is online

MQTT Broker
MQTT Broker

A connection to a MQTT broker

Status: ONLINE

the weather thing is not online

Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: No MQTT client

No i don’t need to have a outgoing command topic I thought this is the syntax haven’t found an example.

This syntax is not valid anymore. Was an error in the blog post and documentation.

If you would have used the forum search, you would have found that this is a known bug with the OH 2.4 release and got fixed just the same day as the release already.

To avoid this look into:

–>MQTT Generic Thing: java.lang.Exception: No MQTT client


Bridge mqtt:broker:mosquitto "MQTT Broker: Mosquitto" [ host="smarthome.fritz.box", port=1883, secure="false"]
Thing mqtt:topic:outTemp_C (mqtt:broker:mosquitto) {
Type number : outTemp_C "outTemp_C" [ stateTopic="weather/outTemp_C"]

I updated to openhab2.4 today.
Before that I had openhab2.3 on my Synology.

I used the old version of mqtt binding.

In this version, the mqtt broker was configured using the .cfg file.

Define your MQTT broker connections here for use in the MQTT Binding or MQTT
Persistence bundles. Replace <broker> with an ID you choose.
URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

My items were then configured like this.

Switch Kinderzimmer “Kinderzimmer Licht” [ “Lighting” ] {mqtt=">[broker:shellies/shelly1-XXXXX/relay/0/command:command:*:MAP(shelliesonoff.map)],<[broker:shellies/shelly1-XXXXX/relay/0:state:MAP(shelliesonoff.map)]"}

It all worked out fine, too.
Now since openhab2.4 and the new mqtt binding there is no .cfg file anymore.

For the new Mqtt binding I created a Thing for testing. It looks like this. In PaperUI it is also shown as connected.

mqtt:broker:unsecureBroker [ host=“192.168.xxx.xxx”, secure=false ]

What is not clear to me now is what my items must look like, that everything works again.
Can someone help me?

Start here and then do a search on the forum and you’ll find plenty of examples.

If your still having issues then post both things and items someone will be glad to help.

It would be easiest if there were an example of a Shelly1 in the new version. I tried it like this. But it doesn’t work.
My items from the old version can be seen in the post before. If I understand that correctly, does the new version work without items?

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.XXX.XXX", secure=false ]
    Thing mqtt:topic:mything {
        Type switch : lamp "Kitchen Lamp" [ stateTopic="ON/OFF", commandTopic="shellies/shelly1-XXXXX/relay/0/command" ]

Please consider to bring you up to speed on the openHAB 2 concepts which are Things / Channels / Items (in contrast to openHAB 1 which only had items).

You still need items, but they have no configuration anymore, only one(!) for the linked channel. As @H102 wrote, there are many examples by now in the forum.

Cheers, David

1 Like

I have found the solution here.