Trouble with MQTT Bindings 2.x - eventsTriggered - Item stale


I have been struggling with the MQTT 2.x binding quite alot and have created various test cases, but I struggle here. Hopefully one of the friendly forum members can help me?

What seems to work (all configured via HABadmin / paperui)

  • mosquito is working
  • binding is installed in openhab, binding connects to MQTT service
  • event is triggered (“vent.ChannelTriggeredEvent”) when I update the mqtt channel.

Issue: Item (Switch) does not get updated.


I saw that there are a lot of discussions about MQTT in the forum, but I was not able to find any an mqtt binding 2.x howto. If I have overseen it, then please accept my sincere apologies - but I have spent quite a lot of time trying back and forth :-).

root@openhab:/etc/openhab2# cat items/mqtt.items
Switch MQTT_Test3 "Testing... MQ5" { mqtt="<[MQTTBroker:SWTest:state:default], >[broker:testing/mqtt/back-topic:command:*:default]" }

(I tried to add multiple pictures showing everything in context - but beeing a new user I was not allowed to have multiple pictures)

There is no “official” documentation out yet for MQTTv2

In principle, when using any 2.x Binding, your Item config needs to point to a Channel
Your Item config is still pointing to a legacy (1.x) style of config
Get the Channel Unique Identifier (CUID) from PaperUI and dump it in your Item ... { channel="CUID" }

1 Like


check this out: (WIP):

First of all thank you for being so responsive.

Q: I am still struggling, but hopefully you can “push” me into the right direction? I have read the smarthome binding readme - do you suggest that I perform the configuration manually instead of using paper-ui?

Status: I have also tried to move away from the “legacy(1.x)” configuration from the mqtt.items file - but this was no success. As you can see I have added the CUID into the “channel” - but openhab now no longer “sees” the mqtt updates (on/off) while I see them beeing send to mosquitto.

Any ideas how to continue tshooting this problem?

I would love to get this working and contribute by documenting the stuff that I needed to do (…).

sorry… i haven’t even started to study the new MQTTv2 binding to be able to help with troubleshooting…
I will have to do this at a certain moment to migrate all my MQTTv1 stuff over but I keep postponing this :stuck_out_tongue:

You added a channel to the MQTT broker connection
You need to create another Thing with a switch channel (Follow the instruction link 2 posts above)
and then link your item to that channel


it finally works. Thank you everyone - I have spent way too many hours on this.

Hopefully my little summary will help others to more out of openhab2. Its very cool when it works :slight_smile

  1. install mosquitto incl. mosquitto tools (e.g. apt-get install mosquitto_tools)
    Configured mosquitto according to the 1.x tutorial.

  2. Created an MQTT test sender

	#! /bin/bash
	while true; do
	    echo "SWTest ON"
	    mosquitto_pub -t 'SWTest' -m "ON" -d
	    sleep 5
	    echo "SWTest OFF"
	    mosquitto_pub -t 'SWTest' -m "OFF" -d
	    sleep 5
  1. Verified that MQTT is received from a local client
	mosquitto_sub -v -t 'SWTest' -d

(Please note that MQTT topics are case sensitive)

— if you don’t see the data from (2) here STOP. do not continue

  1. Installed the MQTT 2.x Binding via Paper-UI
    a) Things > MQTT > MQTT Broker
    b) Things > MQTT > ADD MANUALLY > Generic MQTT Thing
    Add Switch
    c) Link a new Switch into the MQTT Switch

In pictures MQTT Things:

Please note that the “IS COMMAND” had to be set (didn’t work for me without)

MQTT Thing linked to Switch

  1. Verify that (2) is able to update switch, relevant logs may be /var/log/openhab2/events.log

2018-12-07 14:45:31.732 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command OFF
2018-12-07 14:45:31.734 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become OFF
2018-12-07 14:45:31.735 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from ON to OFF
2018-12-07 14:45:35.505 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command ON
2018-12-07 14:45:35.506 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become ON
2018-12-07 14:45:35.507 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from OFF to ON
2018-12-07 14:45:39.277 [ome.event.ItemCommandEvent] - Item 'Switch_MQTT_SWTest' received command OFF
2018-12-07 14:45:39.278 [nt.ItemStatePredictedEvent] - Switch_MQTT_SWTest predicted to become OFF
2018-12-07 14:45:39.279 [vent.ItemStateChangedEvent] - Switch_MQTT_SWTest changed from ON to OFF

1 Like

nice overview
your help will be definitely appreciated to improve the upcoming Readme for MQTTv2 :wink:

1 Like

Thanks for the feedback and thanks for being so response. I have been testing, failing, testing, failing over multiple weeks and was about to give up the 2.x binding. But luckily we have some very helpful people in this forum here that pointed the beginner into the right direction.

I’ll post a tibber/mqtt integration howto later (once confirmed working).

1 Like