home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.56k stars 29.48k forks source link

OwnTracks: Cannot subscribe to topic 'owntracks/#' #121753

Open syphernl opened 1 month ago

syphernl commented 1 month ago

The problem

I use several trackers to determine my location. I noticed that for the past few HomeAssistant releases (probably going back at least 2~3 months) my OwnTracks status seems to be stuck at "Home" and hasn't registered any moments I have been away. The integration shows no errors whatsoever, but in the logs there is one mention of OwnTracks (see below) which is probably the cause for this.

It appears that the OwnTracks integration doesn't make attempts to retry when it encounters this error. When I manually reload the integration entry it works again.

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

OwnTracks

Link to integration documentation on our website

https://www.home-assistant.io/integrations/owntracks/

Diagnostics information

No response

Example YAML snippet

owntracks:
  max_gps_accuracy: 200
  mqtt_topic: "owntracks/#"

Anything in the logs that might be useful for us?

Logger: homeassistant.setup
Source: setup.py:602
First occurred: July 10, 2024 at 13:52:25 (1 occurrences)
Last logged: July 10, 2024 at 13:52:25

Error handling when_setup callback for mqtt
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 220, in async_subscribe_internal
    mqtt_data = hass.data[DATA_MQTT]
                ~~~~~~~~~^^^^^^^^^^^
KeyError: 'mqtt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 602, in when_setup
    await when_setup_cb(hass, component)
  File "/usr/src/homeassistant/homeassistant/components/owntracks/__init__.py", line 151, in async_connect_mqtt
    await mqtt.async_subscribe(hass, context.mqtt_topic, async_handle_mqtt_message, 1)
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 199, in async_subscribe
    return async_subscribe_internal(hass, topic, msg_callback, qos, encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/mqtt/client.py", line 222, in async_subscribe_internal
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Cannot subscribe to topic 'owntracks/#', make sure MQTT is set up correctly

Additional information

It claims my "MQTT may not be set up correctly". It actually is working just fine, all of my other MQTT-based integrations (e.g. Zigbee2MQTT with many devices) work just fine.

home-assistant[bot] commented 1 month ago

owntracks documentation owntracks source

waldmeisterx commented 1 month ago

Same error here, too. Manually accessing the topic owntracks/# with the MQTT integration works with no error.