[Solved] Multiple Zigbee2MQTT Instances truncate the other's devices

The Problem:
I added a Zigbee coordinator on my hass instance to run Z2M as an add-on. I have added the presence sensors within Z2M and they seem well connected with quick state updates.

So this one’s really frustrating me because I have my Valetudo operating just fine on MQTT as well as an old instance of Zigbee2MQTT on a pi 1 running in side my shed. (no issues).

As mentioned, I can restart the Z2M add-on and the logs will show a whole bunch of activity like the logs at the end, but after adding it, it decides to remote it! I’ve tried setting the logs to debug level, but it just won’t tell me why it’s thought to delete it.

2024-10-23 19:32:51.373 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('binary_sensor', '1221051039810110150109113116116_0x00124b000be876f7 connection_state') '{'device': {'hw_version': 'zStack3x0 20210708', 'identifiers': ['zigbee2mqtt_bridge_0x00124b000be876f7'], 'manufacturer': 'Zigbee2MQTT', 'model': 'Bridge', 'sw_version': '1.40.2', 'name': 'Zigbee2MQTT Bridge'}, 'device_class': 'connectivity', 'entity_category': 'diagnostic', 'object_id': 'zigbee2mqtt_bridge_connection_state', 'origin': {'sw_version': '1.40.2', 'support_url': 'https://www.zigbee2mqtt.io', 'name': 'Zigbee2MQTT'}, 'payload_off': 'offline', 'payload_on': 'online', 'state_topic': 'zigbee2mqtt/bridge/state', 'unique_id': 'bridge_0x00124b000be876f7_connection_state_zigbee2mqtt', 'value_template': '{{ value }}', 'name': 'Connection state', 'platform': 'mqtt'}'
2024-10-23 19:32:51.374 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Ignoring unchanged update for: binary_sensor.zigbee2mqtt_bridge_connection_state
2024-10-23 19:32:51.375 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 1221051039810110150109113116116_0x00124b000be876f7 restart_required from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.417 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: button 1221051039810110150109113116116_0x00124b000be876f7 restart from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.417 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new button.mqtt entity: button.zigbee2mqtt_bridge_restart
2024-10-23 19:32:51.459 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: select 1221051039810110150109113116116_0x00124b000be876f7 log_level from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.460 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new select.mqtt entity: select.zigbee2mqtt_bridge_log_level
2024-10-23 19:32:51.500 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 1221051039810110150109113116116_0x00124b000be876f7 version from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.501 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.zigbee2mqtt_bridge_version
2024-10-23 19:32:51.511 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('button', '1221051039810110150109113116116_0x00124b000be876f7 restart') '{}'
2024-10-23 19:32:51.511 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: button.zigbee2mqtt_bridge_restart
2024-10-23 19:32:51.544 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 1221051039810110150109113116116_0x00124b000be876f7 coordinator_version from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.584 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 1221051039810110150109113116116_0x00124b000be876f7 network_map from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.627 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 1221051039810110150109113116116_0x00124b000be876f7 permit_join_timeout from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.629 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.zigbee2mqtt_bridge_permit_join_timeout
2024-10-23 19:32:51.667 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('select', '1221051039810110150109113116116_0x00124b000be876f7 log_level') '{}'
2024-10-23 19:32:51.667 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: select.zigbee2mqtt_bridge_log_level
2024-10-23 19:32:51.676 INFO (MainThread) [homeassistant.components.switch] Setting up mqtt.switch
2024-10-23 19:32:51.677 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: switch 1221051039810110150109113116116_0x00124b000be876f7 permit_join from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.679 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.mqtt entity: switch.zigbee2mqtt_bridge_permit_join
2024-10-23 19:32:51.687 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: binary_sensor 0xa4c13817b9c39107 presence from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.688 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.mqtt entity: binary_sensor.test_presence_presence
2024-10-23 19:32:51.713 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('sensor', '1221051039810110150109113116116_0x00124b000be876f7 version') '{}'
2024-10-23 19:32:51.713 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: sensor.zigbee2mqtt_bridge_version
2024-10-23 19:32:51.723 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 presence_state from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.724 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_presence_state
2024-10-23 19:32:51.764 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 target_distance from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.766 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_target_distance
2024-10-23 19:32:51.809 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 illuminance_lux from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.811 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_illuminance_lux
2024-10-23 19:32:51.849 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: switch 0xa4c13817b9c39107 switch_indicator from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.850 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.mqtt entity: switch.test_presence_indicator
2024-10-23 19:32:51.890 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 none_delay_time from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.892 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_none_delay_time
2024-10-23 19:32:51.925 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('sensor', '1221051039810110150109113116116_0x00124b000be876f7 permit_join_timeout') '{}'
2024-10-23 19:32:51.925 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: sensor.zigbee2mqtt_bridge_permit_join_timeout
2024-10-23 19:32:51.938 INFO (MainThread) [homeassistant.components.number] Setting up mqtt.number
2024-10-23 19:32:51.939 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: number 0xa4c13817b9c39107 none_delay_time from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.940 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new number.mqtt entity: number.test_presence_none_delay_time
2024-10-23 19:32:51.972 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('switch', '1221051039810110150109113116116_0x00124b000be876f7 permit_join') '{}'
2024-10-23 19:32:51.972 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: switch.zigbee2mqtt_bridge_permit_join
2024-10-23 19:32:51.974 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 move_detection_max from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:51.975 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_move_detection_max
2024-10-23 19:32:52.005 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('binary_sensor', '0xa4c13817b9c39107 presence') '{}'
2024-10-23 19:32:52.005 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: binary_sensor.test_presence_presence
2024-10-23 19:32:52.014 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: number 0xa4c13817b9c39107 move_detection_max from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:52.016 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new number.mqtt entity: number.test_presence_move_detection_max
2024-10-23 19:32:52.057 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 move_detection_min from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:52.058 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_move_detection_min
2024-10-23 19:32:52.065 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('sensor', '0xa4c13817b9c39107 presence_state') '{}'
2024-10-23 19:32:52.065 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: sensor.test_presence_presence_state
2024-10-23 19:32:52.111 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: number 0xa4c13817b9c39107 move_detection_min from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:52.113 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new number.mqtt entity: number.test_presence_move_detection_min
2024-10-23 19:32:52.114 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('sensor', '0xa4c13817b9c39107 target_distance') '{}'
2024-10-23 19:32:52.114 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: sensor.test_presence_target_distance
2024-10-23 19:32:52.119 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: sensor 0xa4c13817b9c39107 small_move_detection_max from external application Zigbee2MQTT, version: 1.40.2, support URL: https://www.zigbee2mqtt.io
2024-10-23 19:32:52.120 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.mqtt entity: sensor.test_presence_small_move_detection_max
2024-10-23 19:32:52.151 DEBUG (MainThread) [homeassistant.components.mqtt.entity] Got update for entity with hash: ('sensor', '0xa4c13817b9c39107 illuminance_lux') '{}'
2024-10-23 19:32:52.151 INFO (MainThread) [homeassistant.components.mqtt.entity] Removing component: sensor.test_presence_illuminance_lux
2024-10-23 19:32:52.153 INFO (MainThread) 

After a hunch, I killed the secondary (external) Z2M instance, and restarted the add-on. The devices stayed.

I’m a bit confused, people have reported running multiple Z2M instances. Given many different devices use the same Mosquitto broker… it’s a bit perplexing why there should be an issue.

You need to change the topic prefix for at least one of the instances in the Z2M settings.

1 Like

Thanks, I have done this and it indeed solves it.