mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Add uv_index
to AccuWeather weather entity (#97015)
This commit is contained in:
parent
15c52e67a0
commit
5249660a6a
@ -14,6 +14,7 @@ from homeassistant.components.weather import (
|
||||
ATTR_FORECAST_NATIVE_WIND_SPEED,
|
||||
ATTR_FORECAST_PRECIPITATION_PROBABILITY,
|
||||
ATTR_FORECAST_TIME,
|
||||
ATTR_FORECAST_UV_INDEX,
|
||||
ATTR_FORECAST_WIND_BEARING,
|
||||
Forecast,
|
||||
WeatherEntity,
|
||||
@ -147,6 +148,11 @@ class AccuWeatherEntity(
|
||||
"""Return the visibility."""
|
||||
return cast(float, self.coordinator.data["Visibility"][API_METRIC][ATTR_VALUE])
|
||||
|
||||
@property
|
||||
def uv_index(self) -> float:
|
||||
"""Return the UV index."""
|
||||
return cast(float, self.coordinator.data["UVIndex"])
|
||||
|
||||
@property
|
||||
def forecast(self) -> list[Forecast] | None:
|
||||
"""Return the forecast array."""
|
||||
@ -172,6 +178,7 @@ class AccuWeatherEntity(
|
||||
ATTR_FORECAST_NATIVE_WIND_GUST_SPEED: item["WindGustDay"][ATTR_SPEED][
|
||||
ATTR_VALUE
|
||||
],
|
||||
ATTR_FORECAST_UV_INDEX: item["UVIndex"][ATTR_VALUE],
|
||||
ATTR_FORECAST_WIND_BEARING: item["WindDay"][ATTR_DIRECTION]["Degrees"],
|
||||
ATTR_FORECAST_CONDITION: [
|
||||
k for k, v in CONDITION_CLASSES.items() if item["IconDay"] in v
|
||||
|
@ -22,6 +22,7 @@ from homeassistant.components.weather import (
|
||||
ATTR_WEATHER_HUMIDITY,
|
||||
ATTR_WEATHER_PRESSURE,
|
||||
ATTR_WEATHER_TEMPERATURE,
|
||||
ATTR_WEATHER_UV_INDEX,
|
||||
ATTR_WEATHER_VISIBILITY,
|
||||
ATTR_WEATHER_WIND_BEARING,
|
||||
ATTR_WEATHER_WIND_GUST_SPEED,
|
||||
@ -61,6 +62,7 @@ async def test_weather_without_forecast(hass: HomeAssistant) -> None:
|
||||
assert state.attributes.get(ATTR_WEATHER_DEW_POINT) == 16.2
|
||||
assert state.attributes.get(ATTR_WEATHER_CLOUD_COVERAGE) == 10
|
||||
assert state.attributes.get(ATTR_WEATHER_WIND_GUST_SPEED) == 20.3
|
||||
assert state.attributes.get(ATTR_WEATHER_UV_INDEX) == 6
|
||||
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
||||
|
||||
entry = registry.async_get("weather.home")
|
||||
@ -86,6 +88,7 @@ async def test_weather_with_forecast(hass: HomeAssistant) -> None:
|
||||
assert state.attributes.get(ATTR_WEATHER_DEW_POINT) == 16.2
|
||||
assert state.attributes.get(ATTR_WEATHER_CLOUD_COVERAGE) == 10
|
||||
assert state.attributes.get(ATTR_WEATHER_WIND_GUST_SPEED) == 20.3
|
||||
assert state.attributes.get(ATTR_WEATHER_UV_INDEX) == 6
|
||||
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
||||
forecast = state.attributes.get(ATTR_FORECAST)[0]
|
||||
assert forecast.get(ATTR_FORECAST_CONDITION) == "lightning-rainy"
|
||||
@ -99,6 +102,7 @@ async def test_weather_with_forecast(hass: HomeAssistant) -> None:
|
||||
assert forecast.get(ATTR_FORECAST_CLOUD_COVERAGE) == 58
|
||||
assert forecast.get(ATTR_FORECAST_APPARENT_TEMP) == 29.8
|
||||
assert forecast.get(ATTR_FORECAST_WIND_GUST_SPEED) == 29.6
|
||||
assert forecast.get(ATTR_WEATHER_UV_INDEX) == 5
|
||||
|
||||
entry = registry.async_get("weather.home")
|
||||
assert entry
|
||||
|
Loading…
x
Reference in New Issue
Block a user