From 62e9e5fb9feb6803f3cee3977f08f945f46979c5 Mon Sep 17 00:00:00 2001 From: Jules Dejaeghere Date: Sun, 23 Jun 2024 13:40:50 +0200 Subject: [PATCH] Fix edge case in current weather --- custom_components/irm_kmi/coordinator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom_components/irm_kmi/coordinator.py b/custom_components/irm_kmi/coordinator.py index 39e576f..ba9eb55 100644 --- a/custom_components/irm_kmi/coordinator.py +++ b/custom_components/irm_kmi/coordinator.py @@ -212,7 +212,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator): or not isinstance(hourly_forecast_data, list) or len(hourly_forecast_data) == 0): - for current in hourly_forecast_data[:2]: + for current in hourly_forecast_data[:4]: if now.strftime('%H') == current['hour']: now_hourly = current break @@ -278,7 +278,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator): if current_weather['condition'] is None: try: current_weather['condition'] = CDT_MAP.get((int(now_hourly.get('ww')), now_hourly.get('dayNight'))) - except (TypeError, ValueError): + except (TypeError, ValueError, AttributeError): current_weather['condition'] = None return current_weather