Handle edge case for current weather

This commit is contained in:
Jules 2023-12-23 21:11:46 +01:00
parent ea853a05a2
commit a384a4b6fb
Signed by: jdejaegh
GPG key ID: 99D6D184CA66933A

View file

@ -36,10 +36,10 @@ class IrmKmiWeather(CoordinatorEntity, WeatherEntity):
data = self.coordinator.data.get('for', {}).get('hourly') data = self.coordinator.data.get('for', {}).get('hourly')
if data is None or not isinstance(data, list) or len(data) == 0: if data is None or not isinstance(data, list) or len(data) == 0:
return None return None
data = data[0] for current in data[:2]:
if datetime.now().strftime('%H') != data['hour']: if datetime.now().strftime('%H') == current['hour']:
return current
return None return None
return data
@property @property
def name(self) -> str: def name(self) -> str: