Mqtt auto discovery doesn't work

Hello,
I’m using zigebee2mqtt and mosquitto mqtt-broker in my smarthome setup since a long time. Both applications are running as a docker-container.

Now I started to work with Home Assistant. HA is running on a synology NAS as a virtual machine. I installed the mosquitto addon successfully. I am able to listen to all topics on the mqtt-broker, but the auto discovery doesn’t work.

No device can be found.

So, can anybody help me to start auto discovery?

Thanks for your help in advance. - Best regards - Daniel

There is a MQTT addon for creating a broker, and a MQTT integration for connecting home assistant to the broker. You should be able to link the Integration to your existing external MQTT broker if you don’t want to use the addon Broker.

Did you configure the integration under settings > devices & services

Hi, thanks for your fast reply.
I already use the MQTT addon, and I was able to connect to my MQTT broker. I use a separate username and password to connect to the MQTT broker. - If listen to the MQTT broker (# - on the first page of the settings) I can see all topics. On the second page of the settings, I did choose my Discovery-praefix.

Everything seems to configured well, Home Assistant can find no devices. - Auto discovery does not work.

Does this topic show up?

zigbee2mqtt/bridge/#

Do you have the correct broker in here?
zigbee2mqtt/configuration.yaml

“mqtt”: {
“base_topic”: “zigbee2mqtt”,
“server”: “mqtt://YourBroker:1883”,
“user”: “YourUser”, ### should be different to the homeassistant user
“password”: “YourPW”
},

Did you choose homeassistant as the prefix?

Not sure if it actually matters anymore, but it used to be that you would need to setup a secondary user

So in the integration It would be user homeassistant

Capture

And then in the MQTT addon you add a secondary user and password in the options.
Which would be equal to YouUser and YourPass in the zigbee2mqtt config.yaml

Capture

Any errors in the logs of Homeassistant, zigbee2mqtt, or the mqtt broker?

Hi, yes the following topic shows me all the content, I can also find in MQTT-Explorer.

zigbee2mqtt/bridge/#

My MQTT-Broker could be found under “local-IP:1883”. This is the right one, where z2m publishes all the devices and topics.

The prefix I specified is “zigbee2mqtt”. This is the “base_topic” of z2m.

I have specially created a secondary user (ha_mqtt) with an own password. The user has full access to all data of the MQTT-Broker. (I checked this with MQTT-Explorer.)

The access permissions in the Mosquitto broker addon are set as well.

I got no errors in the logs.

I tried to find some help on the zigbee2mqtt-page:
https://www.zigbee2mqtt.io/guide/usage/integrations/home_assistant.html#mqtt-discovery

But in my opinion I did the necessary steps, that are described there. I can not understand why auto discovery doesn’t find any result. (My setup contains about 20 devices)

2 Likes

The prefix is homeassistant for the mqtt integration.

Zigbee2mqtt sets it own prefix in its z2m/configuration.yaml

Try a host reboot too.


You can use the last post(post 13) in this link to test a discovery message with mqtt-Explorer (when the prefix is homeassistant)

https://community.home-assistant.io/t/mqtt-discovery-allow-setting-the-entity-id-via-disovery-message/203186/13?u=hasqt

It sounds like you already were using an MQTT broker before you started using HA. Is that correct?

if so then you don’t need the MQTT add-on since that will only create a new MQTT broker on your network. Which you shouldn’t need since you already have one.

remove the MQTT add-on and configure the HA MQTT integration to use your old previously existing MQTT broker.

then make sure you set the MQTT discovery topic correctly.

Dear Daniel, I think I have the same issue.
Were you able to resolve it?

Docker environment with separate Mosquitto, Homeassistant and Zigbee2mqtt containers.
When I use a MQTT client, I can see that Zigbee2mqtt fires the right messages on MQTT.
Home assistant meanwhile can’t discover them. But home assistant is connected to the broker as well.

Really curious as to why this is…

Best regards

Just came here to say… I’m having the same issue too.

zigbee2mqtt > MQTT broker (have tried the add-on built in to HA and EMQX, same result) > HA MQTT Client connects, but says devices are unavailable.

Hi,

Same here, MQTT Explorer is OK, I can also form MQTT Integration listen to my broker, and see the message display but no entity are showing up.

I tried to add by hand a basic light into the configuration.yaml, quick restart HA to reread the yaml and my light came up as entity and I can switch it ON or OFF.

Running in to this issue as well.

I see the remote HA events/states change on the broker(on main HA) via MQTT Explorer when testing, but the main HA is not discovering. Also to note, can see both MQTT clients and Explorer connected to the broker.

Main HA:

  • Broker Add-On
  • MQTT Add-On
mqtt_statestream:
  base_topic: homeassistant

Remote HA:

  • MQTT Add-On
  • MQTT Statestream
mqtt_statestream:
  base_topic: homeassistant
  include:
    domains:
      - sensor
      - binary_sensor