Hi,
I’m having trouble with Home Assistant not auto discovering my MQTT devices. I set up an external broker and the HA MQTT integration about a year ago and got the auto discovery to work correctly. I recently noticed, that the discovery doesn’t work properly anymore but can’t figure out why. No device or entity gets created when HA receives a discovery message.
Here’s my setup:
My Home Assistant runs on a Raspberry Pi 4, inside a docker container. On the same machine I run an MQTT broker (Mosquitto) inside another container. My device I’m trying to discover is an Arduino, which runs an MQTT client.
The Arduino publishes a discovery topic which shows up in MQTT Explorer as
homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36/config
{
"~": "homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36",
"name": "ledStrip_C72044AA50573738352E3120FF111B36",
"uniq_id": "ledStrip_C72044AA50573738352E3120FF111B36",
"cmd_t": "~/set",
"stat_t": "~/state",
"schema": "json",
"brightness": true,
"retain": true,
"color_mode": true,
"supported_color_modes": [
"hs"
],
"effect": "SlowBreathingWave",
"fx_list": [
"SlowBreathingWave",
"ChristmasSparkle"
]
}
In Home Assistant I’ve added and configured the MQTT extension to connect to my broker.
As far as I can tell, Home assistant connects to the MQTT broker correctly. When I listen to the “homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36/config” topic in Home Assistant, I can see the messages.
This is what my configuration.yaml looks like:
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
logger:
default: critical
logs:
homeassistant.components.mqtt: debug
#mqtt:
# discovery: true
# discovery_prefix: homeassistant
Note the MQTT section, which was previously required. I received deprecation warnings from HA, so I commented the lines out. Apparently those settings are now handled by the MQTT integration UI.
My Home Assistant logs show the following messages when I restart my Arduino to resend the discovery topic:
2023-04-22 09:30:41.339 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36/config (qos=0): b'{"~":"homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36","name":"ledStrip_C72044AA50573738352E3120FF111B36","uniq_id":"ledStrip_C72044AA50573738352E3120FF111B36","cmd_t":"~/set","stat_t":"~/state","schema":"json","brightness":true,"retain":true,"color_mode":true,"supported_color_modes":["hs"],"effect":"SlowBreathingWave","fx_list":["SlowBreathingWave","ChristmasSparkle"]}'
2023-04-22 09:30:41.340 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process discovery payload {'name': 'ledStrip_C72044AA50573738352E3120FF111B36', 'unique_id': 'ledStrip_C72044AA50573738352E3120FF111B36', 'command_topic': 'homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36/set', 'state_topic': 'homeassistant/light/ledStrip_C72044AA50573738352E3120FF111B36/state', 'schema': 'json', 'brightness': True, 'retain': True, 'color_mode': True, 'supported_color_modes': ['hs'], 'effect': 'SlowBreathingWave', 'effect_list': ['SlowBreathingWave', 'ChristmasSparkle'], 'platform': 'mqtt'}
2023-04-22 09:30:41.340 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: light ledStrip_C72044AA50573738352E3120FF111B36
2023-04-22 09:30:41.358 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('light', 'ledStrip_C72044AA50573738352E3120FF111B36'): deque([])
So, it seems to me that Home Assistant sees the discovery topic, but ultimately never executes the discovery to create an entity.
I’ve updated Home Assistant (currently running 2023.4.6 Frontend 20230411.1 - latest), removed and reinstalled the MQTT integration and restarted HA several times.
Have I misconfigured something? Any ideas why the discovery doesn’t work? Feedback is much appreciated.
Thanks!