feat(sensor): restore latest_events attribute and wire format_events service to it (v1.2.2)#36
Merged
Merged
Conversation
Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com>
Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix removal of latest_events attribute in sensor
feat(sensor): restore Mar 15, 2026
latest_events attribute and wire format_events service to it (v1.2.2)
|
|
||
| # latest_events: eventos nuevos de esta actualización, ordenados del más reciente al más antiguo | ||
| self._latest_events = sorted( | ||
| filtered_events, key=lambda e: parse_event_time(e), reverse=True |
There was a problem hiding this comment.
Suggested change
| filtered_events, key=lambda e: parse_event_time(e), reverse=True | |
| filtered_events, key=parse_event_time, reverse=True |
Avoid unnecessarily wrapping parse_event_time in a lambda. Read more.
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.
latest_eventswas dropped from the sensor'sextra_state_attributesin v1.2.1. Additionally, theformat_eventsservice was reading from the full cumulativeeventslist rather than the per-update delta.Changes
sensor.py— Re-introduces_latest_events:extra_state_attributes["latest_events"](raw dicts, unformatted)hass.data[DOMAIN][entry_id]["latest_events"]so other components can consume it__init__.py—format_eventsservice now reads fromlatest_eventsinstead ofevents, scoping formatted output to the delta of the most recent feed pollmanifest.json— version bumped to1.2.2Resulting attribute shape
Each entry in
latest_eventsis a raw dict with keys:id,title,place,magnitude,time,updated,coordinates,distance. Theformat_eventsservice applies formatting at call time from these raw dicts.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.