mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add UV Index and UV Health Concern sensors to tomorrow.io (#96534)
This commit is contained in:
parent
3b309cad99
commit
edcae75812
@ -72,6 +72,8 @@ from .const import (
|
||||
TMRW_ATTR_TEMPERATURE,
|
||||
TMRW_ATTR_TEMPERATURE_HIGH,
|
||||
TMRW_ATTR_TEMPERATURE_LOW,
|
||||
TMRW_ATTR_UV_HEALTH_CONCERN,
|
||||
TMRW_ATTR_UV_INDEX,
|
||||
TMRW_ATTR_VISIBILITY,
|
||||
TMRW_ATTR_WIND_DIRECTION,
|
||||
TMRW_ATTR_WIND_GUST,
|
||||
@ -291,6 +293,8 @@ class TomorrowioDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
TMRW_ATTR_PRESSURE_SURFACE_LEVEL,
|
||||
TMRW_ATTR_SOLAR_GHI,
|
||||
TMRW_ATTR_SULPHUR_DIOXIDE,
|
||||
TMRW_ATTR_UV_INDEX,
|
||||
TMRW_ATTR_UV_HEALTH_CONCERN,
|
||||
TMRW_ATTR_WIND_GUST,
|
||||
],
|
||||
[
|
||||
|
@ -115,3 +115,5 @@ TMRW_ATTR_PRESSURE_SURFACE_LEVEL = "pressureSurfaceLevel"
|
||||
TMRW_ATTR_SOLAR_GHI = "solarGHI"
|
||||
TMRW_ATTR_CLOUD_BASE = "cloudBase"
|
||||
TMRW_ATTR_CLOUD_CEILING = "cloudCeiling"
|
||||
TMRW_ATTR_UV_INDEX = "uvIndex"
|
||||
TMRW_ATTR_UV_HEALTH_CONCERN = "uvHealthConcern"
|
||||
|
@ -11,6 +11,7 @@ from pytomorrowio.const import (
|
||||
PollenIndex,
|
||||
PrecipitationType,
|
||||
PrimaryPollutantType,
|
||||
UVDescription,
|
||||
)
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@ -64,6 +65,8 @@ from .const import (
|
||||
TMRW_ATTR_PRESSURE_SURFACE_LEVEL,
|
||||
TMRW_ATTR_SOLAR_GHI,
|
||||
TMRW_ATTR_SULPHUR_DIOXIDE,
|
||||
TMRW_ATTR_UV_HEALTH_CONCERN,
|
||||
TMRW_ATTR_UV_INDEX,
|
||||
TMRW_ATTR_WIND_GUST,
|
||||
)
|
||||
|
||||
@ -309,6 +312,20 @@ SENSOR_TYPES = (
|
||||
name="Fire Index",
|
||||
icon="mdi:fire",
|
||||
),
|
||||
TomorrowioSensorEntityDescription(
|
||||
key=TMRW_ATTR_UV_INDEX,
|
||||
name="UV Index",
|
||||
icon="mdi:sun-wireless",
|
||||
),
|
||||
TomorrowioSensorEntityDescription(
|
||||
key=TMRW_ATTR_UV_HEALTH_CONCERN,
|
||||
name="UV Radiation Health Concern",
|
||||
value_map=UVDescription,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["high", "low", "moderate", "very_high", "extreme"],
|
||||
translation_key="uv_index",
|
||||
icon="mdi:sun-wireless",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -61,6 +61,15 @@
|
||||
"freezing_rain": "Freezing Rain",
|
||||
"ice_pellets": "Ice Pellets"
|
||||
}
|
||||
},
|
||||
"uv_index": {
|
||||
"state": {
|
||||
"low": "Low",
|
||||
"moderate": "Moderate",
|
||||
"high": "High",
|
||||
"very_high": "Very high",
|
||||
"extreme": "Extreme"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,6 +224,7 @@ class TomorrowioWeatherEntity(TomorrowioEntity, WeatherEntity):
|
||||
|
||||
temp = values.get(TMRW_ATTR_TEMPERATURE_HIGH)
|
||||
temp_low = None
|
||||
|
||||
wind_direction = values.get(TMRW_ATTR_WIND_DIRECTION)
|
||||
wind_speed = values.get(TMRW_ATTR_WIND_SPEED)
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
"pressureSurfaceLevel": 29.47,
|
||||
"solarGHI": 0,
|
||||
"cloudBase": 0.74,
|
||||
"cloudCeiling": 0.74
|
||||
"cloudCeiling": 0.74,
|
||||
"uvIndex": 3,
|
||||
"uvHealthConcern": 1
|
||||
},
|
||||
"forecasts": {
|
||||
"nowcast": [
|
||||
|
@ -60,6 +60,9 @@ CLOUD_COVER = "cloud_cover"
|
||||
CLOUD_CEILING = "cloud_ceiling"
|
||||
WIND_GUST = "wind_gust"
|
||||
PRECIPITATION_TYPE = "precipitation_type"
|
||||
UV_INDEX = "uv_index"
|
||||
UV_HEALTH_CONCERN = "uv_radiation_health_concern"
|
||||
|
||||
|
||||
V3_FIELDS = [
|
||||
O3,
|
||||
@ -91,6 +94,8 @@ V4_FIELDS = [
|
||||
CLOUD_CEILING,
|
||||
WIND_GUST,
|
||||
PRECIPITATION_TYPE,
|
||||
UV_INDEX,
|
||||
UV_HEALTH_CONCERN,
|
||||
]
|
||||
|
||||
|
||||
@ -171,6 +176,8 @@ async def test_v4_sensor(hass: HomeAssistant) -> None:
|
||||
check_sensor_state(hass, CLOUD_CEILING, "0.74")
|
||||
check_sensor_state(hass, WIND_GUST, "12.64")
|
||||
check_sensor_state(hass, PRECIPITATION_TYPE, "rain")
|
||||
check_sensor_state(hass, UV_INDEX, "3")
|
||||
check_sensor_state(hass, UV_HEALTH_CONCERN, "moderate")
|
||||
|
||||
|
||||
async def test_v4_sensor_imperial(hass: HomeAssistant) -> None:
|
||||
@ -202,6 +209,8 @@ async def test_v4_sensor_imperial(hass: HomeAssistant) -> None:
|
||||
check_sensor_state(hass, CLOUD_CEILING, "0.46")
|
||||
check_sensor_state(hass, WIND_GUST, "28.27")
|
||||
check_sensor_state(hass, PRECIPITATION_TYPE, "rain")
|
||||
check_sensor_state(hass, UV_INDEX, "3")
|
||||
check_sensor_state(hass, UV_HEALTH_CONCERN, "moderate")
|
||||
|
||||
|
||||
async def test_entity_description() -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user