#Custom mqtt integration times out on startup when mqtt discovery is enabled.

6 messages · Page 1 of 1 (latest)

fathom trellis
#

Hi, I've created a custom integration that requires MQTT.
This integration subscribes on a MQTT response topic at startup.
After subscription, it also publishes a request on a topic and then wait for the reply on the response topic.
This works perfectly and during the startup, the initial data is being published and read from the response topic, so the sensors are properly populated. (using coordinator.async_config_entry_first_refresh in __init__.py
There is a timeout defined of 10s for the answer, but the initial call works perfectly, but ONLY when MQTT discovery is disabled.
From the moment the MQTT discovery is enabled, the initial setup is always timing out after those 10s (timeout in coordinator.async_config_entry_first_refresh() in __init__.py).
After the next scan interval, the sensors are properly populated.
Does someone have any idea why this is only working when MQTT discovery is disabled.
Or why it's not working van MQTT discovery is enabled?

fathom trellis
#

If I put a delay in the __init__.py of f.e. 30s (until the discovery is certainly finished), the coordinator.async_config_entry_first_refresh() does not longer time out... So it's really the discovery that seems to block it... Any suggestions on how to get around this?

fathom trellis
#

It seems that the discovery triggers a lot of subscriptions and my subscription seems to be only accepted after the discovery ends...

#

Is there maybe a way to wait for MQTT client initialized, birth message sent before setting up my integration?

#

Or can we delay the discovery so my subscription is handled first?

dusty cipher