Skip to content

Commit

Permalink
Fix history stats not comparing all times in UTC (#73040)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jun 4, 2022
1 parent c7416c0 commit 0a2a166
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions homeassistant/components/history_stats/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ async def async_update(self, event: Event | None) -> HistoryStatsState:
current_period_end_timestamp = floored_timestamp(current_period_end)
previous_period_start_timestamp = floored_timestamp(previous_period_start)
previous_period_end_timestamp = floored_timestamp(previous_period_end)
now_timestamp = floored_timestamp(datetime.datetime.now())
utc_now = dt_util.utcnow()
now_timestamp = floored_timestamp(utc_now)

if now_timestamp < current_period_start_timestamp:
if current_period_start > utc_now:
# History cannot tell the future
self._history_current_period = []
self._previous_run_before_start = True
Expand Down

0 comments on commit 0a2a166

Please sign in to comment.