Repository navigation
Stop writing a state on every poll: remove force_update - #197
Merged
Merged
Conversation
_attr_force_update was added in 0.2.0 because the entries list was changed in place, and Home Assistant's shallow attribute comparison missed changes to the same list object (#104). Since 1.0, FeedReader.read() returns a new list on every poll, so changed entries are detected without it. With force_update, every poll wrote a state and fired state_changed even when the feed hadn't changed: a recorder row per poll, automations triggered on the sensor running every poll, and logbook/history noise. Fixes #185 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FvqVzfJq7yZSkZfSyG3YHT
iantrich
marked this pull request as ready for review
November 17, 2026 23:23
…-update # Conflicts: # tests/test_integration.py
Merged
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.
Fixes #185.
Why
_attr_force_update = Truewas added in 0.2.0 to work around #104. The entries list was changed in place, and Home Assistant compares attributes shallowly, so it missed changes to the same list object. Since 1.0,FeedReader.read()returns a new list on every poll, so Home Assistant sees changed entries without the workaround. The comment no longer described the code.With
force_update, every poll wrote a state and firedstate_changed, even when the feed hadn't changed. That meant:statesfor every poll,Change
This removes
_attr_force_updateand its comment. A short comment explains why it isn't needed. The comment on_unrecorded_attributesnow says "changes often" instead of "changes on every poll".Tests
test_unchanged_poll_writes_no_stateis the test the issue proposed:state_changed. This fails onmaster, which fires an event on every poll.state_changed, with the new entries in the attributes.The existing
test_update_preserves_previous_attribute_snapshotstill covers the new-list-per-read guarantee that makes this safe.The full offline suite passes (240 tests). pre-commit (black, ruff, mypy) is clean, and
sensor.pycompiles under Python 3.13.Release notes
to:/from:used to run on every poll. It now runs only when the feed changes. Worth a line for anyone who relied on the old behavior as a poll tick.Generated by Claude Code