Skip to content

fix: re-send HA MQTT autodiscovery on every reconnect#3

Open
andicoder wants to merge 1 commit into
fashberg:masterfrom
andicoder:fix/hass-autodiscovery-on-reconnect
Open

fix: re-send HA MQTT autodiscovery on every reconnect#3
andicoder wants to merge 1 commit into
fashberg:masterfrom
andicoder:fix/hass-autodiscovery-on-reconnect

Conversation

@andicoder

Copy link
Copy Markdown

Discovery configs are published as retained messages and were sent only once, on the first connect after boot (guarded by lastMqttHassAutodiscoverySent==0). When the broker restarts without persistence, all retained messages are lost and the device never re-announces, so Home Assistant entities disappear until the device is rebooted. mqttReconnect() only runs on an actual (re)connect, so re-announcing unconditionally is idempotent and self-heals a broker restart.

Discovery configs are published as retained messages and were sent only
once, on the first connect after boot (guarded by lastMqttHassAutodiscoverySent==0).
When the broker restarts without persistence, all retained messages are lost
and the device never re-announces, so Home Assistant entities disappear until
the device is rebooted. mqttReconnect() only runs on an actual (re)connect, so
re-announcing unconditionally is idempotent and self-heals a broker restart.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant