Add humidity to NWS forecast (#95575)

* Add humidity to NWS forecast to address https://github.com/home-assistant/core/issues/95572

* Use pynws 1.5.0 enhancements for probabilityOfPrecipitation, dewpoint, and relativeHumidity.

* Update requirements to match pynws version

* test for clear night

* update docstring

---------

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
This commit is contained in:
lymanepp 2023-07-06 17:05:46 -04:00 committed by GitHub
parent e94726ec84
commit 6c4b5291e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 20 deletions

View file

@ -3,6 +3,8 @@ from homeassistant.components.nws.const import CONF_STATION
from homeassistant.components.weather import (
ATTR_CONDITION_LIGHTNING_RAINY,
ATTR_FORECAST_CONDITION,
ATTR_FORECAST_DEW_POINT,
ATTR_FORECAST_HUMIDITY,
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
ATTR_FORECAST_TEMP,
ATTR_FORECAST_TIME,
@ -59,6 +61,9 @@ DEFAULT_OBSERVATION = {
"windGust": 20,
}
CLEAR_NIGHT_OBSERVATION = DEFAULT_OBSERVATION.copy()
CLEAR_NIGHT_OBSERVATION["iconTime"] = "night"
SENSOR_EXPECTED_OBSERVATION_METRIC = {
"dewpoint": "5",
"temperature": "10",
@ -183,6 +188,9 @@ DEFAULT_FORECAST = [
"timestamp": "2019-08-12T23:53:00+00:00",
"iconTime": "night",
"iconWeather": (("lightning-rainy", 40), ("lightning-rainy", 90)),
"probabilityOfPrecipitation": 89,
"dewpoint": 4,
"relativeHumidity": 75,
},
]
@ -192,7 +200,9 @@ EXPECTED_FORECAST_IMPERIAL = {
ATTR_FORECAST_TEMP: 10,
ATTR_FORECAST_WIND_SPEED: 10,
ATTR_FORECAST_WIND_BEARING: 180,
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 90,
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 89,
ATTR_FORECAST_DEW_POINT: 4,
ATTR_FORECAST_HUMIDITY: 75,
}
EXPECTED_FORECAST_METRIC = {
@ -211,7 +221,14 @@ EXPECTED_FORECAST_METRIC = {
2,
),
ATTR_FORECAST_WIND_BEARING: 180,
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 90,
ATTR_FORECAST_PRECIPITATION_PROBABILITY: 89,
ATTR_FORECAST_DEW_POINT: round(
TemperatureConverter.convert(
4, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
),
1,
),
ATTR_FORECAST_HUMIDITY: 75,
}
NONE_FORECAST = [{key: None for key in DEFAULT_FORECAST[0]}]