Fix precipitation calculation for hourly forecast (#52676)

It seems that hourly forecast have precipitation in 3h blocks.
This commit is contained in:
Stefan Agner 2021-07-08 11:39:56 +02:00 committed by GitHub
parent abca7deadb
commit 1dd4ba5fcd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,6 +191,8 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
"""Get rain data from weather data."""
if "all" in rain:
return round(rain["all"], 2)
if "3h" in rain:
return round(rain["3h"], 2)
if "1h" in rain:
return round(rain["1h"], 2)
return 0
@ -201,6 +203,8 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
if snow:
if "all" in snow:
return round(snow["all"], 2)
if "3h" in snow:
return round(snow["3h"], 2)
if "1h" in snow:
return round(snow["1h"], 2)
return 0