Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a history stats bug when window and tracked state change simultaneously #133770

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions homeassistant/components/history_stats/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@
await self._async_history_from_db(
current_period_start_timestamp, current_period_end_timestamp
)
if event and (new_state := event.data["new_state"]) is not None:
if (

Check warning on line 135 in homeassistant/components/history_stats/data.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/history_stats/data.py#L135

Added line #L135 was not covered by tests
current_period_start_timestamp
<= floored_timestamp(new_state.last_changed)
<= current_period_end_timestamp
):
self._history_current_period.append(

Check warning on line 140 in homeassistant/components/history_stats/data.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/history_stats/data.py#L140

Added line #L140 was not covered by tests
HistoryState(
new_state.state, new_state.last_changed.timestamp()
frenck marked this conversation as resolved.
Show resolved Hide resolved
)
)

self._previous_run_before_start = False

seconds_matched, match_count = self._async_compute_seconds_and_changes(
Expand Down