New devices from Zigbee2MQTT not discovered in HA

I run HAOS on an x86 mini PC.

My Zigbee coordinator is an SLZB-06 connected to the router via ethernet.

My HA supervisor and core are up to date as of this morning.

I have configured Mosquitto and Zigbee2MQTT successfully and have added about 10 devices over the last few weeks. They are properly exposed, can be controlled via Z2M or via HA without problem.

Last week I wanted to control (via HA) an Ikea Styrbar remote and ran into issues. I decided to remote it from HA and from Z2M and add it again. It was added to Z2M but not discovered in HA. I will point out that there is a loose time correlation between the last HA core/supervisor updates and this problem, but I’m far from confident they are correlated (I think Z2M problems started before but I want to mention all possible links). (also, this morning I updated core to its newest version in the hope of fixing things).

I read all I could on the web to try and understand the problem, rebooted Mosquitto, Z2M, HA multiple times.

Yesterday I realized the problem was deeper than just the Styrbar. I wanted to add a Sonoff ZB Mini R2 relay. Again, properly detected and controlled via Z2M, but not discovered by HA. So the problem is somewhere in-between.

Again I did my homework. Most of the info on the web dates from 2 years or so, and lots have changed since then, sadly, so the content is rarely relevant.

Here’s what I know. First, my Z2M configuration.yaml file (I confirmed that homeassistant is enabled as you can see):

version: 4
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://core-mosquitto:1883
  user: xxx
  password: xxx
serial:
  port: tcp://192.168.xxxxxxxxxx
  baudrate: 115200
  adapter: zstack
  disable_led: false
advanced:
  log_level: info
  channel: 11
  network_key:
    - 246
    - 217
    - 246
    - 225
    - 243
    - 212
    - 142
    - 103
    - 26
    - 17
    - 178
    - 211
    - 241
    - 2
    - 203
    - 103
  pan_id: 39593
  ext_pan_id:
    - 73
    - 18
    - 28
    - 218
    - 58
    - 106
    - 63
    - 123
frontend:
  enabled: true
  port: xxxx
homeassistant:
  enabled: true
  legacy_action_sensor: true
  discovery_topic: HomeAssistant
  base_topic: zigbee2mqtt
  force_disable_retain: false
  include_device_information: false
  keepalive: 60
  maximum_packet_size: 1048576
  reject_unauthorized: true
  server: mqtt://core-mosquitto:1883
  user: xxxx
  version: 4
  experimental_event_entities: true

In Z2M, going to Settings and then the Home Assistant tab, when trying to make changes (such as allowing experimental options) and clicking Submit, I get this message

z2m: Request ‘zigbee2mqtt/bridge/request/options’ failed with error: ‘Extension with name HomeAssistant already present’

That’s not good!

When I added the Sonoff relay yesterday evening, here’s what the Mosquitto log says:

[18:31:08] INFO: Successfully send discovery information to Home Assistant.
[18:31:09] INFO: Successfully send service information to the Supervisor.

However, when toggling any Z2M device (the un-discovered Sonoff or another, properly discovered device) I see this

2025-04-25 08:18:38: New connection from 172.30.33.3:57610 on port 1883.
2025-04-25 08:18:38: New client connected from 172.30.33.3:57610 as mqttjs_c497cd50 (p2, c1, k60, u'(username)').
2025-04-25 08:19:42: New connection from 172.30.32.2:41520 on port 1883.
2025-04-25 08:19:42: Client <unknown> closed its connection.

Note that the last two lines appear everytime I do something to any Zigbee device, and has been doing so ever since I started using my concentrator.

I’m at my wits’ end. Discovery was working perfectly, until it suddenly didn’t. I wonder if I broke something when I force removed the remote from Home Assistant.

I will point out that I have verified my Mosquitto syntax and configuration countless times, it’s properly configured according to the doc, and I changed nothing at all since it first worked.

Any help will be more than welcome.

Have you checked in the MQTT integration that the devices are present and do not have a _2 in the entity names?

Do you mean going into

Settings - Devices & Services - Integrations / MQTT - Devices

If so, I have looked there, and the new devices do not show up. Devices added about two weeks ago do show, newer devices don’t.

Did you intentionally set the discovery topic in your config to the capitalized version HomeAssistant? The default auto discovery topic used by HA is homeassistant and it is case sensitive.

homeassistant:
  discovery_topic: homeassistant

If you intentionally changed it, it needs to be changed in HA’s MQTT configuration to match.

1 Like

I don’t remember changing it, but I might have, I guess? Or just writing it this way? As shown in my first post, the syntax matches:

discovery_topic: HomeAssistant

Also, that has not been changed or edited since first setting up my Z2M initially.

That being said, someone else recommended installing MQTT Explorer, which I did, and I see an entry for “homeassistant” and an entry for “HomeAssistant”. The new relay that’s missing shows in the latter, not the former:

Again, I changed nothing on my side. If I don’t risk messing up my currently working setup, I don’t mind changing the uppercases, but since the working relays are inside switchboxes at the moment, and part of integrations, I’m really not keen on restarting everything and loosing my current working devices.

You have two options: change the z2m configuration to reflect all lowercase homeassistant or else go into HA and reconfigure the MQTT integration to use the HomeAssistant topic.

I would recommend the former, because there are other integrations besides z2m that utilize autodiscovery, and they would each need to be customized for the custom TitleCase autodiscovery topic.

You shouldn’t have to do anything else after changing the config and restarting z2m.

Thanks again for the help.

So I change it in Z2M here:

And change it also in HA here in Z2M’s configuration file:

Capture d’écran 2025-04-25 115156

Restart Z2M and I’m done?

I’m willing to do that. Still wondering why things stopped working to discover new devices.

Yes that should do it.

There was a big z2m update a little while ago that contained many breaking changes (changed from version 1.x to version 2.x). Perhaps your issue was related to that.

Awesome, it worked! Thanks a bunch. I replaced the uppercases with lowercases in the two areas, restarted the Zigbee2MQTT add-on (not just restarting from its interface, but restarting the whole add-on) and also restarted HA. The Sonoff relay showed up immediately. For good measure I added also the Styrbar, it also showed up and now it exposes its actions, which it didn’t do previously.

I can’t say I understand why the uppercases mess up with stuff, and how updates/timings come into play, but at least I have a working solution.

Thanks for the help.