fix(sensor): restore delta semantics for latest_events + fire HA event on new earthquakes (v1.2.6/v1.2.7)#39
Merged
Conversation
… attribute (v1.2.5) Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix empty quake_events variable in automation
fix(sensor): replace dual-list pattern with single Mar 16, 2026
latest_events accumulator (v1.2.5)
…ia _seen_ids (v1.2.6) Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com>
Copilot
AI
changed the title
fix(sensor): replace dual-list pattern with single
fix(sensor): restore delta semantics for Mar 16, 2026
latest_events accumulator (v1.2.5)latest_events (v1.2.6)
Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com>
Copilot
AI
changed the title
fix(sensor): restore delta semantics for
fix(sensor): restore delta semantics for Mar 16, 2026
latest_events (v1.2.6)latest_events + fire HA event on new earthquakes (v1.2.6/v1.2.7)
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.
v1.2.5 introduced a conceptual error:
latest_eventsbecame a cumulative list that grew on every poll, always exposing all historical events. The correct behaviour is thatlatest_eventsis a delta — only events new since the last cycle — so automations trigger exclusively on genuinely new earthquakes.Behavioral contract (v1.2.6+)
latest_events[]Changes
sensor.py— delta tracking (_seen_ids)_latest_events.extend()accumulator with an internal_seen_ids: set[str]. Each cycle, only events absent from_seen_idsare emitted aslatest_events;_seen_idsis then updated.native_value(TIMESTAMP state) is updated only when new events arrive, sotrigger: statefires only on genuine new earthquakes.MAX_EVENTS = 50constant.sensor.py+const.py— HA event bus notification (v1.2.7)EVENT_NEW_QUAKES = "usgs_earthquakes_feed_new_events"toconst.py.latest_eventsis non-empty, enabling event-based automations without relying on sensor state polling:README
events/ "last 50 events" references with accuratelatest_eventsdelta semantics.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.