diff --git a/homeassistant/components/tomorrowio/__init__.py b/homeassistant/components/tomorrowio/__init__.py index b8a1ba64423875..ce5ec4191c5abf 100644 --- a/homeassistant/components/tomorrowio/__init__.py +++ b/homeassistant/components/tomorrowio/__init__.py @@ -72,6 +72,8 @@ 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 @@ async def _async_update_data(self) -> 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, ], [ diff --git a/homeassistant/components/tomorrowio/const.py b/homeassistant/components/tomorrowio/const.py index 4b1e2487da8db7..51d8d5f31ccd21 100644 --- a/homeassistant/components/tomorrowio/const.py +++ b/homeassistant/components/tomorrowio/const.py @@ -115,3 +115,5 @@ 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" diff --git a/homeassistant/components/tomorrowio/sensor.py b/homeassistant/components/tomorrowio/sensor.py index 046dc79f2c6d7e..6f75679f124dd3 100644 --- a/homeassistant/components/tomorrowio/sensor.py +++ b/homeassistant/components/tomorrowio/sensor.py @@ -11,6 +11,7 @@ PollenIndex, PrecipitationType, PrimaryPollutantType, + UVDescription, ) from homeassistant.components.sensor import ( @@ -64,6 +65,8 @@ 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 @@ def convert_ppb_to_ugm3(molecular_weight: int | float) -> Callable[[float], floa 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", + ), ) diff --git a/homeassistant/components/tomorrowio/strings.json b/homeassistant/components/tomorrowio/strings.json index 1057477b0acedb..c795dbfdbafd10 100644 --- a/homeassistant/components/tomorrowio/strings.json +++ b/homeassistant/components/tomorrowio/strings.json @@ -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" + } } } } diff --git a/homeassistant/components/tomorrowio/weather.py b/homeassistant/components/tomorrowio/weather.py index d92ac401f92b61..86b84ec3ca62e6 100644 --- a/homeassistant/components/tomorrowio/weather.py +++ b/homeassistant/components/tomorrowio/weather.py @@ -224,6 +224,7 @@ def forecast(self): 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) diff --git a/tests/components/tomorrowio/fixtures/v4.json b/tests/components/tomorrowio/fixtures/v4.json index ed5fb0982a023c..0ca4f348956104 100644 --- a/tests/components/tomorrowio/fixtures/v4.json +++ b/tests/components/tomorrowio/fixtures/v4.json @@ -31,7 +31,9 @@ "pressureSurfaceLevel": 29.47, "solarGHI": 0, "cloudBase": 0.74, - "cloudCeiling": 0.74 + "cloudCeiling": 0.74, + "uvIndex": 3, + "uvHealthConcern": 1 }, "forecasts": { "nowcast": [ diff --git a/tests/components/tomorrowio/test_sensor.py b/tests/components/tomorrowio/test_sensor.py index 487b3a4adb8dd7..77335769383e98 100644 --- a/tests/components/tomorrowio/test_sensor.py +++ b/tests/components/tomorrowio/test_sensor.py @@ -60,6 +60,9 @@ 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 @@ 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: