Zigbee2mqtt - what is the secret to Z2M device discovery?

hi all - HA, MQTT, Zibgee2MQTT, device firmware and pairing are ALL GOOD!

The problem is: the devices still do not display in HA! In HA you can see the messages being received loud and clear on homeassistant topic. what am I missing?

My setup:

debian host
Docker with all separate containers: HA, Mosquitto, zigbee2mqtt, frigate, and others
Sonoff Dongle-E - nicely working in zigbee2mqtt
zigbee2mqtt definitely has homeassistant: true

inside homeassistant in the MQTT configuration: “listen to a topic” - the device is clearly visible.

See screenshots below…
I seem to be at the last hurdle!!!
what am I missing???

Homeassistant is clearly talking to MQTT

However in the mqtt integration no new entities or devices. what gives?

Not sure I can tell you why, but do you see the entities in the MQTT integration? that should be the first start to ensure that MQTT sees them

thanks, that is exactly the issue, entities are not appearing, only those entities from the coordinator itself:

here is zigbee2mqtt logs:

<small>2025-02-02 10:39:15</small>`z2m:mqtt: MQTT publish: topic 'homeassistant/binary_sensor/1221051039810110150109113116116_0x8c65a3fffe522bab/connection_state/config', payload '{"device":{"hw_version":"EmberZNet 7.4.5 [GA]","identifiers":["zigbee2mqtt_bridge_0x8c65a3fffe522bab"],"manufacturer":"Zigbee2MQTT","model":"Bridge","name":"Zigbee2MQTT Bridge","sw_version":"2.0.0"},"device_class":"connectivity","entity_category":"diagnostic","name":"Connection state","object_id":"zigbee2mqtt_bridge_connection_state","origin":{"name":"Zigbee2MQTT","sw":"2.0.0","url":"https://www.zigbee2mqtt.io"},"payload_off":"offline","payload_on":"online","state_topic":"zigbee2mqtt/bridge/state","unique_id":"bridge_0x8c65a3fffe522bab_connection_state_zigbee2mqtt","value_template":"{{ value_json.state }}"}'`

info <small>2025-02-02 10:45:22</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":84,"power_on_behavior":"off","state":"OFF","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 10:47:19</small>`z2m: Connected to MQTT server`

info <small>2025-02-02 10:47:19</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload '{"state":"online"}'`

info <small>2025-02-02 10:48:03</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":84,"power_on_behavior":"off","state":"OFF","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 11:39:10</small>`zh:ember: [NCP COUNTERS] 0,476,5908,3,2,0,2,2,1,1,0,0,61,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`

info <small>2025-02-02 11:39:10</small>`zh:ember: [ASH COUNTERS] 373,79,36,42,0,0,0,0,494,42,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0`

info <small>2025-02-02 12:19:47</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":68,"power_on_behavior":"off","state":"ON","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 12:36:55</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":84,"power_on_behavior":"off","state":"OFF","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 12:39:10</small>`zh:ember: [NCP COUNTERS] 0,467,5938,0,0,0,0,0,2,0,0,0,60,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0`

info <small>2025-02-02 12:39:10</small>`zh:ember: [ASH COUNTERS] 5,4,1,3,0,0,0,0,149,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0`

info <small>2025-02-02 13:35:03</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":64,"power_on_behavior":"off","state":"ON","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 13:35:32</small>`z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Basement_Lightswitch', payload '{"linkquality":36,"power_on_behavior":"off","state":"OFF","update":{"installed_version":4110,"latest_version":4110,"state":"idle"}}'`

info <small>2025-02-02 13:39:10</small>`zh:ember: [NCP COUNTERS] 0,469,5947,0,0,0,0,0,2,0,0,0,60,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`

info <small>2025-02-02 13:39:10</small>`zh:ember: [ASH COUNTERS] 5,4,1,3,0,0,0,0,149,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0`

Very strange indeed. In your log you can see Zigbee2MQTT is connected to the MQTT broker. Have you tried uninstalling and re-installing the MQTT broker (just a thought as I am not sure here what else could be wrong)…the 8 entities you have I also have aside from the devices…

I have tried deleting the MQTT integration (no luck)
also tried deleting and re-pairing the device in z2m (no luck)

Possiblities

  • is Z2M publishing the correct discovery message or am I missing some z2m config?
  • Do I need to manually configure the device in yaml or manually publish a discovery message?

No, you should not need to trigger manually.
One thing: You have not activated ZHA, did you? it should be either Zigbee2Mqtt or ZHA

That’s right, not running ZHA.

What version of HA are you running ? HA MQTT discovery is picky about the structure of the discovery messages.

Release 2.0.0 · Koenkk/zigbee2mqtt · GitHub :
For Home Assistant users: this version requires at least Home Assistant 2024.9

hi Francis,

I’m on 2024.5.1. I will try and upgrade, looks like I never have! I am also thinking for some reason maybe there is not a discovery message from the sonoff at least I cannot see it when I subscribe to the topic. What if HA has missed the initial discovery message - do I need to try and repair?

I am seeing MQTT messages from the sonoff though, i.e. whenever someone toggles it. This is not a discovery message though as I gather.

Action Plan:

  • upgrade / retest
  • re-pair the device (new discovery message?) / retest
homeassistant/device_automation/0x0ceff6fffe4a6bd9/action_off/config at 5:44 PM:

{"automation_type":"trigger","device":{"identifiers":["zigbee2mqtt_0x0ceff6fffe4a6bd9"],"manufacturer":"SONOFF","model":"Zigbee smart switch (no neutral)","model_id":"ZBMINIL2","name":"Basement_Lightswitch","sw_version":"1.0.14","via_device":"zigbee2mqtt_bridge_0x8c65a3fffe522bab"},"origin":{"name":"Zigbee2MQTT","sw":"2.0.0","url":"https://www.zigbee2mqtt.io"},"payload":"off","subtype":"off","topic":"zigbee2mqtt/Basement_Lightswitch/action","type":"action"}

Solved.
Portainer, recreate, pull latest, 2 minutes later the switch magically appeared in home assistant!

thanks guys

image

1 Like