From 03847e6c416b20e04a1b7151a387110b427e6d6b Mon Sep 17 00:00:00 2001 From: priiduonu Date: Tue, 31 Jul 2018 20:18:11 +0300 Subject: [PATCH] Round precipitation forecast to 1 decimal place (#15759) The OWM returns precipitation forecast values as they are submitted to their network. It can lead to values like `0.0025000000000004 mm` which does not make sense and messes up the display card. This PR rounds the value to 1 decimal place. --- homeassistant/components/weather/openweathermap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/weather/openweathermap.py b/homeassistant/components/weather/openweathermap.py index 00d9bc47f1b..46a0b3ecc14 100644 --- a/homeassistant/components/weather/openweathermap.py +++ b/homeassistant/components/weather/openweathermap.py @@ -173,7 +173,10 @@ class OpenWeatherMapWeather(WeatherEntity): ATTR_FORECAST_TEMP: entry.get_temperature('celsius').get('temp'), ATTR_FORECAST_PRECIPITATION: - entry.get_rain().get('3h'), + (round(entry.get_rain().get('3h'), 1) + if entry.get_rain().get('3h') is not None + and (round(entry.get_rain().get('3h'), 1) > 0) + else None), ATTR_FORECAST_CONDITION: [k for k, v in CONDITION_CLASSES.items() if entry.get_weather_code() in v][0]