Add precipitation probability forecast to owm (#47284)

* Add precipitation probability forecast to owm

* Update weather_update_coordinator.py

Reformat the code based on black
pull/47555/head
N1c093 2021-03-07 00:48:22 +01:00 committed by GitHub
parent f542b360d5
commit 9101ed2732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -16,6 +16,7 @@ from homeassistant.components.weather import (
ATTR_CONDITION_WINDY_VARIANT, ATTR_CONDITION_WINDY_VARIANT,
ATTR_FORECAST_CONDITION, ATTR_FORECAST_CONDITION,
ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_PRECIPITATION,
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
ATTR_FORECAST_PRESSURE, ATTR_FORECAST_PRESSURE,
ATTR_FORECAST_TEMP, ATTR_FORECAST_TEMP,
ATTR_FORECAST_TEMP_LOW, ATTR_FORECAST_TEMP_LOW,
@ -93,6 +94,7 @@ MONITORED_CONDITIONS = [
FORECAST_MONITORED_CONDITIONS = [ FORECAST_MONITORED_CONDITIONS = [
ATTR_FORECAST_CONDITION, ATTR_FORECAST_CONDITION,
ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_PRECIPITATION,
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
ATTR_FORECAST_PRESSURE, ATTR_FORECAST_PRESSURE,
ATTR_FORECAST_TEMP, ATTR_FORECAST_TEMP,
ATTR_FORECAST_TEMP_LOW, ATTR_FORECAST_TEMP_LOW,
@ -212,6 +214,7 @@ WEATHER_SENSOR_TYPES = {
FORECAST_SENSOR_TYPES = { FORECAST_SENSOR_TYPES = {
ATTR_FORECAST_CONDITION: {SENSOR_NAME: "Condition"}, ATTR_FORECAST_CONDITION: {SENSOR_NAME: "Condition"},
ATTR_FORECAST_PRECIPITATION: {SENSOR_NAME: "Precipitation"}, ATTR_FORECAST_PRECIPITATION: {SENSOR_NAME: "Precipitation"},
ATTR_FORECAST_PRECIPITATION_PROBABILITY: {SENSOR_NAME: "Precipitation probability"},
ATTR_FORECAST_PRESSURE: {SENSOR_NAME: "Pressure"}, ATTR_FORECAST_PRESSURE: {SENSOR_NAME: "Pressure"},
ATTR_FORECAST_TEMP: { ATTR_FORECAST_TEMP: {
SENSOR_NAME: "Temperature", SENSOR_NAME: "Temperature",

View File

@ -10,6 +10,7 @@ from homeassistant.components.weather import (
ATTR_CONDITION_SUNNY, ATTR_CONDITION_SUNNY,
ATTR_FORECAST_CONDITION, ATTR_FORECAST_CONDITION,
ATTR_FORECAST_PRECIPITATION, ATTR_FORECAST_PRECIPITATION,
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
ATTR_FORECAST_PRESSURE, ATTR_FORECAST_PRESSURE,
ATTR_FORECAST_TEMP, ATTR_FORECAST_TEMP,
ATTR_FORECAST_TEMP_LOW, ATTR_FORECAST_TEMP_LOW,
@ -143,6 +144,9 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
ATTR_FORECAST_PRECIPITATION: self._calc_precipitation( ATTR_FORECAST_PRECIPITATION: self._calc_precipitation(
entry.rain, entry.snow entry.rain, entry.snow
), ),
ATTR_FORECAST_PRECIPITATION_PROBABILITY: (
entry.precipitation_probability * 100
),
ATTR_FORECAST_PRESSURE: entry.pressure.get("press"), ATTR_FORECAST_PRESSURE: entry.pressure.get("press"),
ATTR_FORECAST_WIND_SPEED: entry.wind().get("speed"), ATTR_FORECAST_WIND_SPEED: entry.wind().get("speed"),
ATTR_FORECAST_WIND_BEARING: entry.wind().get("deg"), ATTR_FORECAST_WIND_BEARING: entry.wind().get("deg"),