core icon indicating copy to clipboard operation
core copied to clipboard

Component Snips can’t subscribe to MQTT at startup

Open diplix opened this issue 2 years ago • 4 comments

The problem

After upgrading to 2022.11.0 and restarting, the first logged Error is that the integration snips could not be initialized: Cannot subscribe to topic 'hermes/intent/#', MQTT is not enabled

Seems to me that snips is trying to initialize very early, when mqtt is not ready yet. It worked fine with core-2022.11.0b2.

Bildschirmfoto 2022-11-02 um 23 57 12

What version of Home Assistant Core has the issue?

core-2022.11.0 and beta versions > core-2022.11.0b2

What was the last working version of Home Assistant Core?

core-2022.11.0b2

What type of installation are you running?

Home Assistant Core

Integration causing the issue

mqtt, snips

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

snips:
  probability_threshold: 0.089
  site_ids: ivanka, ivan, juri

mqtt is fully configured via frontend.

Anything in the logs that might be useful for us?

Cannot subscribe to topic 'hermes/intent/#', MQTT is not enabled

Additional information

No response

diplix avatar Nov 02 '22 23:11 diplix

could not reproduce this in a clean install. however on my main installation, mqtt does take 47 to 49 seconds to load. home assistant managed to startup once without the snips initialisation error mentioned above. i failed to check the mqtt startup time for that session, but i suspect:

if initializing mqtt does take more than a certain amount of time (> 45 seconds), snips fails to initialize during home assistant setup:

Logger: homeassistant.setup
Source: components/mqtt/client.py:196
First occurred: 01:24:28 (1 occurrences)
Last logged: 01:24:28

Error during setup of component snips
Traceback (most recent call last):
  File "/home/homeassistant/homeassistant_p3.10/lib/python3.10/site-packages/homeassistant/setup.py", line 235, in _async_setup_component
    result = await task
  File "/home/homeassistant/homeassistant_p3.10/lib/python3.10/site-packages/homeassistant/components/snips/__init__.py", line 162, in async_setup
    await mqtt.async_subscribe(hass, INTENT_TOPIC, message_received)
  File "/home/homeassistant/homeassistant_p3.10/lib/python3.10/site-packages/homeassistant/components/mqtt/client.py", line 196, in async_subscribe
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Cannot subscribe to topic 'hermes/intent/#', MQTT is not enabled

same behavior in core-2022.11.1 reverting to core-2022.11.0b2 still avoids the problem.

diplix avatar Nov 04 '22 00:11 diplix

i could work around the problem by adding components/snips to custom_components/snips. this seems to force initialisation of the snips integration to start later during startup.

diplix avatar Nov 04 '22 00:11 diplix

I read that MQTT is optional. If the built-in MQTT integration is not setup first then mqtt.async_subscribe will fail. May we we should just log a warning instead of failing the setup if MQTT is not configured.

jbouwh avatar Nov 07 '22 15:11 jbouwh

Linked PR #81733 should await loading the MQTT entry to be loaded before setting up the snips integration.

jbouwh avatar Nov 09 '22 07:11 jbouwh

Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (mqtt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mqtt can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign mqtt Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


mqtt documentation mqtt source (message by IssueLinks)

home-assistant[bot] avatar Nov 09 '22 07:11 home-assistant[bot]