Add humidity and dew point to tomorrow.io integration (#98496)
* Add humidity and dew point to tomorrow.io integration * Fix ruff complaints * Make mypy happy * Merge emontnemery's changes * Fix formatting error * Add fake humidity and dew point to test data (first interval only) * Fix inconsistency * Fix inconsistency
This commit is contained in:
parent
49d2c60992
commit
f6a9be937b
4 changed files with 33 additions and 0 deletions
|
@ -7,6 +7,8 @@ from pytomorrowio.const import DAILY, FORECASTS, HOURLY, NOWCAST, WeatherCode
|
|||
|
||||
from homeassistant.components.weather import (
|
||||
ATTR_FORECAST_CONDITION,
|
||||
ATTR_FORECAST_HUMIDITY,
|
||||
ATTR_FORECAST_NATIVE_DEW_POINT,
|
||||
ATTR_FORECAST_NATIVE_PRECIPITATION,
|
||||
ATTR_FORECAST_NATIVE_TEMP,
|
||||
ATTR_FORECAST_NATIVE_TEMP_LOW,
|
||||
|
@ -44,6 +46,7 @@ from .const import (
|
|||
DOMAIN,
|
||||
MAX_FORECASTS,
|
||||
TMRW_ATTR_CONDITION,
|
||||
TMRW_ATTR_DEW_POINT,
|
||||
TMRW_ATTR_HUMIDITY,
|
||||
TMRW_ATTR_OZONE,
|
||||
TMRW_ATTR_PRECIPITATION,
|
||||
|
@ -138,6 +141,8 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
|
|||
precipitation_probability: int | None,
|
||||
temp: float | None,
|
||||
temp_low: float | None,
|
||||
humidity: float | None,
|
||||
dew_point: float | None,
|
||||
wind_direction: float | None,
|
||||
wind_speed: float | None,
|
||||
) -> Forecast:
|
||||
|
@ -156,6 +161,8 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
|
|||
ATTR_FORECAST_PRECIPITATION_PROBABILITY: precipitation_probability,
|
||||
ATTR_FORECAST_NATIVE_TEMP: temp,
|
||||
ATTR_FORECAST_NATIVE_TEMP_LOW: temp_low,
|
||||
ATTR_FORECAST_HUMIDITY: humidity,
|
||||
ATTR_FORECAST_NATIVE_DEW_POINT: dew_point,
|
||||
ATTR_FORECAST_WIND_BEARING: wind_direction,
|
||||
ATTR_FORECAST_NATIVE_WIND_SPEED: wind_speed,
|
||||
}
|
||||
|
@ -259,6 +266,8 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
|
|||
|
||||
temp = values.get(TMRW_ATTR_TEMPERATURE_HIGH)
|
||||
temp_low = None
|
||||
dew_point = values.get(TMRW_ATTR_DEW_POINT)
|
||||
humidity = values.get(TMRW_ATTR_HUMIDITY)
|
||||
|
||||
wind_direction = values.get(TMRW_ATTR_WIND_DIRECTION)
|
||||
wind_speed = values.get(TMRW_ATTR_WIND_SPEED)
|
||||
|
@ -285,6 +294,8 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
|
|||
precipitation_probability,
|
||||
temp,
|
||||
temp_low,
|
||||
humidity,
|
||||
dew_point,
|
||||
wind_direction,
|
||||
wind_speed,
|
||||
)
|
||||
|
|
|
@ -908,6 +908,8 @@
|
|||
"values": {
|
||||
"temperatureMin": 44.13,
|
||||
"temperatureMax": 44.13,
|
||||
"dewPoint": 12.76,
|
||||
"humidity": 58.46,
|
||||
"windSpeed": 9.33,
|
||||
"windDirection": 315.14,
|
||||
"weatherCode": 1000,
|
||||
|
@ -2206,6 +2208,8 @@
|
|||
"values": {
|
||||
"temperatureMin": 26.11,
|
||||
"temperatureMax": 45.93,
|
||||
"dewPoint": 12.76,
|
||||
"humidity": 58.46,
|
||||
"windSpeed": 9.49,
|
||||
"windDirection": 239.6,
|
||||
"weatherCode": 1000,
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T11:00:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 45.9,
|
||||
|
@ -148,6 +150,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T11:00:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 45.9,
|
||||
|
@ -292,6 +296,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T17:48:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 44.1,
|
||||
|
@ -512,6 +518,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T17:48:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 44.1,
|
||||
|
@ -733,6 +741,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T11:00:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 45.9,
|
||||
|
@ -879,6 +889,8 @@
|
|||
dict({
|
||||
'condition': 'sunny',
|
||||
'datetime': '2021-03-07T17:48:00+00:00',
|
||||
'dew_point': 12.8,
|
||||
'humidity': 58,
|
||||
'precipitation': 0.0,
|
||||
'precipitation_probability': 0,
|
||||
'temperature': 44.1,
|
||||
|
|
|
@ -24,6 +24,8 @@ from homeassistant.components.weather import (
|
|||
ATTR_CONDITION_SUNNY,
|
||||
ATTR_FORECAST,
|
||||
ATTR_FORECAST_CONDITION,
|
||||
ATTR_FORECAST_DEW_POINT,
|
||||
ATTR_FORECAST_HUMIDITY,
|
||||
ATTR_FORECAST_PRECIPITATION,
|
||||
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
|
||||
ATTR_FORECAST_TEMP,
|
||||
|
@ -164,6 +166,8 @@ async def test_v4_weather(hass: HomeAssistant) -> None:
|
|||
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 0,
|
||||
ATTR_FORECAST_TEMP: 45.9,
|
||||
ATTR_FORECAST_TEMP_LOW: 26.1,
|
||||
ATTR_FORECAST_DEW_POINT: 12.8,
|
||||
ATTR_FORECAST_HUMIDITY: 58,
|
||||
ATTR_FORECAST_WIND_BEARING: 239.6,
|
||||
ATTR_FORECAST_WIND_SPEED: 34.16, # 9.49 m/s -> km/h
|
||||
}
|
||||
|
@ -191,6 +195,8 @@ async def test_v4_weather_legacy_entities(hass: HomeAssistant) -> None:
|
|||
assert weather_state.attributes[ATTR_FORECAST][0] == {
|
||||
ATTR_FORECAST_CONDITION: ATTR_CONDITION_SUNNY,
|
||||
ATTR_FORECAST_TIME: "2021-03-07T11:00:00+00:00",
|
||||
ATTR_FORECAST_DEW_POINT: 12.8,
|
||||
ATTR_FORECAST_HUMIDITY: 58,
|
||||
ATTR_FORECAST_PRECIPITATION: 0,
|
||||
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 0,
|
||||
ATTR_FORECAST_TEMP: 45.9,
|
||||
|
|
Loading…
Add table
Reference in a new issue