From 074fcd96ed5ee801f3ca087424d8c91a6b75813a Mon Sep 17 00:00:00 2001
From: Diogo Gomes <diogogomes@gmail.com>
Date: Thu, 24 Jan 2019 05:14:21 +0000
Subject: [PATCH] Fix error when API doesn't return a forecast. (#20365)

* add guard

* wrong logic
---
 homeassistant/components/weather/ipma.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/homeassistant/components/weather/ipma.py b/homeassistant/components/weather/ipma.py
index a2f5058ac1e..fda0fef4f25 100644
--- a/homeassistant/components/weather/ipma.py
+++ b/homeassistant/components/weather/ipma.py
@@ -116,6 +116,9 @@ class IPMAWeather(WeatherEntity):
     @property
     def condition(self):
         """Return the current condition."""
+        if not self._forecast:
+            return
+
         return next((k for k, v in CONDITION_CLASSES.items()
                      if self._forecast[0].idWeatherType in v), None)
 
-- 
GitLab