diff --git a/homeassistant/components/weather/openweathermap.py b/homeassistant/components/weather/openweathermap.py index b70413b9565..0e3a6f90b70 100644 --- a/homeassistant/components/weather/openweathermap.py +++ b/homeassistant/components/weather/openweathermap.py @@ -149,6 +149,15 @@ class OpenWeatherMapWeather(WeatherEntity): def forecast(self): """Return the forecast array.""" data = [] + + def calc_precipitation(rain, snow): + """Calculate the precipitation.""" + rain_value = 0 if rain is None else rain + snow_value = 0 if snow is None else snow + if round(rain_value + snow_value, 1) == 0: + return None + return round(rain_value + snow_value, 1) + for entry in self.forecast_data.get_weathers(): if self._mode == 'daily': data.append({ @@ -159,7 +168,9 @@ class OpenWeatherMapWeather(WeatherEntity): ATTR_FORECAST_TEMP_LOW: entry.get_temperature('celsius').get('night'), ATTR_FORECAST_PRECIPITATION: - entry.get_rain().get('all'), + calc_precipitation( + entry.get_rain().get('all'), + entry.get_snow().get('all')), ATTR_FORECAST_WIND_SPEED: entry.get_wind().get('speed'), ATTR_FORECAST_WIND_BEARING: