From b3bdf80eb24394bd78adc1a9af5afa274bcfff28 Mon Sep 17 00:00:00 2001 From: Andrea Arcangeli Date: Sun, 20 Oct 2024 23:35:01 +0200 Subject: [PATCH] open_meteo: correct UTC timezone handling in hourly forecast The `datetime` variable is timezone-naive. Using `dt_util.as_utc(datetime)` incorrectly assigns the local timezone instead of UTC, leading to incorrect conversions. To fix this, directly assign the UTC timezone to the `datetime` variable before conversion, ensuring `dt_util.as_utc()` does not overwrite it with the local timezone. --- homeassistant/components/open_meteo/weather.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/open_meteo/weather.py b/homeassistant/components/open_meteo/weather.py index a2be81f0928..efaee28a448 100644 --- a/homeassistant/components/open_meteo/weather.py +++ b/homeassistant/components/open_meteo/weather.py @@ -156,6 +156,8 @@ class OpenMeteoWeatherEntity( hourly = self.coordinator.data.hourly for index, datetime in enumerate(self.coordinator.data.hourly.time): + if datetime.tzinfo is None: + datetime = datetime.replace(tzinfo=dt_util.UTC) if dt_util.as_utc(datetime) < today: continue