From f4cd89e3fee372d472584cd763ca27c64f1401c9 Mon Sep 17 00:00:00 2001 From: Jules Dejaeghere Date: Fri, 29 Dec 2023 21:35:14 +0100 Subject: [PATCH] Return tonight's forecast after sunset in daily view --- custom_components/irm_kmi/weather.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/irm_kmi/weather.py b/custom_components/irm_kmi/weather.py index 33f9376..112ad00 100644 --- a/custom_components/irm_kmi/weather.py +++ b/custom_components/irm_kmi/weather.py @@ -106,6 +106,8 @@ class IrmKmiWeather(CoordinatorEntity, WeatherEntity): data: list[Forecast] = self.coordinator.data.get('daily_forecast') if not isinstance(data, list): return None + if len(data) > 0 and not data[0].get('is_daytime'): + return data if len(data) > 1 and data[0].get('native_templow') is None and not data[1].get('is_daytime'): data[0]['native_templow'] = data[1]['native_templow'] return [f for f in data if f.get('is_daytime')]