I need some help with MQTT as it is behaving strangely after the core-2021.9.1 update. Auto-discover just works the first time a device is added, and if you need to reboot the device it will never become again in Home Assistant
What is happening:
Auto-discovery devices never come back after they go through a power cycle. If I have an auto-discovered device that needs to be rebooted it will never come online again, all it entities will remain unavailable.
What I did to try to fix it:
- I deleted the auto-discovered device from Home Assistant and rebooted Home Assistant, and the device wasn’t rediscovered.
- I removed the MQTT integration, restarted Home Assistant and re-added the MQTT integration, and the device wasn’t rediscoverd.
- I removed the MQTT integration and Mosquitto broker add-on, restarted Home Assistant, added Mosquitto broker add-on, and reconfigured the integration, and the device wasn’t rediscovered.
Steps to replicate:
- Have a device added via MQTT Auto-Discover;
- Turn the device off, making all its entities unavailable;
- Turn the device on, and it will never show again in Home Assistant
System Info
## System Health
version | core-2021.9.6
-- | --
installation_type | Home Assistant OS
dev | false
hassio | true
docker | true
user | root
virtualenv | false
python_version | 3.9.6
os_name | Linux
os_version | 5.10.17-v8
arch | aarch64
timezone | America/Toronto
<details><summary>Home Assistant Community Store</summary>
GitHub API | ok
-- | --
Github API Calls Remaining | 4772
Installed Version | 1.15.2
Stage | running
Available Repositories | 881
Installed Repositories | 12
</details>
<details><summary>Home Assistant Cloud</summary>
logged_in | true
-- | --
subscription_expiration | October 9, 2021, 8:00 PM
relayer_connected | true
remote_enabled | true
remote_connected | true
alexa_enabled | false
google_enabled | true
can_reach_cert_server | ok
can_reach_cloud_auth | ok
can_reach_cloud | ok
</details>
<details><summary>Home Assistant Supervisor</summary>
host_os | Home Assistant OS 6.3
-- | --
update_channel | stable
supervisor_version | supervisor-2021.09.0
docker_version | 20.10.7
disk_total | 58.0 GB
disk_used | 8.9 GB
healthy | true
supported | true
board | rpi4-64
supervisor_api | ok
version_api | ok
installed_addons | File editor (5.3.3), Terminal & SSH (9.1.3), Samba share (9.5.1), Network UPS Tools (0.8.0), Z-Wave JS (0.1.39), Check Home Assistant configuration (3.8.0), Home Assistant Google Drive Backup (0.105.1), ESPHome (2021.8.2), AirCast (3.1.1)
</details>
<details><summary>Lovelace</summary>
dashboards | 1
-- | --
resources | 7
views | 4
mode | storage
</details>
<details><summary>Spotify</summary>
api_endpoint_reachable | ok
-- | --
</details>
I don’t know why the Mosquito Broker isn’t included in the installed add-ons list but it is running:
Mosquito broker log captured after restarting it:
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing...
[00:26:56] INFO: Certificates found: SSL is available
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing...
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[00:26:57] INFO: Starting NGINX for authentication handling...
[00:26:57] INFO: Starting mosquitto MQTT broker...
1631507217: mosquitto version 1.6.12 starting
1631507217: |-- *** auth-plug: startup
[00:26:57] INFO: Successfully send discovery information to Home Assistant.
[00:26:58] INFO: Successfully send service information to the Supervisor.
1631507217: Config loaded from /etc/mosquitto/mosquitto.conf.
1631507217: Loading plugin: /usr/share/mosquitto/auth-plug.so
1631507217: ├── Username/password checking enabled.
1631507217: ├── TLS-PSK checking enabled.
1631507217: └── Extended authentication not enabled.
1631507217: Opening ipv4 listen socket on port 1883.
1631507217: Opening ipv6 listen socket on port 1883.
1631507217: Opening websockets listen socket on port 1884.
1631507217: Opening ipv4 listen socket on port 8883.
1631507217: Opening ipv6 listen socket on port 8883.
1631507217: Opening websockets listen socket on port 8884.
1631507217: Warning: Mosquitto should not be run as root/administrator.
1631507217: mosquitto version 1.6.12 running
1631507217: New connection from 192.168.86.202 on port 1883.
1631507217: New connection from 127.0.0.1 on port 1883.
1631507217: New client connected from 192.168.86.202 as 3vnd5l2wjZWpHDqDN67hUY (p1, c1, k60).
1631507217: Socket error on client <unknown>, disconnecting.
1631507218: New connection from 172.30.32.1 on port 1883.
1631507218: New client connected from 172.30.32.1 as 1nnWVCVzui5yFaOChmutu6 (p2, c1, k60, u'homeassistant').
1631507295: New connection from 172.30.32.2 on port 1883.
1631507295: Socket error on client <unknown>, disconnecting.
1631507415: New connection from 172.30.32.2 on port 1883.
1631507415: Socket error on client <unknown>, disconnecting.
1631507535: New connection from 172.30.32.2 on port 1883.
1631507535: Socket error on client <unknown>, disconnecting.
1631507655: New connection from 172.30.32.2 on port 1883.
1631507655: Socket error on client <unknown>, disconnecting.
1631507775: New connection from 172.30.32.2 on port 1883.
1631507775: Socket error on client <unknown>, disconnecting.
1631507895: New connection from 172.30.32.2 on port 1883.
1631507895: Socket error on client <unknown>, disconnecting.
1631508015: New connection from 172.30.32.2 on port 1883.
1631508015: Socket error on client <unknown>, disconnecting.
1631508135: New connection from 172.30.32.2 on port 1883.
The device that should be autodiscovery is the client from 192.168.86.202 - It is a Ender 3 3D Printer connected to Octoprint and running the MQTT, Home Assistant Discovery and PSU to MQTT Plug-in.
It was working fine until I had to reboot RaspeberyPI running Octoprint, after that, I couldn’t make it reappear in Home Assistant.
It also happened with a LED controller built using ESP8266. It was working fine until the update and a reboot, after that it never became available again, and I ended-up converting it to ESPHome.
Supervisor Log
21-09-12 23:26:43 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token
21-09-12 23:44:19 INFO (SyncWorker_6) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/raspberrypi4-64-homeassistant
21-09-12 23:44:33 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-09-12 23:44:41 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-12 23:44:42 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-12 23:45:28 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
21-09-12 23:48:35 INFO (SyncWorker_2) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-12 23:48:37 INFO (SyncWorker_2) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-12 23:48:40 INFO (SyncWorker_1) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-12 23:48:43 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
21-09-12 23:49:43 INFO (SyncWorker_5) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-12 23:49:45 INFO (SyncWorker_5) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-12 23:49:48 INFO (SyncWorker_7) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-12 23:49:50 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
21-09-12 23:51:19 INFO (SyncWorker_6) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/raspberrypi4-64-homeassistant
21-09-12 23:51:30 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-09-12 23:51:39 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-12 23:51:39 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-12 23:52:25 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
21-09-12 23:55:04 INFO (SyncWorker_0) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-12 23:55:05 INFO (SyncWorker_0) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-12 23:55:08 INFO (SyncWorker_6) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-12 23:55:11 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
21-09-12 23:56:44 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token
21-09-12 23:58:54 INFO (SyncWorker_0) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-12 23:58:56 INFO (SyncWorker_0) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-12 23:58:59 INFO (SyncWorker_3) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-12 23:59:02 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
21-09-12 23:59:55 INFO (SyncWorker_2) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-12 23:59:57 INFO (SyncWorker_2) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-13 00:00:00 INFO (SyncWorker_5) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-13 00:00:03 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
21-09-13 00:08:20 INFO (SyncWorker_3) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/raspberrypi4-64-homeassistant
21-09-13 00:08:50 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-09-13 00:08:59 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-13 00:08:59 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-13 00:09:44 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
21-09-13 00:12:26 INFO (MainThread) [supervisor.auth] Auth request from 'core_mosquitto' for 'mqtt'
21-09-13 00:12:27 INFO (MainThread) [supervisor.auth] Successful login for 'mqtt'
21-09-13 00:15:57 INFO (SyncWorker_1) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-13 00:15:59 INFO (SyncWorker_1) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-13 00:15:59 INFO (SyncWorker_1) [supervisor.docker.interface] Removing image homeassistant/aarch64-addon-mosquitto with latest and 6.0.1
21-09-13 00:15:59 INFO (MainThread) [supervisor.addons.addon] Removing add-on data folder /data/addons/data/core_mosquitto
21-09-13 00:15:59 INFO (MainThread) [supervisor.discovery] Delete discovery to Home Assistant mqtt from core_mosquitto
21-09-13 00:15:59 INFO (MainThread) [supervisor.addons] Add-on 'core_mosquitto' successfully removed
21-09-13 00:15:59 INFO (MainThread) [supervisor.discovery] Discovery 8b98ec34ae9147d687f555366cee7b16 message send
21-09-13 00:16:19 INFO (SyncWorker_2) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/raspberrypi4-64-homeassistant
21-09-13 00:16:41 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-09-13 00:16:48 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-13 00:16:48 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-13 00:17:39 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
21-09-13 00:17:47 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/info access from cebe7a76_hassio_google_drive_backup
21-09-13 00:17:47 INFO (MainThread) [supervisor.api.middleware.security] /backups access from cebe7a76_hassio_google_drive_backup
21-09-13 00:18:31 INFO (SyncWorker_4) [supervisor.docker.interface] Restarting ghcr.io/home-assistant/raspberrypi4-64-homeassistant
21-09-13 00:18:43 INFO (MainThread) [supervisor.homeassistant.core] Wait until Home Assistant is ready
21-09-13 00:18:52 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-13 00:18:52 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-13 00:19:38 INFO (MainThread) [supervisor.homeassistant.core] Detect a running Home Assistant instance
21-09-13 00:22:00 INFO (MainThread) [supervisor.addons] Creating Home Assistant add-on data folder /data/addons/data/core_mosquitto
21-09-13 00:22:00 INFO (SyncWorker_7) [supervisor.docker.interface] Downloading docker image homeassistant/aarch64-addon-mosquitto with tag 6.0.1.
21-09-13 00:22:03 INFO (MainThread) [supervisor.addons] Add-on 'core_mosquitto' successfully installed
21-09-13 00:22:13 INFO (SyncWorker_1) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-13 00:22:15 INFO (MainThread) [supervisor.discovery] Sending discovery to Home Assistant mqtt from core_mosquitto
21-09-13 00:22:15 INFO (MainThread) [supervisor.discovery] Discovery fc2b72df07124ea5b7b075d2f4456046 message send
21-09-13 00:22:16 INFO (MainThread) [supervisor.services.modules.mqtt] Set core_mosquitto as service provider for mqtt
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.check] Starting system checks with state CoreState.RUNNING
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.SECURITY/ContextType.CORE
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.PLUGIN
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.CORE
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.TRUST/ContextType.SUPERVISOR
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.PWNED/ContextType.ADDON
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.checks.base] Run check for IssueType.FREE_SPACE/ContextType.SYSTEM
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.check] System checks complete
21-09-13 00:22:18 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state CoreState.RUNNING
21-09-13 00:22:19 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete
21-09-13 00:22:19 INFO (MainThread) [supervisor.resolution.fixup] Starting system autofix at state CoreState.RUNNING
21-09-13 00:22:19 INFO (MainThread) [supervisor.resolution.fixup] System autofix complete
21-09-13 00:26:44 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token
21-09-13 00:26:48 INFO (SyncWorker_5) [supervisor.docker.interface] Stopping addon_core_mosquitto application
21-09-13 00:26:51 INFO (SyncWorker_5) [supervisor.docker.interface] Cleaning addon_core_mosquitto application
21-09-13 00:26:55 INFO (SyncWorker_6) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-mosquitto with version 6.0.1
21-09-13 00:26:57 ERROR (MainThread) [supervisor.services.modules.mqtt] There is already a MQTT service in use from core_mosquitto
No relevant errors on Core log