MQTT state not updating


I’m a bit out of options, so I hope someone else can explain what I’m doing wrong.
Currently running openHabian 3.4.2. with Mosquitto MQTT broker and Zigbee2MQTT, everything is working fine expect for one thing.

I recently purchased new Zigbee Smart plugs to try out, they are from Nous, Zigbee2MQTT documentation here:

It paired correctly with Zigbee2MQTT, so I gave it a friendly name and added it to my thing file like the documentation describes, the thing looks like this:

     Thing topic socketPower1 "socketPower1" {
    Type switch : power             "Power"         [ stateTopic="zigbee2mqtt/socketPlug1/get", transformationPattern="JSONPATH:$.state", commandTopic="zigbee2mqtt/socketPlug1/set", on="ON", off="OFF" ]

The item looks like this:

Switch socketPower1 "socketPower1" { channel="mqtt:topic:mosquitto:socketPower1:power" }

The command part of the thing is working correctly, I can switch it to ON and OFF via openHab, but when I toggle the switch with the physical button or in the Zigbee2MQTT webgui, it doesn’t get updates in openHab. When I connect with a tool called MQTT Explorer to the MQTT broker, I can see the sates changing from OFF to ON.

Why isn’t it updating in openHab?

Does the info from MQTT explorer match with the setup in OH?

Thanks for the quick response, it seems to be the same info as the documentation describes:

Remove the get from the state topic to match mqtt explorer

I tried, but still nothing, when I flip the switch on the webGUI, the status in openHab keeps unchanged

Anything in your log file?
Maybe remove ON & OFF values in the thing. As these are the default values this should work by default.

Can you try to add same thing via user interface, to see if that’s a syntax issue in your thing file or something else wrong?

Ok, really strange, I commented the thing lines out so the thing would get deleted. Then I added the thing as you said through the user interface and configured it exactly the same and everything was working (also the update from zigbee2mqtt to openHab).

Then I deleted everything again in the user interface, uncommented all the lines again, saved it and now everything is also working from the thing file :slight_smile:

If anybody ever wonders, the thing now looks like this:

  Thing topic socketPower1 "socketPower1"  {
    Type switch : power             "Power"         [ stateTopic="zigbee2mqtt/socketPlug1", transformationPattern="JSONPATH:$.state", commandTopic="zigbee2mqtt/socketPlug1/set" ]

So, indeed you don’t need to place the get statement at the end of the topic.

You have also removed the on/off description in your thing.

Out of curiosity:
If you re-add (or create a duplicated thing)

on="ON", off="OFF"

To your thing, will it break again?