From e96210fced4d63d77f1d0c80a7e04ce98057bd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hjelseth=20H=C3=B8yer?= Date: Tue, 14 Feb 2023 15:14:10 +0100 Subject: [PATCH] Fix Tibber stats (#88025) --- homeassistant/components/tibber/sensor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tibber/sensor.py b/homeassistant/components/tibber/sensor.py index 2fe9e290d04..dc6a58b6b82 100644 --- a/homeassistant/components/tibber/sensor.py +++ b/homeassistant/components/tibber/sensor.py @@ -636,13 +636,20 @@ class TibberDataCoordinator(DataUpdateCoordinator[None]): statistics = [] + last_stats_time_dt = ( + dt_util.utc_from_timestamp(last_stats_time) + if last_stats_time + else None + ) + for data in hourly_data: if data.get(sensor_type) is None: continue from_time = dt_util.parse_datetime(data["from"]) if from_time is None or ( - last_stats_time is not None and from_time <= last_stats_time + last_stats_time_dt is not None + and from_time <= last_stats_time_dt ): continue