Skip to content

fix(sensor): keep the last feed while a poll fails - #36

Merged
timmaurice merged 1 commit into
masterfrom
c082/keep-last-data
Nov 13, 2026
Merged

timmaurice merged 1 commit into
masterfrom
c082/keep-last-data

Conversation

@timmaurice

Copy link
Copy Markdown
Owner

Summary

When a poll fails, CoordinatorEntity marks the sensor unavailable and Home Assistant writes an
unavailable state without attributes. rss-accordion (and any other consumer) then lost the whole
entries list, 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: true while the most recent poll failed (the attribute is absent
otherwise). A feed that never loaded is still unavailable. UpdateFailed is still raised, so the
failure is still logged and last_update_success is unchanged. Automations that trigger on
unavailable as an outage signal should use the stale attribute instead.

Tests

  • New tests for stale/available behaviour and the never-loaded case in tests/test_sensor.py.
  • Full suite: 284 passed; 4 tests/test_api.py tests fail in this local environment
    (pytest-homeassistant-custom-component socket/aiohttp setup), unrelated to this change.
  • black --check clean.

Board card c082.

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.
@timmaurice
timmaurice merged commit 7263cf3 into master Nov 13, 2026
8 checks passed
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