Fresh OH 2.4 and MQTT binding

There are at least 20 threads about this, please use the forum search.
You need to either install the legacy binding or change your config to the new channel definition concept.

Ok, tanks.
I downloaded the " Download openHAB 2.4.0 Stable Legacy Add-ons"

When extracting this there is a MQTT binding v1.13 and I am pretty sure I have had a v2.3.0 binding of this earlier. I suppose this is from OH1, right?

Where can I find that?

Okay, you did not search. Iā€™m happy to do it for you:
Enable Legacy Addons in your PaperUI config and install the mqtt1 binding through PaperUI, then use all your config like before.

I did searchā€¦
But as I said I am pretty sure I used v2.3.x of MQTT binding with OH 2.3 - not legacy 1.x

To me and from past ā€¦legacy is referred to OH1 and not OH2 - am I wrong?

PS. I have used legacy Astro binding v 1.10 in OH2 since before since the functionality was better in that DS.

Mqtt2 binding was introduced with openHAB 2.4

Not quite: as soon as a 2.x binding is available the 1.x becomes legacy.

Thanks for your information.
I have started to configured the MQTT binding via UI (even though I would like text files) and got connection


I only want to publish to MQTT topic when an event is triggered

I have my items configured like:

Switch OfficeWindowPlugSwitch "Plug Office Window" (gGF_Office, Lights) {channel="zwave:device:55bca95a:node5:switch_binary", mqtt=">[rabbitmq:/myhouse/office/command/light2:command:*:Switch ${itemName} was turned ${command}]"}

It doesnā€™t send any events though - what shall correspond to ā€œrabbitmqā€ in my items config?

You need a Broker Thing for that.

ā€¦ and you need channels. Or is that your old mqtt1 config?

Read this post (found through search function :grinning:)

Still trying to get this working with v2.4 MQTT binding.
I have searched, read but donā€™t get it working - I might be stupid :slight_smile:
Currently I only want to publish status changes of items on a topic that belongs to the item.
I want to do the configurations in text files (*.things, *.items etc)

So I have created the MQTT Broker connection in things/mqtt.things:

mqtt:broker:rabbitmq 
    [ host="192.168.1.20", 
      port=1883, 
      qos=1, 
      clientID="openHAB2", 
      reconnectTime=20000, 
      keepAlive=60000, 
      secure=false, 
      username="openhab", 
      password="the-password" 
    ]

It connects fine.

In my legacy MQTT configuration I had the following config on items like the two examples:

To publish that a Z-wave switch was turned ON or OFF:

Switch MySwitch "My Z-Wave Switch" (Office, Lights)
{
    channel="zwave:device:55bca95a:node4:switch_binary", 
    mqtt=">[rabbitmq:/myhouse/office/command/light:command:*:Switch ${itemName} was turned ${command}]"
}

And a sensor reporting temperature changes

Number SensorTheRoomTemp   "Temperature in the room" <temperature> 
{
  channel="mysensors:temperature:gateway:sensor-the-room-temp:temp", 
  mqtt=">[rabbitmq:/myhouse/the-room/sensor/temperature:state:*:Temperature,sensor=${itemName},location=the-room temperature=${state} ]" 
}

How shall I accomplish the same result in config files using v2.4 MQTT binding?

mqtt:broker:rabbitmq 
    [ host="192.168.1.20", 
      port=1883, 
      qos=1, 
      clientID="openHAB2", 
      reconnectTime=20000, 
      keepAlive=60000, 
      secure=false, 
      username="openhab", 
      password="the-password" 
    ]
{
    Thing topic myThing "My Thing" {
        Channels:
            Type switch : mySwitch "My Switch" [
                commandTopic="House/Porch/Thermostat/Mode",
                formatBeforePublish="Item SensorTheRoomTemp changed to %s"
            ]
    }

This should take care of the first one although it will only publish ON and OFF

For the second, the new binding cannot publish on state changes.
If you wish to retain the functionality of the old binding, use the old binding.

1 Like

@4integration i really have to ask you this: you once read and learned how to assemble item file lines to make mqtt 1 work.

So why on earth donā€™t you read the documentation to figure out how to use mqtt2. Mqtt is now using OH2 concepts and yes you are required to know those otherwise you will fail with your migration.

There was a long section on the changelog and even a blog post to introduce mqtt2.

Others: please donā€™t solve user ā€œtasksā€ if they are not even willing to read the changelog and breaking changes on an update.

1 Like

People need help. Iā€™ll move them to another thread if required

1 Like

Thanks a lot @vzorglub for your kindful help and I got it working with a few modifications (needed ā€œBridgeā€ and an ending bracket).

Since I (currently) donā€™t like how the configuration is done with v2.4 MQTT binding I also installed the old binding and they seem to work in parallel and I can eventually migrate later.

Thanks again - you are a role model :slight_smile:

@David_Graeff - please donā€™t be such wiseacre and instead follow the good spirit of people like @vzorglub

@4integration
David was correct,
You should have opened a new thread

OK - but I did open a new/this thread yesterday?!

Possibly, I am still working through a back log of 75+ new posts
In the future, only post a new query on a new thread, donā€™t post it on several threads
And then waitā€¦
Someone should pick it up. If not, then ā€œbumpā€ it after a while.

Sorry but this is asshole abusing behaviour. You are making others do the work. You not even tried. You basically say: this is what I had before, now make it work. Fast.

And that is not how it works here.

1 Like