Skip to content
Snippets Groups Projects
Commit 074fcd96 authored by Diogo Gomes's avatar Diogo Gomes Committed by Paulus Schoutsen
Browse files

Fix error when API doesn't return a forecast. (#20365)

* add guard

* wrong logic
parent 5580bec1
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,9 @@ class IPMAWeather(WeatherEntity): ...@@ -116,6 +116,9 @@ class IPMAWeather(WeatherEntity):
@property @property
def condition(self): def condition(self):
"""Return the current condition.""" """Return the current condition."""
if not self._forecast:
return
return next((k for k, v in CONDITION_CLASSES.items() return next((k for k, v in CONDITION_CLASSES.items()
if self._forecast[0].idWeatherType in v), None) if self._forecast[0].idWeatherType in v), None)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment