From 5abff314371d4cb5f3d2c1668776b01cb4cac89f Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Fri, 7 Oct 2022 23:52:36 +0000 Subject: [PATCH] Use new device classes in Accuweather integration (#79717) * Add new device classes * Update tests --- homeassistant/components/accuweather/sensor.py | 7 +++++++ tests/components/accuweather/test_sensor.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/homeassistant/components/accuweather/sensor.py b/homeassistant/components/accuweather/sensor.py index f57af15714d..4347bca5863 100644 --- a/homeassistant/components/accuweather/sensor.py +++ b/homeassistant/components/accuweather/sensor.py @@ -189,6 +189,7 @@ FORECAST_SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="WindGustDay", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind gust day", entity_registry_enabled_default=False, @@ -200,6 +201,7 @@ FORECAST_SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="WindGustNight", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind gust night", entity_registry_enabled_default=False, @@ -211,6 +213,7 @@ FORECAST_SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="WindDay", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind day", unit_fn=lambda metric: SPEED_KILOMETERS_PER_HOUR @@ -221,6 +224,7 @@ FORECAST_SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="WindNight", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind night", unit_fn=lambda metric: SPEED_KILOMETERS_PER_HOUR @@ -243,6 +247,7 @@ SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="Ceiling", + device_class=SensorDeviceClass.DISTANCE, icon="mdi:weather-fog", name="Cloud ceiling", state_class=SensorStateClass.MEASUREMENT, @@ -329,6 +334,7 @@ SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="Wind", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind", state_class=SensorStateClass.MEASUREMENT, @@ -339,6 +345,7 @@ SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="WindGust", + device_class=SensorDeviceClass.SPEED, icon="mdi:weather-windy", name="Wind gust", entity_registry_enabled_default=False, diff --git a/tests/components/accuweather/test_sensor.py b/tests/components/accuweather/test_sensor.py index 8612a805980..ababaea5443 100644 --- a/tests/components/accuweather/test_sensor.py +++ b/tests/components/accuweather/test_sensor.py @@ -49,6 +49,7 @@ async def test_sensor_without_forecast(hass): assert state.attributes.get(ATTR_ICON) == "mdi:weather-fog" assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == LENGTH_METERS assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DISTANCE entry = registry.async_get("sensor.home_cloud_ceiling") assert entry @@ -435,6 +436,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == SPEED_KILOMETERS_PER_HOUR assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind_gust") assert entry @@ -447,6 +449,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == SPEED_KILOMETERS_PER_HOUR assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind") assert entry @@ -579,6 +582,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == SPEED_KILOMETERS_PER_HOUR assert state.attributes.get("direction") == "SSE" assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind_day_0d") assert entry @@ -592,6 +596,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get("direction") == "WNW" assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" assert state.attributes.get(ATTR_STATE_CLASS) is None + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind_night_0d") assert entry @@ -605,6 +610,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get("direction") == "S" assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" assert state.attributes.get(ATTR_STATE_CLASS) is None + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind_gust_day_0d") assert entry @@ -618,6 +624,7 @@ async def test_sensor_enabled_without_forecast(hass): assert state.attributes.get("direction") == "WSW" assert state.attributes.get(ATTR_ICON) == "mdi:weather-windy" assert state.attributes.get(ATTR_STATE_CLASS) is None + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.SPEED entry = registry.async_get("sensor.home_wind_gust_night_0d") assert entry