Fix edge case in current weather

This commit is contained in:
Jules 2024-06-23 13:40:50 +02:00
parent 5f53d16ce2
commit 62e9e5fb9f
Signed by: jdejaegh
GPG key ID: 99D6D184CA66933A

View file

@ -212,7 +212,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
or not isinstance(hourly_forecast_data, list) or not isinstance(hourly_forecast_data, list)
or len(hourly_forecast_data) == 0): 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']: if now.strftime('%H') == current['hour']:
now_hourly = current now_hourly = current
break break
@ -278,7 +278,7 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
if current_weather['condition'] is None: if current_weather['condition'] is None:
try: try:
current_weather['condition'] = CDT_MAP.get((int(now_hourly.get('ww')), now_hourly.get('dayNight'))) 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 current_weather['condition'] = None
return current_weather return current_weather