Repository navigation
fix(sensor): keep the last feed while a poll fails - #36
Merged
Merged
Conversation
A failed poll made the sensor unavailable, and an unavailable state carries no attributes, so cards showing the entries went blank on any server hiccup even though the coordinator still held the last good feed. The sensor now stays available while the coordinator has data and adds a stale attribute (only while the last poll failed). A feed that never loaded is still unavailable.
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.
Summary
When a poll fails,
CoordinatorEntitymarks the sensor unavailable and Home Assistant writes anunavailable state without attributes.
rss-accordion(and any other consumer) then lost the wholeentrieslist, although the coordinator still held the last good feed.Behaviour change: the sensor stays available while the coordinator has data, keeps the last
feed, and exposes
stale: truewhile the most recent poll failed (the attribute is absentotherwise). A feed that never loaded is still unavailable.
UpdateFailedis still raised, so thefailure is still logged and
last_update_successis unchanged. Automations that trigger onunavailableas an outage signal should use thestaleattribute instead.Tests
tests/test_sensor.py.tests/test_api.pytests fail in this local environment(pytest-homeassistant-custom-component socket/aiohttp setup), unrelated to this change.
black --checkclean.Board card c082.