diff --git a/homeassistant/components/ambient_network/sensor.py b/homeassistant/components/ambient_network/sensor.py index eff99503cc8..9ec6db6ff45 100644 --- a/homeassistant/components/ambient_network/sensor.py +++ b/homeassistant/components/ambient_network/sensor.py @@ -239,6 +239,7 @@ SENSOR_DESCRIPTIONS = ( native_unit_of_measurement=DEGREE, suggested_display_precision=0, entity_registry_enabled_default=False, + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key=TYPE_WINDGUSTMPH, diff --git a/homeassistant/components/ambient_station/sensor.py b/homeassistant/components/ambient_station/sensor.py index d1ac39ba01a..730b798bd15 100644 --- a/homeassistant/components/ambient_station/sensor.py +++ b/homeassistant/components/ambient_station/sensor.py @@ -608,21 +608,25 @@ SENSOR_DESCRIPTIONS = ( key=TYPE_WINDDIR, translation_key="wind_direction", native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key=TYPE_WINDDIR_AVG10M, translation_key="wind_direction_average_10m", native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key=TYPE_WINDDIR_AVG2M, translation_key="wind_direction_average_2m", native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key=TYPE_WINDGUSTDIR, translation_key="wind_gust_direction", native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key=TYPE_WINDGUSTMPH, diff --git a/homeassistant/components/arwn/sensor.py b/homeassistant/components/arwn/sensor.py index ada96c07340..a31156bbba6 100644 --- a/homeassistant/components/arwn/sensor.py +++ b/homeassistant/components/arwn/sensor.py @@ -92,7 +92,12 @@ def discover_sensors(topic: str, payload: dict[str, Any]) -> list[ArwnSensor] | device_class=SensorDeviceClass.WIND_SPEED, ), ArwnSensor( - topic + "/dir", "Wind Direction", "direction", DEGREE, "mdi:compass" + topic + "/dir", + "Wind Direction", + "direction", + DEGREE, + "mdi:compass", + device_class=SensorDeviceClass.WIND_DIRECTION, ), ] return None diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index f9a110586ba..a4d39ea07cc 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -169,6 +169,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( translation_key="windazimuth", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="pressure", @@ -530,30 +531,35 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( translation_key="windazimuth_1d", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="windazimuth_2d", translation_key="windazimuth_2d", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="windazimuth_3d", translation_key="windazimuth_3d", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="windazimuth_4d", translation_key="windazimuth_4d", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="windazimuth_5d", translation_key="windazimuth_5d", native_unit_of_measurement=DEGREE, icon="mdi:compass-outline", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="condition_1d", diff --git a/homeassistant/components/ecowitt/sensor.py b/homeassistant/components/ecowitt/sensor.py index b7816de0f35..6968acdfa4f 100644 --- a/homeassistant/components/ecowitt/sensor.py +++ b/homeassistant/components/ecowitt/sensor.py @@ -65,7 +65,9 @@ ECOWITT_SENSORS_MAPPING: Final = { state_class=SensorStateClass.MEASUREMENT, ), EcoWittSensorTypes.DEGREE: SensorEntityDescription( - key="DEGREE", native_unit_of_measurement=DEGREE + key="DEGREE", + native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), EcoWittSensorTypes.WATT_METERS_SQUARED: SensorEntityDescription( key="WATT_METERS_SQUARED", diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index 93f3a0f0d80..3a789289c74 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -167,6 +167,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = ( translation_key="wind_bearing", native_unit_of_measurement=DEGREE, value_fn=lambda data: data.conditions.get("wind_bearing", {}).get("value"), + device_class=SensorDeviceClass.WIND_DIRECTION, ), ECSensorEntityDescription( key="wind_chill", diff --git a/homeassistant/components/homematic/sensor.py b/homeassistant/components/homematic/sensor.py index b33a725db0f..24172e196c1 100644 --- a/homeassistant/components/homematic/sensor.py +++ b/homeassistant/components/homematic/sensor.py @@ -177,6 +177,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = { "WIND_DIRECTION": SensorEntityDescription( key="WIND_DIRECTION", native_unit_of_measurement=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), "WIND_DIRECTION_RANGE": SensorEntityDescription( key="WIND_DIRECTION_RANGE", diff --git a/homeassistant/components/lacrosse_view/sensor.py b/homeassistant/components/lacrosse_view/sensor.py index ea5a82a3df8..667fcbb8dcc 100644 --- a/homeassistant/components/lacrosse_view/sensor.py +++ b/homeassistant/components/lacrosse_view/sensor.py @@ -105,6 +105,7 @@ SENSOR_DESCRIPTIONS = { value_fn=get_value, native_unit_of_measurement=DEGREE, suggested_display_precision=2, + device_class=SensorDeviceClass.WIND_DIRECTION, ), "WetDry": LaCrosseSensorEntityDescription( key="WetDry", diff --git a/homeassistant/components/meteoclimatic/sensor.py b/homeassistant/components/meteoclimatic/sensor.py index e51fcfd3f20..169da7a0a18 100644 --- a/homeassistant/components/meteoclimatic/sensor.py +++ b/homeassistant/components/meteoclimatic/sensor.py @@ -101,6 +101,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( name="Wind Bearing", native_unit_of_measurement=DEGREE, icon="mdi:weather-windy", + device_class=SensorDeviceClass.WIND_DIRECTION, ), SensorEntityDescription( key="rain", diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index 33f3d6afaf4..759cf7b010f 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -102,6 +102,7 @@ SENSORS: dict[str, SensorEntityDescription] = { key="V_DIRECTION", native_unit_of_measurement=DEGREE, icon="mdi:compass", + device_class=SensorDeviceClass.WIND_DIRECTION, ), "V_WEIGHT": SensorEntityDescription( key="V_WEIGHT", diff --git a/homeassistant/components/number/const.py b/homeassistant/components/number/const.py index bdde3a4567e..61a4fa644b0 100644 --- a/homeassistant/components/number/const.py +++ b/homeassistant/components/number/const.py @@ -11,6 +11,7 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, + DEGREE, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, @@ -424,6 +425,12 @@ class NumberDeviceClass(StrEnum): - USCS / imperial: `oz`, `lb` """ + WIND_DIRECTION = "wind_direction" + """Wind direction. + + Unit of measurement: `°` + """ + WIND_SPEED = "wind_speed" """Wind speed. @@ -516,6 +523,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = { UnitOfVolume.LITERS, }, NumberDeviceClass.WEIGHT: set(UnitOfMass), + NumberDeviceClass.WIND_DIRECTION: {DEGREE}, NumberDeviceClass.WIND_SPEED: set(UnitOfSpeed), } diff --git a/homeassistant/components/number/icons.json b/homeassistant/components/number/icons.json index 636fa0a7751..49103f5cd41 100644 --- a/homeassistant/components/number/icons.json +++ b/homeassistant/components/number/icons.json @@ -150,6 +150,9 @@ "weight": { "default": "mdi:weight" }, + "wind_direction": { + "default": "mdi:compass-rose" + }, "wind_speed": { "default": "mdi:weather-windy" } diff --git a/homeassistant/components/number/strings.json b/homeassistant/components/number/strings.json index cc77d224d72..993120ef3ad 100644 --- a/homeassistant/components/number/strings.json +++ b/homeassistant/components/number/strings.json @@ -169,6 +169,9 @@ "weight": { "name": "[%key:component::sensor::entity_component::weight::name%]" }, + "wind_direction": { + "name": "[%key:component::sensor::entity_component::wind_direction::name%]" + }, "wind_speed": { "name": "[%key:component::sensor::entity_component::wind_speed::name%]" } diff --git a/homeassistant/components/nws/sensor.py b/homeassistant/components/nws/sensor.py index 63579c95883..4cfb3b85e0f 100644 --- a/homeassistant/components/nws/sensor.py +++ b/homeassistant/components/nws/sensor.py @@ -114,6 +114,7 @@ SENSOR_TYPES: tuple[NWSSensorEntityDescription, ...] = ( icon="mdi:compass-rose", native_unit_of_measurement=DEGREE, unit_convert=DEGREE, + device_class=SensorDeviceClass.WIND_DIRECTION, ), NWSSensorEntityDescription( key="barometricPressure", diff --git a/homeassistant/components/sensor/const.py b/homeassistant/components/sensor/const.py index c46aca548c8..8eccb758756 100644 --- a/homeassistant/components/sensor/const.py +++ b/homeassistant/components/sensor/const.py @@ -11,6 +11,7 @@ from homeassistant.const import ( CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_MILLION, + DEGREE, LIGHT_LUX, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS, @@ -454,6 +455,12 @@ class SensorDeviceClass(StrEnum): - USCS / imperial: `oz`, `lb` """ + WIND_DIRECTION = "wind_direction" + """Wind direction. + + Unit of measurement: `°` + """ + WIND_SPEED = "wind_speed" """Wind speed. @@ -612,6 +619,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = { UnitOfVolume.LITERS, }, SensorDeviceClass.WEIGHT: set(UnitOfMass), + SensorDeviceClass.WIND_DIRECTION: {DEGREE}, SensorDeviceClass.WIND_SPEED: set(UnitOfSpeed), } @@ -683,5 +691,6 @@ DEVICE_CLASS_STATE_CLASSES: dict[SensorDeviceClass, set[SensorStateClass]] = { SensorStateClass.TOTAL, SensorStateClass.TOTAL_INCREASING, }, + SensorDeviceClass.WIND_DIRECTION: set(), SensorDeviceClass.WIND_SPEED: {SensorStateClass.MEASUREMENT}, } diff --git a/homeassistant/components/sensor/device_condition.py b/homeassistant/components/sensor/device_condition.py index 4a68fbabe8f..f52393f28ff 100644 --- a/homeassistant/components/sensor/device_condition.py +++ b/homeassistant/components/sensor/device_condition.py @@ -83,6 +83,7 @@ CONF_IS_VOLUME = "is_volume" CONF_IS_VOLUME_FLOW_RATE = "is_volume_flow_rate" CONF_IS_WATER = "is_water" CONF_IS_WEIGHT = "is_weight" +CONF_IS_WIND_DIRECTION = "is_wind_direction" CONF_IS_WIND_SPEED = "is_wind_speed" ENTITY_CONDITIONS = { @@ -145,6 +146,7 @@ ENTITY_CONDITIONS = { SensorDeviceClass.VOLUME_FLOW_RATE: [{CONF_TYPE: CONF_IS_VOLUME_FLOW_RATE}], SensorDeviceClass.WATER: [{CONF_TYPE: CONF_IS_WATER}], SensorDeviceClass.WEIGHT: [{CONF_TYPE: CONF_IS_WEIGHT}], + SensorDeviceClass.WIND_DIRECTION: [{CONF_TYPE: CONF_IS_WIND_DIRECTION}], SensorDeviceClass.WIND_SPEED: [{CONF_TYPE: CONF_IS_WIND_SPEED}], DEVICE_CLASS_NONE: [{CONF_TYPE: CONF_IS_VALUE}], } @@ -204,6 +206,7 @@ CONDITION_SCHEMA = vol.All( CONF_IS_VOLUME_FLOW_RATE, CONF_IS_WATER, CONF_IS_WEIGHT, + CONF_IS_WIND_DIRECTION, CONF_IS_WIND_SPEED, CONF_IS_VALUE, ] diff --git a/homeassistant/components/sensor/device_trigger.py b/homeassistant/components/sensor/device_trigger.py index 0003b83d05a..dee48434294 100644 --- a/homeassistant/components/sensor/device_trigger.py +++ b/homeassistant/components/sensor/device_trigger.py @@ -82,6 +82,7 @@ CONF_VOLUME = "volume" CONF_VOLUME_FLOW_RATE = "volume_flow_rate" CONF_WATER = "water" CONF_WEIGHT = "weight" +CONF_WIND_DIRECTION = "wind_direction" CONF_WIND_SPEED = "wind_speed" ENTITY_TRIGGERS = { @@ -144,6 +145,7 @@ ENTITY_TRIGGERS = { SensorDeviceClass.VOLUME_FLOW_RATE: [{CONF_TYPE: CONF_VOLUME_FLOW_RATE}], SensorDeviceClass.WATER: [{CONF_TYPE: CONF_WATER}], SensorDeviceClass.WEIGHT: [{CONF_TYPE: CONF_WEIGHT}], + SensorDeviceClass.WIND_DIRECTION: [{CONF_TYPE: CONF_WIND_DIRECTION}], SensorDeviceClass.WIND_SPEED: [{CONF_TYPE: CONF_WIND_SPEED}], DEVICE_CLASS_NONE: [{CONF_TYPE: CONF_VALUE}], } @@ -204,6 +206,7 @@ TRIGGER_SCHEMA = vol.All( CONF_VOLUME_FLOW_RATE, CONF_WATER, CONF_WEIGHT, + CONF_WIND_DIRECTION, CONF_WIND_SPEED, CONF_VALUE, ] diff --git a/homeassistant/components/sensor/icons.json b/homeassistant/components/sensor/icons.json index 5f770765ee3..497c1544b3b 100644 --- a/homeassistant/components/sensor/icons.json +++ b/homeassistant/components/sensor/icons.json @@ -156,6 +156,9 @@ "weight": { "default": "mdi:weight" }, + "wind_direction": { + "default": "mdi:compass-rose" + }, "wind_speed": { "default": "mdi:weather-windy" } diff --git a/homeassistant/components/sensor/strings.json b/homeassistant/components/sensor/strings.json index dcbb4d3c826..ae414a178e9 100644 --- a/homeassistant/components/sensor/strings.json +++ b/homeassistant/components/sensor/strings.json @@ -52,6 +52,7 @@ "is_volume_flow_rate": "Current {entity_name} volume flow rate", "is_water": "Current {entity_name} water", "is_weight": "Current {entity_name} weight", + "is_wind_direction": "Current {entity_name} wind direction", "is_wind_speed": "Current {entity_name} wind speed" }, "trigger_type": { @@ -105,6 +106,7 @@ "volume_flow_rate": "{entity_name} volume flow rate changes", "water": "{entity_name} water changes", "weight": "{entity_name} weight changes", + "wind_direction": "{entity_name} wind direction changes", "wind_speed": "{entity_name} wind speed changes" }, "extra_fields": { @@ -299,6 +301,9 @@ "weight": { "name": "Weight" }, + "wind_direction": { + "name": "Wind direction" + }, "wind_speed": { "name": "Wind speed" } diff --git a/tests/components/ambient_network/snapshots/test_sensor.ambr b/tests/components/ambient_network/snapshots/test_sensor.ambr index 7266afcfd96..8637471cc60 100644 --- a/tests/components/ambient_network/snapshots/test_sensor.ambr +++ b/tests/components/ambient_network/snapshots/test_sensor.ambr @@ -836,7 +836,7 @@ 'suggested_display_precision': 0, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Wind direction', 'platform': 'ambient_network', @@ -851,6 +851,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Data provided by ambientnetwork.net', + 'device_class': 'wind_direction', 'friendly_name': 'Station A Wind direction', 'last_measured': HAFakeDatetime(2023, 11, 8, 12, 12, 0, 914000, tzinfo=zoneinfo.ZoneInfo(key='US/Pacific')), 'unit_of_measurement': '°', @@ -1820,7 +1821,7 @@ 'suggested_display_precision': 0, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Wind direction', 'platform': 'ambient_network', @@ -1835,6 +1836,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Data provided by ambientnetwork.net', + 'device_class': 'wind_direction', 'friendly_name': 'Station C Wind direction', 'last_measured': HAFakeDatetime(2024, 6, 6, 8, 28, 3, tzinfo=zoneinfo.ZoneInfo(key='US/Pacific')), 'unit_of_measurement': '°', @@ -2741,7 +2743,7 @@ 'suggested_display_precision': 0, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Wind direction', 'platform': 'ambient_network', @@ -2756,6 +2758,7 @@ StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Data provided by ambientnetwork.net', + 'device_class': 'wind_direction', 'friendly_name': 'Station D Wind direction', 'unit_of_measurement': '°', }),