Is MQTT action exists?

I want it :sunglasses:

There is no MQTT action.

But what would you want to do with an action that you cannot do with a String Item bound to a an MQTT topic and publishing a message using postUpdate?

For example:

Item:

String N_D_Update { mqtt=">[mosquitto:entry_sensors/getUpdate:state:*:default]" }

Rule Code:

N_D_Update.postUpdate("update")

The above rule code will publish the word “update” to the topic entry_sensors/getUpdate. I use it to request the current status of some sensors.

1 Like

There is, but you need to be running 1.8.

See: https://github.com/openhab/openhab/wiki/Actions#mqtt-action

Presumably this would also require an MQTT actions jar file installed, correct?

Should be found here (in addons.zip)

Pretty sure this link is deprecated. MQTT action is part of mqtt2 Binding.

Is there a way to install 1.8 from apt-get? I also would like this feature but would really like to keep everything under the package manager.

Not that I’m aware of. I’m running a couple of 1.8-SNAPSHOT addons that I installed manually to my 1.7.1 instance - after removing the version installed by Apt. This works fine, I just won’t get any updates for those addons via Apt.

Interesting that 1.8 wouldn’t be under the testing/unstable branch.

The distribution packaging mechanism does not currently support “unstable”. It would be nice to have!

There is no mqtt action bundle in this package.

I will submit a pull request to include it in the distribution. Whoops!

Thanks! :+1:

The JAR should be in addons.zip from the next nightly build. In the meantime, here is one.

Strange, build-list said Build-Duration for MQTT-action was 1.2secs… direct Link: https://openhab.ci.cloudbees.com/job/openHAB/lastStableBuild/org.openhab.action$org.openhab.action.mqtt/artifact/org.openhab.action/org.openhab.action.mqtt/1.8.0-SNAPSHOT/org.openhab.action.mqtt-1.8.0-SNAPSHOT.jar

Yes, the jar was being built but not included in the final deliverable. Tha’s what @watou fixed.

Expect the new functionality on tonights Jenkins build.

How to post a retained message to topic?

Since the action uses the same underlying MqttService as the binding, you would set retain to true in openhab.cfg as documented here. I just updated the Actions wiki page with this info as well.

I try to create 2 connections to mqtt retained and not, but it not works for me.
Please view my settings, is it right?
openhab.cfg:
mqtt:wb.url=tcp://192.168.1.4:1883
mqtt:wb.clientId=openhab
mqtt-eventbus:broker=wb
mqtt:wb.retain=false

mqtt:wbr.url=tcp://192.168.1.4:1883
mqtt:wbr.clientId=openhab2
mqtt-eventbus:broker=wbr
mqtt:wbr.retain=true

I see you are defining the mqtt-eventbus:broker config value twice, once as wb and again as wbr.

mqtt-eventbus:broker should be only one for same server?
And if i use another mqtt server 192.168.1.5 - should i define eventbus:broker for it?