Repository navigation
Conversation
Home Assistant does not keep non-retained MQTT states across a restart. On homeassistant/status "online" the add-on only republishes discovery and availability, so sensors reported on a fixed schedule stay unknown until their next report (up to 5 min), and change-only sensors until their next change. on_ha_connected now starts republish_all_states() in the background (it runs under the discovery lock): 10 s and 60 s after HA comes online, every running inverter re-sends the last published value of each non-retained sensor. A value published meanwhile is sent again after ours; a failed send is logged and the pass goes on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Hi, thank you for the PR. Why 10s and 60s? Once we get the 'online' a single publish should be more than enough |
Contributor
Author
|
Hi
This is a precaution in case of Mqtt is not available at startup, but never
appear after 10s we can remove the 60s if you want ?
Le sam. 10 oct. 2026 à 15:55, Johann Kellerman ***@***.***> a
écrit :
… *kellerza* left a comment (kellerza/sunsynk#698)
<#698 (comment)>
Hi, thank you for the PR. Why 10s and 60s?
Once we get the 'online' a single publish should be more than enough
—
Reply to this email directly, view it on GitHub
<#698?email_source=notifications&email_token=AYDJ6M66O62GOQDBFO4FSHL5TI5VTA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMBZHAZDCNRUGMZ2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-6098216433>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYDJ6MY25TUMWTYU2GO3MJL5TI5VTAVCNFSNUABFKJSXA33TNF2G64TZHM2DAMZWGU3DAOJRHNEXG43VMU5TKNZWHAZDMNBQGUZ2C5QC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Owner
|
In on_ha_connected, MQTT is available and we already received "online" (or a timeout if HA is not configured correctly) So, we can simplify this a lot by just calling a method like this (on AInverter) from on_ha_connected async def republish_cached_sensors(self) -> None:
"""Re-send last MQTT-published non-retained states after HA comes online."""
states = {
asen: asen.value
for asen in self.ss.values()
if asen.entity
and not asen.retain
and asen.value is not None
and asen.opt.schedule.report_every > 10
}
if states:
await self.publish_sensors(states=states)No delays and competing with other schedules. This will also not resend values for sensors that get published frequently (<10s from when this runs) |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Home Assistant does not keep non-retained MQTT states across a restart. On homeassistant/status "online" the add-on only republishes discovery and availability, so sensors reported on a fixed schedule stay unknown until their next report (up to 5 min), and change-only sensors until their next change.
on_ha_connected now starts republish_all_states() in the background (it runs under the discovery lock): 10 s and 60 s after HA comes online, every running inverter re-sends the last published value of each non-retained sensor. A value published meanwhile is sent again after ours; a failed send is logged and the pass goes on.