New MQTT 2.4 Binding

Can you give an example, please?
I have not seen any MQTTv2 rule examples, yet

1 Like

I cannot. I haven’t written a javascript rule yet and have no idea how to interact with a new rule engine action from within DSL rules. But the idea is simple:

When
  item_change
Do
  mqtt.publish("my/topic/"+item.getUID(), item.getState().toString())
1 Like

But the MQTT action remains the same after MQTTv2 is installed and V1 removed? In the DSL

No, as I said, I have no idea how to access a new-rule-engine action. The binding id is “mqtt” and the action-id is “publish”, that is all I know.

Not in the new rule engine. In the DSL, does the action remain the same?

I would assume you cannot use the MQTT v2 action in the DSL rules.

Well, I want to clear up the assumption, and understand how to use the equivalent of the V1 Action with the V2 binding.

I could live with the fact that “new” actions would only be accessible via “new” javascript/jython rules. But Kai said something along the lines of that new actions will be available for DSL rules as well, personally I just don’t know how.

Can someone explain me a little bit, how this MQTT Binding differs from the old (1.0) one?

I have tried installing it, but I couldn’t find later, how could I use it… I thought it follows the same procedure as other OH 2.X bindings, that you will have a bridge (MQTT broker) and then it will “auto-discover” the available topics and you can add each end-topic as a thing.
But I assume this is not how this works. Can someone explain that to me in a few sentences?
Will it worth switching to it from 1.0? I think sooner or later I will have to switch from my 1.X bindings and I have a few (I use MQTT very frequently, almost everything communicates through this protocol), so I would start with this…

Thanks in advance!

Yeah, this is at least what I like to make possible, potentially even only through some workaround/hack. But I see it as an important feature so that the new MQTT binding can really serve as a full replacement for the old one.
Getting the actions accessible from rules is one of my last todos for the 2.4 release - I’ll hurry up to come up with some suggestion :slight_smile: .

3 Likes

I’m just trying to migrate to MQTT 2.4.
So far I’ve been pulsing my EasyESP over mqtt1:

default.items:
Rollershutter Markise “Markise” {mqtt=">[broker:/Markise/cmd:command:UP:pulse,0,0,100], >[broker:/Markise/cmd:command:STOP:pulse,2,0,100], >[broker:/Markise/cmd:command:DOWN:pulse,1,0,100]"}

but how do I do that in the new version ?!

At the moment you can’t. You would need an outbound MAP transformation to convert UP to “pulse,0,0,100” and so on. OH 2.5 snapshot will support this soon.

Hi David,

are there plans for OH2.5 to support multiple nodes for one homie device as this is currently noted as a limitation and I’d like to use this?

  • This binding does not support Homie Node Instances.

Cheers, Michel

Multiple nodes are supported. Node “arrays” are not supported because they are removed in Homie 4.0.

Time for me to jump on the bandwagon, I appear to have picked a really bad time to migrate my OH2 onto a new rPi as I have stumbles onto this MQTT issue.
I assume on the old rPi I was on an older version of MQTT (forgive my ignorance here) and the new rPi which is up-to-date via apt, must be on the new one. I installed the MQTT binding via PaperUI and mosquitto via apt.
I can publish and subscribe fine via the CLI using mosquitto_pub and mosquitto_sub, so I know that at least this is working. Integration with OH2 seems to have broken.
If anyone is able to help I would be extremely grateful!

mqtt.things

mqtt:broker:mySecureBroker [ host="192.168.0.10", secure=true, certificatepin=true, publickeypin=true ]

mqtt:broker:myAuthentificatedBroker [ host="192.168.0.10", secure=false, username="openhab", password="mypassword" ]

example of an item (sonoff tasmota)

Switch airwick_lounge_alive "Air Wick Lounge Alive" (sonoff)
    { mqtt="<[mqtt:tele/sonoff-airwick-lounge/tele/LWT:state:MAP(unreach.map)]" }
Number airwick_lounge_rssi "Air Wick Lounge RSSI [%d %%]" (sonoff)
    { mqtt="<[mqtt:tele/sonoff-airwick-lounge/STATE:state:JSONPATH($.Wifi.RSSI)]" }
Switch airwick_lounge_switch "Air Wick Lounge Switch" (sonoff)["Lighting"]
    { mqtt=">[mqtt:cmnd/sonoff-airwick-lounge/POWER:command:*:default],
            <[mqtt:stat/sonoff-airwick-lounge/POWER:state:default]" }

From reading the above I assume that the items need to be changed to something along the lines of mqtt.publish(…) but not quite sure how to integrate the directionality or the item command (e.g. from clicking the respective button in HABPanel).

Cheers, and happy new year!

Install mqtt1.

Again, apologies for my ignorance; how do I do that? I cant see anything in PaperUI relating to MQTT1

You should be able to turn on “Include Legacy 1.x Bindings” under Paper_UI > Configuration > System > Add-on Management.

1 Like

Although the revert to mqtt1 has been suggeste to you, I’d like to point you to a thread discribing the use of mqtt2.4 with tasmota. See here

Perfect, just what I needed. I’ll give it a go. Many many thanks everyone