ZigBee2MQTT Device Availability

Hi, i hope someone can help me understand this.

I have a lot of ZigBee devices. Configured via ZigBee2MQTT. So far so good. Everything works fine. Now i would love to have an extra channel for every device which shows me the current state (online/offline)

I already defined it in the configuration.yaml.

    timeout: 10
    timeout: 1440

The frontend already shows me the current state. But i don’t know if its possible to get an extra channel for every single device. I already tried:

  legacy_availability_payload: true

But my ZigBee2MQTT seems to stop working after adding this line. I hoped, it adds a second JSON-attribute to the received payload. Like this: {"state":"offline"}



But as my ZigBee2MQTT fails to start after adding it in the configuration.yaml i don’t know how to achieve this.

Thanks in advance :slight_smile:

Please read https://www.zigbee2mqtt.io/guide/configuration/device-availability.html:

The availability feature checks whether your devices are online. The availability state of a device is published to zigbee2mqtt/[FRIENDLY_NAME]/availability (this message is a retained MQTT message).

I have these statements in my zigbee2mqtt configuration.yaml
legacy_api: true
legacy_availability_payload: true

If I run this mosquitto command:
mosquitto_sub -h -W 1 -v -t “zigbee2mqtt/+/availability”

I get the out put like this:
zigbee2mqtt/switch-backup-server/availability online
zigbee2mqtt/sensor-hue-lounge/availability online

This is the thing set up:

Thank you. Your replies helped me a lot.

I managed to get a working status for all my MQTT.things.
But now i would like to get a switch-item to show me the current state. I tried following without success:

Thing mqtt:topic:FRIENDLY_NAME "Z2M: FRIENDLY NAME" (mqtt:broker:823098e4c9) [availabilityTopic="zigbee2mqtt/FRIENDLY_NAME/availability", payloadAvailable="online", payloadNotAvailable="offline", transformationPattern="JSONPATH:$.state"] {
    Type switch : online "Availability" [stateTopic="zigbee2mqtt/FRIENDLY_NAME/availability", transformationPattern="JSONPATH:$.state", on="online", off="offline"]

My switch is not updating at all. What am i doing wrong now?

Set it like this and make the thing an on off switch:

UID: mqtt:topic:mqttbroker:9569f6beeb
label: Zigbee door front middle
thingTypeUID: mqtt:topic
  payloadNotAvailable: offline
  availabilityTopic: zigbee2mqtt/door-front-middle/availability
  payloadAvailable: online
bridgeUID: mqtt:broker:mqttbroker
location: Loungeroom
  - id: zigbeetestonline
    channelTypeUID: mqtt:switch
    label: Zigbee online
    description: ""
      commandTopic: zigbee2mqtt/door-front-middle/availability
      stateTopic: zigbee2mqtt/door-front-middle/availability
      off: online
      on: offline

Then create a switch: