mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
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:
parent
a4f9602405
commit
03847e6c41
@ -173,7 +173,10 @@ class OpenWeatherMapWeather(WeatherEntity):
|
|||||||
ATTR_FORECAST_TEMP:
|
ATTR_FORECAST_TEMP:
|
||||||
entry.get_temperature('celsius').get('temp'),
|
entry.get_temperature('celsius').get('temp'),
|
||||||
ATTR_FORECAST_PRECIPITATION:
|
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:
|
ATTR_FORECAST_CONDITION:
|
||||||
[k for k, v in CONDITION_CLASSES.items()
|
[k for k, v in CONDITION_CLASSES.items()
|
||||||
if entry.get_weather_code() in v][0]
|
if entry.get_weather_code() in v][0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user