Add humidity to tomorrowio hourly weather forecasts (#70186)

* Add humidity to hourly weather forecasts

* Don't include humidity in daily forecasts

* Fix test
pull/70295/head
lymanepp 2022-04-19 12:14:07 -04:00 committed by GitHub
parent 2228ea5ee0
commit febcab11fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 204 additions and 0 deletions

View File

@ -297,6 +297,7 @@ class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator):
[
TMRW_ATTR_TEMPERATURE_LOW,
TMRW_ATTR_TEMPERATURE_HIGH,
TMRW_ATTR_HUMIDITY,
TMRW_ATTR_WIND_SPEED,
TMRW_ATTR_WIND_DIRECTION,
TMRW_ATTR_CONDITION,

View File

@ -18,6 +18,9 @@ from homeassistant.components.weather import (
ATTR_CONDITION_WINDY,
)
# Attribute missing from homeassistant.components.weather
ATTR_FORECAST_HUMIDITY = "humidity"
CONF_TIMESTEP = "timestep"
FORECAST_TYPES = [DAILY, HOURLY, NOWCAST]

View File

@ -33,6 +33,7 @@ from homeassistant.util import dt as dt_util
from . import TomorrowioDataUpdateCoordinator, TomorrowioEntity
from .const import (
ATTR_FORECAST_HUMIDITY,
CLEAR_CONDITIONS,
CONDITIONS,
CONF_TIMESTEP,
@ -100,6 +101,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
forecast_dt: datetime,
use_datetime: bool,
condition: int,
humidity: float | None,
precipitation: float | None,
precipitation_probability: float | None,
temp: float | None,
@ -118,6 +120,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
data = {
ATTR_FORECAST_TIME: forecast_dt.isoformat(),
ATTR_FORECAST_CONDITION: translated_condition,
ATTR_FORECAST_HUMIDITY: humidity,
ATTR_FORECAST_PRECIPITATION: precipitation,
ATTR_FORECAST_PRECIPITATION_PROBABILITY: precipitation_probability,
ATTR_FORECAST_TEMP: temp,
@ -211,6 +214,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
use_datetime = True
condition = values.get(TMRW_ATTR_CONDITION)
humidity = values.get(TMRW_ATTR_HUMIDITY)
precipitation = values.get(TMRW_ATTR_PRECIPITATION)
precipitation_probability = values.get(TMRW_ATTR_PRECIPITATION_PROBABILITY)
@ -237,6 +241,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
forecast_dt,
use_datetime,
condition,
None if self.forecast_type == DAILY else humidity,
precipitation,
precipitation_probability,
temp,

File diff suppressed because it is too large Load Diff