core: `history_stats` sensor does not work in `2022.5.0b1`

The problem

There’s unexpected error in the logs (see below) and history_stats sensor does not work.

Developer tools:

state: unknown

state_class: measurement
unit_of_measurement: h
device_class: duration
icon: mdi:chart-line
friendly_name: TV time

What version of Home Assistant Core has the issue?

2022.5.0b1

What was the last working version of Home Assistant Core?

2022.4.7

What type of installation are you running?

Home Assistant OS

Integration causing the issue

History Stats

Link to integration documentation on our website

https://www.home-assistant.io/integrations/history_stats/

Diagnostics information

No response

Example YAML snippet

- platform: history_stats
    name: "TV time"
    entity_id: media_player.televize
    state: "on"
    type: time
    start: '{{ now().replace(hour=0, minute=0, second=0) }}'
    end: '{{ now() }}'

Anything in the logs that might be useful for us?

2022-04-28 17:28:04 ERROR (MainThread) [homeassistant.components.history_stats.coordinator] Unexpected error fetching TV time data: date value out of range
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/history_stats/coordinator.py", line 94, in _async_update_data
    return await self._history_stats.async_update(None)
  File "/usr/src/homeassistant/homeassistant/components/history_stats/data.py", line 60, in async_update
    previous_period_start = dt_util.as_utc(previous_period_start)
  File "/usr/src/homeassistant/homeassistant/util/dt.py", line 71, in as_utc
    return dattim.astimezone(UTC)
OverflowError: date value out of range

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Nothing in logs and sensor looks good! Thanks!