Always retain Home Assistant MQTT Discovery config topic #777
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe what the PR does:
When
ecowitt2mqtt
loses connection to the MQTT broker for some reason (the broker going down, network issues, etc.) and the broker hasn't setretain
, the following bug can happen:ecowitt2mqtt
starts up.ecowitt2mqtt
detects that it hasn't sent MQTT Discovery info before, so it does; this creates the config topic + underlying data.ecowitt2mqtt
loses connection to the MQTT broker. Withoutretain
set, this effectively wipes allecowitt2mqtt
data from the broker's memory.ecowitt2mqtt
reconnects.ecowitt2mqtt
has been running this whole time, it sees this payload and says, "I've already published config info for these entities, so I won't do it again." This means that it fails to republish the config topic.To address all possibilities of this issue, we set the config topic to always retain.
Does this fix a specific issue?
Fixes #760
Checklist:
README.md
with any new documentation.