Zigbee2Mqtt auto discovery not working

I am running the Mosquitto and Zigbee2Mqtt addons. Both are configured to use discovery. I am able to add device to Z2M successfully. The problem is happening when the discovery messages get sent from Z2M to HA. The broker sees the messages, but then immediately removes them. You can see it happen here under binary_sensor: Mqtt explorer

I set the core and mqtt integration logging to debug and it gives a bit more info. It appears that the mqtt integration sees the discovery message, creates the device and then removes it. You can see the removals on lines 41 and 52 here: Pastebin

I have actually been able to see the devices get created very briefly in HA. If I keep the devices for the MQTT integration page open and I have Z2M send a discovery message it see a new device show up, but if I refresh the page it is gone.

What could be causing the devices to not stick?

I have tested mqtt discovery with some tasmota devices and it works fine, so this is something specific to Z2M.

What is your version of HA ? and what is the version of Zigbee2MQTT ?

I am running core-2021.9.5 and Zigbee2Mqtt version 1.21.1-1

Here is some more information about what is happening. I set the mqtt integration log level to debug and here is what happens when a discovery message is sent from Zigbee2Mqtt.

2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/battery/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/0x00158d0001e18535/occupancy/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/voltage/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/linkquality/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/battery/config: b'{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0x00158d0001e18535"],"manufacturer":"Xiaomi","model":"MiJia human body movement sensor (RTCGQ01LM)","name":"Unknown Motion Sensor","sw_version":"Zigbee2MQTT 1.21.1"},"device_class":"battery","json_attributes_topic":"zigbee2mqtt/Unknown Motion Sensor","name":"Unknown Motion Sensor battery","state_class":"measurement","state_topic":"zigbee2mqtt/Unknown Motion Sensor","unique_id":"0x00158d0001e18535_battery_zigbee2mqtt","unit_of_measurement":"%","value_template":"{{ value_json.battery }}"}'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'identifiers': ['zigbee2mqtt_0x00158d0001e18535'], 'manufacturer': 'Xiaomi', 'model': 'MiJia human body movement sensor (RTCGQ01LM)', 'name': 'Unknown Motion Sensor', 'sw_version': 'Zigbee2MQTT 1.21.1'}, 'device_class': 'battery', 'json_attributes_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'name': 'Unknown Motion Sensor battery', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'unique_id': '0x00158d0001e18535_battery_zigbee2mqtt', 'unit_of_measurement': '%', 'value_template': '{{ value_json.battery }}', 'platform': 'mqtt'}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001e18535 battery
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/0x00158d0001e18535/occupancy/config: b'{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0x00158d0001e18535"],"manufacturer":"Xiaomi","model":"MiJia human body movement sensor (RTCGQ01LM)","name":"Unknown Motion Sensor","sw_version":"Zigbee2MQTT 1.21.1"},"device_class":"motion","json_attributes_topic":"zigbee2mqtt/Unknown Motion Sensor","name":"Unknown Motion Sensor occupancy","payload_off":false,"payload_on":true,"state_topic":"zigbee2mqtt/Unknown Motion Sensor","unique_id":"0x00158d0001e18535_occupancy_zigbee2mqtt","value_template":"{{ value_json.occupancy }}"}'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/voltage/config: b'{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0x00158d0001e18535"],"manufacturer":"Xiaomi","model":"MiJia human body movement sensor (RTCGQ01LM)","name":"Unknown Motion Sensor","sw_version":"Zigbee2MQTT 1.21.1"},"device_class":"voltage","enabled_by_default":false,"json_attributes_topic":"zigbee2mqtt/Unknown Motion Sensor","name":"Unknown Motion Sensor voltage","state_class":"measurement","state_topic":"zigbee2mqtt/Unknown Motion Sensor","unique_id":"0x00158d0001e18535_voltage_zigbee2mqtt","unit_of_measurement":"mV","value_template":"{{ value_json.voltage }}"}'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/linkquality/config: b'{"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"device":{"identifiers":["zigbee2mqtt_0x00158d0001e18535"],"manufacturer":"Xiaomi","model":"MiJia human body movement sensor (RTCGQ01LM)","name":"Unknown Motion Sensor","sw_version":"Zigbee2MQTT 1.21.1"},"enabled_by_default":false,"icon":"mdi:signal","json_attributes_topic":"zigbee2mqtt/Unknown Motion Sensor","name":"Unknown Motion Sensor linkquality","state_class":"measurement","state_topic":"zigbee2mqtt/Unknown Motion Sensor","unique_id":"0x00158d0001e18535_linkquality_zigbee2mqtt","unit_of_measurement":"lqi","value_template":"{{ value_json.linkquality }}"}'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event device_registry_updated[L]: action=create, device_id=0ee008416dbe4debb9bd3dcbab88b18f>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=create, entity_id=sensor.unknown_motion_sensor_battery>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/info: b'{"commit":"unknown","config":{"advanced":{"adapter_concurrent":null,"adapter_delay":null,"availability_blacklist":[],"availability_blocklist":[],"availability_passlist":[],"availability_timeout":0,"availability_whitelist":[],"cache_state":true,"cache_state_persistent":true,"cache_state_send_on_startup":true,"channel":11,"elapsed":false,"ext_pan_id":[221,221,221,221,221,221,221,221],"homeassistant_discovery_topic":"homeassistant","homeassistant_legacy_entity_attributes":true,"homeassistant_legacy_triggers":true,"homeassistant_status_topic":"hass/status","last_seen":"disable","legacy_api":true,"log_directory":"/config/zigbee2mqtt/log/%TIMESTAMP%","log_file":"log.txt","log_level":"warn","log_output":["console","file"],"log_rotation":true,"log_symlink_current":false,"log_syslog":{},"pan_id":6754,"report":false,"soft_reset_timeout":0,"timestamp_format":"YYYY-MM-DD HH:mm:ss"},"ban":[],"blocklist":[],"device_options":{},"devices":{"0x000d6ffffe223e0c":{"friendly_name":"Living Room Lamp 2"},"0x00158d0001aea6b7":{"friendly_name":"Main Closet"},"0x00158d0001aea731":{"friendly_name":"Kitchen Motion"},"0x00158d0001e18535":{"friendly_name":"Unknown Motion Sensor"},"0x00158d000204955b":{"friendly_name":"Main Bedroom Window"},"0x00158d00020b4f71":{"friendly_name":"Living Room Window"},"0x00158d00033f0a53":{"friendly_name":"Outside"},"0x00158d000358d998":{"friendly_name":"Main Bathroom"},"0x00158d000405101f":{"friendly_name":"Isla\'s Room Button"},"0xd0cf5efffeca7181":{"friendly_name":"Living Room Lamp"}},"experimental":{"output":"json"},"external_converters":[],"frontend":{"port":8099},"groups":{},"homeassistant":true,"map_options":{"graphviz":{"colors":{"fill":{"coordinator":"#e04e5d","enddevice":"#fff8ce","router":"#4ea3e0"},"font":{"coordinator":"#ffffff","enddevice":"#000000","router":"#ffffff"},"line":{"active":"#009900","inactive":"#994444"}}}},"mqtt":{"base_topic":"zigbee2mqtt","force_disable_retain":false,"include_device_information":false,"server":"mqtt://192.168.1.148:1883","user":"hassio"},"ota":{"disable_automatic_update_check":false,"update_check_interval":1440},"passlist":[],"permit_join":false,"queue":{},"serial":{"adapter":"deconz","disable_led":false,"port":"/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2149353-if00"},"whitelist":[]},"config_schema":{"definitions":{"device":{"properties":{"debounce":{"description":"Debounces messages of this device","title":"Debounce","type":"number"},"debounce_ignore":{"description":"Protects unique payload values of specified payload properties from overriding within debounce time","examples":["action"],"items":{"type":"string"},"title":"Ignore debounce","type":"array"},"filtered_attributes":{"description":"Filter attributes from publish payload.","examples":["temperature","battery","action"],"items":{"type":"string"},"title":"Filtered publish attributes","type":"array"},"filtered_optimistic":{"description":"Filter attributes from optimistic publish payload when calling /set. (This has no effect if optimistic is set to false).","examples":["color_mode","color_temp","color"],"items":{"type":"string"},"title":"Filtered optimistic attributes","type":"array"},"friendly_name":{"description":"Used in the MQTT topic of a device. By default this is the device ID","readOnly":true,"title":"Friendly name","type":"string"},"icon":{"description":"The user-defined device icon for the frontend. It can be a link to an image (not a path to a file) or base64 encoded data URL like: image/svg+xml;base64,PHN2ZyB3aW....R0aD","title":"Icon","type":"string"},"optimistic":{"default":true,"description":"Publish optimistic state after set","title":"Optimistic","type":"boolean"},"qos":{"description":"QoS level for MQTT messages of this device","title":"QoS","type":"number"},"retain":{"description":"Retain MQTT messages of this device","title":"Retain","type":"boolean"},"retention":{"description":"Sets the MQTT Message Expiry in seconds, Make sure to set mqtt.version to 5","title":"Retention","type":"number"}},"required":["friendly_name"],"type":"object"},"group":{"properties":{"devices":{"items":{"type":"string"},"type":"array"},"filtered_attributes":{"items":{"type":"string"},"type":"array"},"friendly_name":{"type":"string"},"optimistic":{"type":"boolean"},"qos":{"type":"number"},"retain":{"type":"boolean"}},"required":["friendly_name"],"type":"object"}},"properties":{"advanced":{"properties":{"adapter_concurrent":{"description":"Adapter concurrency (e.g. 2 for CC2531 or 16 for CC26X2R1) (default: null, uses recommended value)","requiresRestart":true,"title":"Adapter concurrency","type":["number","null"]},"adapter_delay":{"description":"Adapter delay","requiresRestart":true,"title":"Adapter delay","type":["number","null"]},"availability_blacklist":{"items":{"type":"string"},"readOnly":true,"requiresRestart":true,"title":"Availability blacklist (deprecated, use availability_blocklist)","type":"array"},"availability_blocklist":{"description":"Prevent devices from being checked for availability","items":{"type":"string"},"requiresRestart":true,"title":"Availability Blocklist","type":"array"},"availability_passlist":{"description":"Only enable availability check for certain devices","items":{"type":"string"},"requiresRestart":true,"title":"Availability passlist","type":"array"},"availability_timeout":{"default":0,"description":"Availability timeout in seconds when enabled, devices will be checked if they are still online. Only AC powered routers are checked for availability","minimum":0,"requiresRestart":true,"title":"Availability Timeout","type":"number"},"availability_whitelist":{"items":{"type":"string"},"readOnly":true,"requiresRestart":true,"title":"Availability whitelist (deprecated, use passlist)","type":"array"},"baudrate":{"description":"Baud rate speed for serial port, this can be anything firmware support but default is 115200 for Z-Stack and EZSP, 38400 for Deconz, however note that some EZSP firmware need 57600","examples":[38400,57600,115200],"requiresRestart":true,"title":"Baudrate","type":"number"},"cache_state":{"default":true,"description":"MQTT message payload will contain all attributes, not only changed ones. Has to be true when integrating via Home Assistant","title":"Cache state","type":"boolean"},"cache_state_persistent":{"default":true,"description":"Persist cached state, only used when cache_state: true","title":"Persist cache state","type":"boolean"},"cache_state_send_on_startup":{"default":true,"description":"Send cached state on startup, only used when cache_state: true","title":"Send cached state on startup","type":"boolean"},"channel":{"default":11,"description":"Zigbee channel, changing requires repairing all devices! (Note: use a ZLL channel: 11, 15, 20, or 25 to avoid Problems)","examples":[15,20,25],"maximum":26,"minimum":11,"requiresRestart":true,"title":"ZigBee channel","type":"number"},"elapsed":{"default":false,"description":"Add an elapsed attribute to MQTT messages, contains milliseconds since the previous msg","title":"Elapsed","type":"boolean"},"ext_pan_id":{"description":"Zigbee extended pan ID, changing requires repairing all devices!","items":{"type":"number"},"requiresRestart":true,"title":"Ext Pan ID","type":"array"},"homeassistant_discovery_topic":{"description":"Home Assistant discovery topic","examples":["homeassistant"],"requiresRestart":true,"title":"Homeassistant discovery topic","type":"string"},"homeassistant_legacy_entity_attributes":{"default":true,"description":"Home Assistant legacy entity attributes, when enabled Zigbee2MQTT will add state attributes to each entity, additional to the separate entities and devices it already creates","title":"Home Assistant legacy entity attributes","type":"boolean"},"homeassistant_legacy_triggers":{"default":true,"description":"Home Assistant legacy triggers, when enabled Zigbee2mqt will send an empty \'action\' or \'click\' after one has been send. A \'sensor_action\' and \'sensor_click\' will be discoverd","title":"Home Assistant legacy triggers","type":"boolean"},"homeassistant_status_topic":{"description":"Home Assistant status topic","examples":["homeassistant/status"],"requiresRestart":true,"title":"Home Assist'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'identifiers': ['zigbee2mqtt_0x00158d0001e18535'], 'manufacturer': 'Xiaomi', 'model': 'MiJia human body movement sensor (RTCGQ01LM)', 'name': 'Unknown Motion Sensor', 'sw_version': 'Zigbee2MQTT 1.21.1'}, 'device_class': 'motion', 'json_attributes_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'name': 'Unknown Motion Sensor occupancy', 'payload_off': False, 'payload_on': True, 'state_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'unique_id': '0x00158d0001e18535_occupancy_zigbee2mqtt', 'value_template': '{{ value_json.occupancy }}', 'platform': 'mqtt'}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 0x00158d0001e18535 occupancy
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'identifiers': ['zigbee2mqtt_0x00158d0001e18535'], 'manufacturer': 'Xiaomi', 'model': 'MiJia human body movement sensor (RTCGQ01LM)', 'name': 'Unknown Motion Sensor', 'sw_version': 'Zigbee2MQTT 1.21.1'}, 'device_class': 'voltage', 'enabled_by_default': False, 'json_attributes_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'name': 'Unknown Motion Sensor voltage', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'unique_id': '0x00158d0001e18535_voltage_zigbee2mqtt', 'unit_of_measurement': 'mV', 'value_template': '{{ value_json.voltage }}', 'platform': 'mqtt'}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001e18535 voltage
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'identifiers': ['zigbee2mqtt_0x00158d0001e18535'], 'manufacturer': 'Xiaomi', 'model': 'MiJia human body movement sensor (RTCGQ01LM)', 'name': 'Unknown Motion Sensor', 'sw_version': 'Zigbee2MQTT 1.21.1'}, 'enabled_by_default': False, 'icon': 'mdi:signal', 'json_attributes_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'name': 'Unknown Motion Sensor linkquality', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Unknown Motion Sensor', 'unique_id': '0x00158d0001e18535_linkquality_zigbee2mqtt', 'unit_of_measurement': 'lqi', 'value_template': '{{ value_json.linkquality }}', 'platform': 'mqtt'}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x00158d0001e18535 linkquality
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 battery'): deque([])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/battery/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/0x00158d0001e18535/occupancy/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/voltage/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensor/0x00158d0001e18535/linkquality/config: b''
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state, mid: 45
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state (retained): b'online'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.unknown_motion_sensor_battery, old_state=None, new_state=<state sensor.unknown_motion_sensor_battery=unknown; state_class=measurement, unit_of_measurement=%, friendly_name=Unknown Motion Sensor battery, device_class=battery @ 2021-09-09T13:17:42.751619-07:00>>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor 0x00158d0001e18535 battery, sending update
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: binary_sensor 0x00158d0001e18535 occupancy, queuing update
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor 0x00158d0001e18535 voltage, queuing update
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor 0x00158d0001e18535 linkquality, queuing update
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=create, entity_id=binary_sensor.unknown_motion_sensor_occupancy>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=create, entity_id=sensor.unknown_motion_sensor_voltage>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=create, entity_id=sensor.unknown_motion_sensor_linkquality>
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('sensor', '0x00158d0001e18535 battery') '{}'
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: sensor.unknown_motion_sensor_battery
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=remove, entity_id=sensor.unknown_motion_sensor_battery>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('binary_sensor', '0x00158d0001e18535 occupancy'): deque([{}])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: binary_sensor 0x00158d0001e18535 occupancy, sending update
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 voltage'): deque([{}])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 linkquality'): deque([{}])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {}
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 battery'): deque([])
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('binary_sensor', '0x00158d0001e18535 occupancy') '{}'
2021-09-09 13:17:42 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: binary_sensor.unknown_motion_sensor_occupancy
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=remove, entity_id=binary_sensor.unknown_motion_sensor_occupancy>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event device_registry_updated[L]: action=remove, device_id=0ee008416dbe4debb9bd3dcbab88b18f>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 voltage'): deque([])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('sensor', '0x00158d0001e18535 linkquality'): deque([])
2021-09-09 13:17:42 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in _async_registry_updated
    await self.async_remove()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 722, in async_remove
    await self.async_will_remove_from_hass()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 607, in async_will_remove_from_hass
    await MqttAvailability.async_will_remove_from_hass(self)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 360, in async_will_remove_from_hass
    self._availability_sub_state = await async_unsubscribe_topics(
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 113, in async_unsubscribe_topics
    return await async_subscribe_topics(hass, sub_state, {})
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 101, in async_subscribe_topics
    debug_info.remove_subscription(
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 64, in remove_subscription
    hass.data[DATA_MQTT_DEBUG_INFO]["entities"][entity_id]["subscriptions"][
KeyError: 'zigbee2mqtt/bridge/state'
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/bridge/state, mid: 46
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on zigbee2mqtt/bridge/state (retained): b'online'
2021-09-09 13:17:42 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'binary_sensor.unknown_motion_sensor_occupancy'

2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=remove, entity_id=sensor.unknown_motion_sensor_voltage>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event entity_registry_updated[L]: action=remove, entity_id=sensor.unknown_motion_sensor_linkquality>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('binary_sensor', '0x00158d0001e18535 occupancy'): deque([])
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/Unknown Motion Sensor, mid: 47
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/Unknown Motion Sensor, mid: 48
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/Unknown Motion Sensor, mid: 49
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=binary_sensor.unknown_motion_sensor_occupancy, old_state=None, new_state=<state binary_sensor.unknown_motion_sensor_occupancy=unavailable; friendly_name=Unknown Motion Sensor occupancy, device_class=motion @ 2021-09-09T13:17:42.827951-07:00>>
2021-09-09 13:17:42 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to zigbee2mqtt/Unknown Motion Sensor, mid: 50

It looks like HA thinks the devices already exist and removes them. Why could that be happening?

1 Like

I am facing the same problem.

Out of a sudden one of my thermostats became unavailable as a device and now I can’t add it anymore.

Did you find a solution to this?

2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 0x5c0272fffea131ee battery_low
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.mqtt entity: binary_sensor.0x5c0272fffea131ee_battery_low
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: switch 0x5c0272fffea131ee window_detection
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: binary_sensor 0x5c0272fffea131ee battery_low, sending update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('binary_sensor', '0x5c0272fffea131ee battery_low') '{}'
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: binary_sensor.0x5c0272fffea131ee_battery_low
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: lock 0x5c0272fffea131ee child_lock
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: climate 0x5c0272fffea131ee climate
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: switch 0x5c0272fffea131ee window_detection, queuing update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0x5c0272fffea131ee linkquality
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: lock 0x5c0272fffea131ee child_lock, queuing update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: climate 0x5c0272fffea131ee climate, queuing update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: sensor 0x5c0272fffea131ee linkquality, queuing update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.mqtt entity: switch.0x5c0272fffea131ee_window_detection
2021-09-18 22:06:16 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 789, in _async_registry_updated
    await self.async_remove()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 722, in async_remove
    await self.async_will_remove_from_hass()
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 607, in async_will_remove_from_hass
    await MqttAvailability.async_will_remove_from_hass(self)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 360, in async_will_remove_from_hass
    self._availability_sub_state = await async_unsubscribe_topics(
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 113, in async_unsubscribe_topics
    return await async_subscribe_topics(hass, sub_state, {})
  File "/usr/src/homeassistant/homeassistant/components/mqtt/subscription.py", line 101, in async_subscribe_topics
    debug_info.remove_subscription(
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 64, in remove_subscription
    hass.data[DATA_MQTT_DEBUG_INFO]["entities"][entity_id]["subscriptions"][
KeyError: 'zigbee2mqtt/bridge/state'
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new lock.mqtt entity: lock.0x5c0272fffea131ee_child_lock
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new climate.mqtt entity: climate.0x5c0272fffea131ee
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.0x5c0272fffea131ee_linkquality
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: lock 0x5c0272fffea131ee child_lock, sending update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: climate 0x5c0272fffea131ee climate, sending update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('lock', '0x5c0272fffea131ee child_lock') '{}'
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: lock.0x5c0272fffea131ee_child_lock
2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'lock.0x5c0272fffea131ee_child_lock'

2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.discovery] Component has already been discovered: switch 0x5c0272fffea131ee window_detection, sending update
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('climate', '0x5c0272fffea131ee climate') '{}'
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: climate.0x5c0272fffea131ee
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Got update for entity with hash: ('switch', '0x5c0272fffea131ee window_detection') '{}'
2021-09-18 22:06:16 INFO (MainThread) [homeassistant.components.mqtt.mixins] Removing component: switch.0x5c0272fffea131ee_window_detection
2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'zigbee2mqtt/bridge/state'

2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'climate.0x5c0272fffea131ee'

2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'switch.0x5c0272fffea131ee_window_detection'

2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'zigbee2mqtt/bridge/state'

2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'zigbee2mqtt/bridge/state'

2021-09-18 22:06:16 ERROR (MainThread) [homeassistant.util.logging] Exception in availability_message_received when handling msg on 'zigbee2mqtt/bridge/state': 'online'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 33, in wrapper
    _log_message(msg)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 23, in _log_message
    messages = debug_info["entities"][entity_id]["subscriptions"][
KeyError: 'switch.0x5c0272fffea131ee_window_detection'

2021-09-18 22:06:31 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"battery_low":null,"child_lock":null,"linkquality":96,"system_mode":"off","window_detection":null}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:31 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":96,"system_mode":"off","window_detection":null}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:31 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":102,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:31 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:31 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:32 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"anti_scaling":"ON","battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":102,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:32 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"anti_scaling":"ON","battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":99,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:32 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","frost_detection":"ON","linkquality":99,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'local_temperature' when rendering '{{ value_json.local_temperature }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:32 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","frost_detection":"ON","linkquality":99,"local_temperature":20.5,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'current_heating_setpoint' when rendering '{{ value_json.current_heating_setpoint }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Could not parse temperature from 
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:32 INFO (MainThread) [homeassistant.components.mqtt.binary_sensor] No matching payload found for entity: 0x5c0272fffea131ee battery low with state topic: zigbee2mqtt/0x5c0272fffea131ee. Payload: '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","current_heating_setpoint":16,"frost_detection":"ON","linkquality":99,"local_temperature":20.5,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}', template output: 'None', with value template 'Template("{{ value_json.battery_low }}")'
2021-09-18 22:06:32 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:32 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
2021-09-18 22:06:33 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'away_mode' when rendering '{{ value_json.away_mode }}'
2021-09-18 22:06:33 ERROR (MainThread) [homeassistant.components.mqtt.climate] Invalid _away mode: 
System Health

version: core-2021.9.6
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.6
os_name: Linux
os_version: 5.10.62
arch: x86_64
timezone: Europe/Berlin


GitHub API: ok
Github API Calls Remaining: 5000
Installed Version: 1.12.4
Stage: running
Available Repositories: 888
Installed Repositories: 7


logged_in: false
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok


host_os: Home Assistant OS 6.4
update_channel: stable
supervisor_version: supervisor-2021.09.0
docker_version: 20.10.7
disk_total: 62.3 GB
disk_used: 19.6 GB
healthy: true
supported: true
board: ova
supervisor_api: ok
version_api: ok
installed_addons: Visual Studio Code (3.6.2), Node-RED (10.0.0), Duck DNS (1.13.0), Terminal & SSH (9.1.3), AdGuard Home (4.1.9), Mosquitto broker (6.0.1), MariaDB (2.4.0), Assistant Relay (0.7.4), Assistant Relay BETA (4.0.0b2), phpMyAdmin (0.5.0), Grafana (7.2.0), InfluxDB (4.2.1), AppDaemon 4 (0.7.0), Samba share (9.5.1), JupyterLab (0.5.0), Zigbee2mqtt (1.21.1-1), Portainer (2.0.0)


dashboards: 1
resources: 5
views: 13
mode: storage

What does the zigbee2mqtt log say ?

I removed the device via Zigbee2mqtt dashboard, restarted home assistant via configuration and then added the device again. This is the zigbee2mqtt logs. To me, they look normal, though configuration did not succeed on first trial.

Info MQTT publish: topic 'homeassistant/switch/0x5c0272fffea131ee/window_detection/config', payload 'null'
Debug Clearing Home Assistant config 'homeassistant/lock/0x5c0272fffea131ee/child_lock/config'
Info MQTT publish: topic 'homeassistant/lock/0x5c0272fffea131ee/child_lock/config', payload 'null'
Debug Clearing Home Assistant config 'homeassistant/climate/0x5c0272fffea131ee/climate/config'
Info MQTT publish: topic 'homeassistant/climate/0x5c0272fffea131ee/climate/config', payload 'null'
Debug Clearing Home Assistant config 'homeassistant/sensor/0x5c0272fffea131ee/linkquality/config'
Info MQTT publish: topic 'homeassistant/sensor/0x5c0272fffea131ee/linkquality/config', payload 'null'
Debug Received MQTT message on 'homeassistant/climate/0x5c0272fffea131ee/climate/config' with data ''
Debug Received MQTT message on 'homeassistant/sensor/0x5c0272fffea131ee/linkquality/config' with data ''
Debug Received MQTT message on 'homeassistant/binary_sensor/0x5c0272fffea131ee/battery_low/config' with data ''
Debug Received MQTT message on 'homeassistant/switch/0x5c0272fffea131ee/window_detection/config' with data ''
Debug Received MQTT message on 'homeassistant/lock/0x5c0272fffea131ee/child_lock/config' with data ''
Debug Received MQTT message on 'homeassistant/climate/0x5c0272fffea131ee/climate/config' with data ''
Debug Received MQTT message on 'homeassistant/sensor/0x5c0272fffea131ee/linkquality/config' with data ''
Info Device '0x5c0272fffea131ee' joined
Info MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"0x5c0272fffea131ee","ieee_address":"0x5c0272fffea131ee"},"type":"device_joined"}'
Info MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"message":{"friendly_name":"0x5c0272fffea131ee"},"type":"device_connected"}'
Debug Device '0x5c0272fffea131ee' announced itself
Info MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"0x5c0272fffea131ee","ieee_address":"0x5c0272fffea131ee"},"type":"device_announce"}'
Info MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"message":"announce","meta":{"friendly_name":"0x5c0272fffea131ee"},"type":"device_announced"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":101,"fn":0,"status":0,"transid":1}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"battery_low":null,"child_lock":null,"linkquality":102,"system_mode":"off","window_detection":null}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":10,"fn":0,"status":0,"transid":23}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":102,"system_mode":"off","window_detection":null}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":8,"fn":0,"status":0,"transid":24}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":105,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":130,"fn":0,"status":0,"transid":25}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":105,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0],"type":"Buffer"},"datatype":2,"dp":27,"fn":0,"status":0,"transid":26}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":null,"child_lock":null,"frost_detection":"ON","linkquality":102,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[1],"type":"Buffer"},"datatype":1,"dp":40,"fn":0,"status":0,"transid":22}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","frost_detection":"ON","linkquality":102,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,208],"type":"Buffer"},"datatype":2,"dp":102,"fn":0,"status":0,"transid":2}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","frost_detection":"ON","linkquality":102,"local_temperature":20.8,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,200],"type":"Buffer"},"datatype":2,"dp":103,"fn":0,"status":0,"transid":3}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":null,"child_lock":"LOCK","current_heating_setpoint":20,"frost_detection":"ON","linkquality":105,"local_temperature":20.8,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0],"type":"Buffer"},"datatype":5,"dp":105,"fn":0,"status":0,"transid":4}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","battery_low":false,"child_lock":"LOCK","current_heating_setpoint":20,"frost_detection":"ON","linkquality":105,"local_temperature":20.8,"local_temperature_calibration":0,"system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":106,"fn":0,"status":0,"transid":5}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","away_mode":"OFF","battery_low":false,"child_lock":"LOCK","current_heating_setpoint":20,"frost_detection":"ON","linkquality":102,"local_temperature":20.8,"local_temperature_calibration":0,"preset_mode":"none","system_mode":"off","window_detection":"ON"}'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0],"type":"Buffer"},"datatype":1,"dp":108,"fn":0,"status":0,"transid":7}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":123,"fn":0,"status":0,"transid":255}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":124,"fn":0,"status":1,"transid":0}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":125,"fn":0,"status":1,"transid":1}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":126,"fn":0,"status":1,"transid":2}' from endpoint 1 with groupID 0
Error Failed to configure '0x5c0272fffea131ee', attempt 1 (Error: Bind 0x5c0272fffea131ee/1 genBasic from '0x00124b002298958c/1' failed (AREQ - ZDO - bindRsp after 10000ms) at Timeout._onTimeout (/app/node_modules/zigbee-herdsman/src/utils/waitress.ts:64:35) at listOnTimeout (internal/timers.js:557:17) at processTimers (internal/timers.js:500:7))
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Info Configuring '0x5c0272fffea131ee'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":127,"fn":0,"status":1,"transid":3}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'read', cluster 'genTime', data '["localTime"]' from endpoint 1 with groupID 0
Info Successfully configured '0x5c0272fffea131ee'
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'read', cluster 'genTime', data '["localTime"]' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":128,"fn":0,"status":1,"transid":4}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[4,1,104,0,200,1,224,0,160,4,56,0,200,5,40,0,160],"type":"Buffer"},"datatype":0,"dp":129,"fn":0,"status":1,"transid":5}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":115,"fn":0,"status":0,"transid":9}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":110,"fn":0,"status":0,"transid":13}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":119,"fn":0,"status":0,"transid":17}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":116,"fn":0,"status":0,"transid":10}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":112,"fn":0,"status":0,"transid":14}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":120,"fn":0,"status":0,"transid":18}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandSetTimeRequest', cluster 'manuSpecificTuya', data '{"payloadSize":1792}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":116,"fn":0,"status":0,"transid":10}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":117,"fn":0,"status":0,"transid":11}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":113,"fn":0,"status":0,"transid":15}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":121,"fn":0,"status":0,"transid":19}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":118,"fn":0,"status":0,"transid":12}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":114,"fn":0,"status":0,"transid":16}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,0,0,0,0,0,0,0,0,0],"type":"Buffer"},"datatype":0,"dp":122,"fn":0,"status":0,"transid":20}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'raw', cluster 'manuSpecificTuya', data '{"data":[9,33,17,0,10,64],"type":"Buffer"}' from endpoint 1 with groupID 0
Debug Received Zigbee message from '0x5c0272fffea131ee', type 'commandGetData', cluster 'manuSpecificTuya', data '{"data":{"data":[0,0,0,200],"type":"Buffer"},"datatype":2,"dp":103,"fn":0,"status":0,"transid":3}' from endpoint 1 with groupID 0
Info MQTT publish: topic 'zigbee2mqtt/0x5c0272fffea131ee', payload '{"anti_scaling":"ON","away_mode":"OFF","battery_low":false,"child_lock":"LOCK","current_heating_setpoint":20,"frost_detection":"ON","linkquality":93,"local_temperature":20.8,"local_temperature_calibration":0,"preset_mode":"none","system_mode":"off","window_detection":"ON"}'

The entities get added, but two of them are unavailable.

And no device gets added

Did you ever resolve this? I’m seeing something similar and would love the clues. =)