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.
This commit is contained in:
priiduonu 2018-07-31 20:18:11 +03:00 committed by Fabian Affolter
parent a4f9602405
commit 03847e6c41

View File

@ -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]