Zigbee2MQTT / MQTT Broker Binding - Read values correctly

Good evening forum,
I am now using MQTT to control my ZigBee devices.
With the switching of sockets it already works, only the reading of values does not work yet.

I installed MQTT Explorer to test and read out the actual functions and values of the devices.
So I have integrated a Ledvance (Osram) Smart Plug+.
(OSRAM AB3257001NJ control via MQTT | zigbee2mqtt.io)
Switching on and off works, only the value linkquality I do not get integrated in OpenHAB. There I get only ZERO.

Preliminary: Yes I am aware that there are configuration files here in the forum and many info about it. But I want to make the whole thing as simple as possible and set up as much as possible via web interface.
This will make later maintenance easier.

Here is the detailed problem.
This is the output via MQTT Explorer of the socket:

{
  "linkquality": 114,
  "state": "OFF",
  "update": {
    "state": "idle"
  }
}

I have created a new Thing and created two Channels.
One channel is for switching the socket - that works - and the other one is for the connection quality.
I named the connection quality “Signal”.
Here is the code for the setup:

UID: mqtt:topic:MQTTBroker:Stecker
label: Ledvance1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:MQTTBroker
channels:
  - id: Strom
    channelTypeUID: mqtt:switch
    label: Strom
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigBee-Ledvance1/set
      stateTopic: zigbee2mqtt/ZigBee-Ledvance1/get
      off: OFF
      on: ON
  - id: Signal
    channelTypeUID: mqtt:number
    label: Signal
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/ZigBee-Ledvance1
      transformationPattern: JSONPATH:$.linkquality

On my fresh test system I have also installed the following:

  • Binary To JSON Transformation
  • Javascript Transformation
  • JSONPath Transformation

I still have a motion detector here, which I also tried to include. There I get the same result :frowning:
I’m probably doing something wrong when creating the channels or?

I have some Tradfri devices connected via zigbee2mqtt with thelinkquality parameter working. If I remember correctly the linkquality value is only published when something else happens with the device, such as it has been switched on or off.

Also, your stateTopics do not match.

Might be worth double checking what topic your example JSON is actually published on.

1 Like

Thanks for the tip.
Due to the long trial and error, I did not even notice it.
I have removed the /get in stateTopic and now the numbers are retrieved.
To be on the safe side, I added stateTopic to the channel for the signal strength (although not needed).

For the protocol, the correct configuration:

UID: mqtt:topic:MQTTBroker:Stecker
label: sdfgsdfg
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:MQTTBroker
channels:
  - id: Strom
    channelTypeUID: mqtt:switch
    label: Strom
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigBee-Ledvance1/set
      stateTopic: zigbee2mqtt/ZigBee-Ledvance1
      off: OFF
      on: ON
  - id: Signal
    channelTypeUID: mqtt:number
    label: Signal
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigBee-Ledvance1/set
      stateTopic: zigbee2mqtt/ZigBee-Ledvance1
      transformationPattern: JSONPATH:$.linkquality

stateTopic is about receiving MQTT messages (subscribe)
commandTopic is about sending messages (publish)