Skip to content

Comments

[homeassistant] Fix re-connection after connection loss#19491

Merged
lsiepel merged 1 commit intoopenhab:mainfrom
ccutrer:homeassistant-broker-reconnect
Oct 17, 2025
Merged

[homeassistant] Fix re-connection after connection loss#19491
lsiepel merged 1 commit intoopenhab:mainfrom
ccutrer:homeassistant-broker-reconnect

Conversation

@ccutrer
Copy link
Member

@ccutrer ccutrer commented Oct 16, 2025

A connection loss only goes through a stop/start cycle, not a dispose/initialize cycle. discoveryHomeAssistantIDs (the list of discovery topics to subscribe to) only gets populated in initialize, so don't clear it in stop -- only in dispose.

This means that after a reconnect, it had forgetten which topics it needed to subscribe to.

Fixes #19431

A connection loss only goes through a `stop`/start cycle, not a
`dispose`/`initialize` cycle. `discoveryHomeAssistantIDs` (the list of
discovery topics to subscribe to) only gets populated in `initialize`,
so don't clear it in `stop` -- only in `dispose`.

This means that after a reconnect, it had forgetten which topics it
needed to subscribe to.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
@ccutrer ccutrer requested a review from antroids as a code owner October 16, 2025 21:19
@ccutrer ccutrer requested a review from lsiepel October 16, 2025 21:21
@ccutrer
Copy link
Member Author

ccutrer commented Oct 16, 2025

Given the triviality of this fix, and how annoying it can be for some users with even moderately flakey connections to their MQTT broker, this seems like a reasonable thing to back port to 5.0 if we think we'll have another release in that line.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/mqtt-homeassistant-things-become-unknown-when-broker-status-changes/164938/43

Copy link
Contributor

@lsiepel lsiepel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@lsiepel lsiepel merged commit b0ecb05 into openhab:main Oct 17, 2025
2 checks passed
@lsiepel lsiepel added the bug An unexpected problem or unintended behavior of an add-on label Oct 17, 2025
lsiepel pushed a commit that referenced this pull request Oct 17, 2025
A connection loss only goes through a `stop`/start cycle, not a
`dispose`/`initialize` cycle.

Signed-off-by: Cody Cutrer <cody@cutrer.us>
@lsiepel lsiepel added the backported A PR that has been cherry-picked to a patch release branch label Oct 17, 2025
@ccutrer ccutrer deleted the homeassistant-broker-reconnect branch October 17, 2025 13:50
@jlaur jlaur added this to the 5.1 milestone Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported A PR that has been cherry-picked to a patch release branch bug An unexpected problem or unintended behavior of an add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mqtt.homeassistant] Things Created with MQTT Homeassistant suddenly go to UNKNOWN state

4 participants