From 1a6bf1bddadb61adeef46f451316512f3e16917e Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 24 Jul 2024 14:38:20 +0200 Subject: [PATCH] Debug statistics metadata issue --- homeassistant/components/recorder/statistics.py | 4 ++++ tests/components/recorder/test_websocket_api.py | 1 + 2 files changed, 5 insertions(+) diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index aeeb30816d7..a45f684383a 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -587,6 +587,10 @@ def _compile_statistics( ): new_short_term_stats.append(new_stat) + if start.minute == 50: + # Once every hour, update issues + get_metadata(instance.hass, statistic_source=DOMAIN) + if start.minute == 55: # A full hour is ready, summarize it _compile_hourly_statistics(session, start) diff --git a/tests/components/recorder/test_websocket_api.py b/tests/components/recorder/test_websocket_api.py index bcdf07502b0..388ca831406 100644 --- a/tests/components/recorder/test_websocket_api.py +++ b/tests/components/recorder/test_websocket_api.py @@ -2079,6 +2079,7 @@ async def test_clear_statistics( ("new_unit", "new_unit_class", "new_display_unit"), [("dogs", None, "dogs"), (None, "unitless", None), ("W", "power", "kW")], ) +@pytest.mark.freeze_time("2024-07-24 11:50:00+00:00") # Breaks metadata, why? async def test_update_statistics_metadata( recorder_mock: Recorder, hass: HomeAssistant,