Unavailable device shown as available

Tags: #<Tag:0x00007f32702455c8>

I’m starting to learn zigbee2mqtt so doing experiments.
I have a paired Zigbee switch, which I disconnected from power supply expecting it will turn unavailable.

While in MQTT confirms it, HA still shows it as OFF.

Here is autodiscovery topic of this device:

  "availability": [
      "topic": "zigbee2mqtt/bridge/state"
      "topic": "zigbee2mqtt/zb3_switch_1/availability"
  "command_topic": "zigbee2mqtt/zb3_switch_1/set",
  "device": {
    "identifiers": [
    "manufacturer": "Nue / 3A",
    "model": "Smart in-wall switch (HGZB-01A)",
    "name": "zb3_switch_1",
    "sw_version": "Zigbee2MQTT 1.16.1-dev"
  "json_attributes_topic": "zigbee2mqtt/zb3_switch_1",
  "name": "zb3_switch_1_switch",
  "payload_off": "OFF",
  "payload_on": "ON",
  "state_topic": "zigbee2mqtt/zb3_switch_1",
  "unique_id": "0x00158d000449dccc_switch_zigbee2mqtt",
  "value_template": "{{ value_json.state }}"

Availability topic looks correctly:

But HA thinks it’s off

I can see no payload_not_available definition but offline is default expected value.
What am I missing?
is it autodiscovery issue or z2m?

thank you.

You need reporting and availability_timeout configured in your zigbee2mqtt config, otherwise devices will always remain in their last known state.

I have both set. Without them availability is not reported to mqtt.
I also have HueGo which currently is also unavailable and this fact is picked by HA up correctly.

  "availability": [
      "topic": "zigbee2mqtt/bridge/state"
      "topic": "zigbee2mqtt/HueGo/availability"
  "brightness": true,
  "brightness_scale": 254,
  "color_temp": true,
  "command_topic": "zigbee2mqtt/HueGo/set",
  "device": {
    "identifiers": [
    "manufacturer": "Philips",
    "model": "Hue Go (7146060PH)",
    "name": "HueGo",
    "sw_version": "Zigbee2MQTT 1.16.1-dev"
  "effect": true,
  "effect_list": [
  "hs": false,
  "json_attributes_topic": "zigbee2mqtt/HueGo",
  "name": "HueGo_light",
  "schema": "json",
  "state_topic": "zigbee2mqtt/HueGo",
  "unique_id": "0x00178801060da1a7_light_zigbee2mqtt",
  "xy": true

I created manually switch based on the same mqtt topic.
And it works as expected:

  - platform: "mqtt"
    name: "zb3_switch_1_test"
    unique_id: "zb3_switch_1_test"
    state_topic: "zigbee2mqtt/zb3_switch_1"
    availability_topic: "zigbee2mqtt/zb3_switch_1/availability"
    payload_off: "OFF"
    payload_on: "ON"
    value_template: "{{ value_json.state }}"
    command_topic: "zigbee2mqtt/zb3_switch_1/set"

MQTT discovery bug?

The only difference between mentioned switch and HueGo was, that reporting and availability_timeout params has been enabled after pairing the switch but before pairing HueGo.

After system restart, it started to work as expected.

Seems like autodiscovery caches the fact that ‘availability’ information was inexistent at time of creating entity. If availability information is added later, HA must be restarted to pick up this information