I’m using mqtt dscovery very short time. I always prefer fixed settings. Now I gave it a go to it because of default settings of zigbee2mqtt.
I have a zigbee switch connected through zigbee2mqtt. The switch is configured but disconnected from power supply (it’s not powered on). So it’s not available in zigbee network therefore should be unavailable. And indeed it is how z2m reports it to mqtt
Here is how it looks like in mqtt:
homeassistant/switch/0x00158d000449dccc/switch/config
{
"availability": [
{
"topic": "zigbee2mqtt/bridge/state"
},
{
"topic": "zigbee2mqtt/zb_switch1/availability"
}
],
"command_topic": "zigbee2mqtt/zb_switch1/set",
"device": {
"identifiers": [
"zigbee2mqtt_0x00158d000449dccc"
],
"manufacturer": "Nue / 3A",
"model": "Smart in-wall switch (HGZB-01A)",
"name": "zb_switch1",
"sw_version": "Zigbee2MQTT 1.16.1"
},
"json_attributes_topic": "zigbee2mqtt/zb_switch1",
"name": "zb_switch1_switch",
"payload_off": "OFF",
"payload_on": "ON",
"state_topic": "zigbee2mqtt/zb_switch1",
"unique_id": "0x00158d000449dccc_switch_zigbee2mqtt",
"value_template": "{{ value_json.state }}"
}
Availability is set to offline:
But for some reason, HA still things it’s available and switched on:
History book:
The times likely corresponds with Z2M restarts. It turns unavailable and after few seconds turns on. But where the HA picks state and availability from, if the data in MQTT shows that device is unavailable. There is no even data about state=on.