Device state not updated in openhab

Dear all,
I’m going crazy getting my zigbee devices to work through the zigbee2mqtt binding.
While turning them on and off works fine the state does not get updated on external changes - like switching them on or off manually or updates to the link quality.
I’ve tried various combinations of using JSONPATH transformation on the channel or the item without any luck. At this point I don’t have any idea what else to try. I’ve set everything via the UI. Below is a sample of my channel configuration:
Please help me find what I’m missing here.

thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:48bee07d3e
channels:
  - id: "1"
    channelTypeUID: mqtt:switch
    label: Zigbee_Steckdose_1_switch
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/Steckdose01/set/state
      postCommand: false
      stateTopic: zigbee2mqtt/Steckdose01/state
      off: '"OFF"'
      on: '"ON"'
  - id: "2"
    channelTypeUID: mqtt:number
    label: Zigbee_Steckdose_1_LQI
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/Steckdose01/linkquality
      max: 255
      min: 0
  - id: "3"
    channelTypeUID: mqtt:contact
    label: Zigbee_Bewegungsmelder_1_Movement
    description: ""
    configuration:
      postCommand: true
      stateTopic: zigbee2mqtt/Bewegungsmelder01
      off: "false"
      on: "true"
  - id: "4"
    channelTypeUID: mqtt:switch
    label: Zigbee_Steckdose_2_switch
    description: null
    configuration:
      commandTopic: zigbee2mqtt/0xa4c1383dc0682214/set/state
      postCommand: true
      qos: 1
      stateTopic: zigbee2mqtt/0xa4c1383dc0682214/state
      off: '"OFF"'
      on: '"ON"'

Cheers, Jo

Please share which devices you have, by linking to the specific device page from here.

Please also share your zigbee2mqtt configuration.yaml.

Thanks for your feedback!
I have the following the devices. The behavior is the same for all of them:
Lidl Smart Plug: Lidl HG06337 control via MQTT | Zigbee2MQTT
Lidl 3-way switch: Lidl HG06338 control via MQTT | Zigbee2MQTT
Lidl smart motion sensor: Lidl HG06335/HG07310 control via MQTT | Zigbee2MQTT
FDTEK smart plug with power monitoring (recognized as Tuya TS011F Plug 1): TuYa TS011F_plug_1 control via MQTT | Zigbee2MQTT

Here is my configuration.yaml:

homeassistant: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://127.0.0.1
  user: ***
  password: ***
serial:
  port: /dev/ttyUSB0
frontend:
  port: 7080
advanced:
  network_key:
    - ***
    - ***
    - ***
    - ***
    - **
    - ***
    - ***

Is that the whole thing? I don’t see any of the devices in here.

Oh sorry, missed a part. Here is the whole file:

homeassistant: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://127.0.0.1
  user: *
  password: *
serial:
  port: /dev/ttyUSB0
frontend:
  port: 7080
advanced:
  network_key:
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
    - *
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
device_options:
  legacy: false
devices:
  '0xcc86ecfffefa5d63':
    friendly_name: Steckdose01
  '0x50325ffffe530ce1':
    friendly_name: Steckerleiste01
  '0x84fd27fffebb781c':
    friendly_name: Bewegungsmelder01
  '0x50325ffffe4a94bb':
    friendly_name: Steckerleiste02
  '0xa4c1383dc0682214':
    friendly_name: Steckdose02
  '0xa4c138262ba0291e':
    friendly_name: Steckdose03

Thanks. Do you have other devices which use the MQTT Binding, and you’re successfully receiving updates from them? Or is this the first time that you’re using this binding?

I’m using the same switch together with z2m and here is my working channel configuration, maybe that’s helpful

channels:
  - id: An_Aus
    channelTypeUID: mqtt:switch
    label: An / Aus
    description: null
    configuration:
      commandTopic: zigbee2mqtt/<device>/set/state
      formatBeforePublish: "%.s"
      stateTopic: zigbee2mqtt/<device>
      transformationPattern: JSONPATH:$.state

You are definitely missing the transformation pattern to receive the state, make sure to have json transformation installed and maybe the quotes on your on/off state are too much.

Also I would recommend to add individual things for each physical device. Even technically it does not matter, it’s maybe helpful to have a better overview and do not mix-up things

Thanks. I was unsure if the JSONPATH setting is actually required.
I’ve mirrored your settings like this now.

UID: mqtt:topic:48bee07d3e:738ae32ae7
label: Zigbee_Geräte
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:48bee07d3e
channels:
  - id: "1"
    channelTypeUID: mqtt:switch
    label: Zigbee_Steckdose_1_switch
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/Steckdose01/set/state
      postCommand: false
      stateTopic: zigbee2mqtt/Steckdose01/
      transformationPattern: JSONPATH:$.state

Unfortunately the behavior is still the same. This should rule out incorrect thing/channel settings, though, so I guess the error comes from somewhere else. Below is the code from my MQTT broker, just to make sure

UID: mqtt:broker:48bee07d3e
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  clientid: 81e6680b-b555-45f9-8ffe-cd43cbba7326
  keepAlive: 60
  secure: false
  certificatepin: true
  password: *
  qos: 1
  reconnectTime: 60000
  host: 192.168.107.252
  lwtRetain: true
  enableDiscovery: true
  username: *

Probably time to start looking into the openHAB logs.

Do you have the JSONPATH Transformation Service installed?

And double check your new configuration. It’s not exactly the mirror of @Matze0211 - there’s at least a trailing slash in there, as well as a not-needed postCommand parameter…

Hm, maybe it was the trailing slash or something else - anyway I got it to work now.
Thanks a lot for your inputs, guys, I can die happy now. :slight_smile: