Use SensorDeviceClass.SPEED in components (#79262)

pull/79276/head
epenet 2022-09-29 09:37:21 +02:00 committed by GitHub
parent a0357767ef
commit 0e764b57c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 0 deletions

View File

@ -308,6 +308,7 @@ SENSOR_DESCRIPTIONS = (
name="Max gust",
icon="mdi:weather-windy",
native_unit_of_measurement=SPEED_MILES_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
@ -631,6 +632,7 @@ SENSOR_DESCRIPTIONS = (
name="Wind gust",
icon="mdi:weather-windy",
native_unit_of_measurement=SPEED_MILES_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
@ -638,18 +640,21 @@ SENSOR_DESCRIPTIONS = (
name="Wind avg 10m",
icon="mdi:weather-windy",
native_unit_of_measurement=SPEED_MILES_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
),
SensorEntityDescription(
key=TYPE_WINDSPDMPH_AVG2M,
name="Wind avg 2m",
icon="mdi:weather-windy",
native_unit_of_measurement=SPEED_MILES_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
),
SensorEntityDescription(
key=TYPE_WINDSPEEDMPH,
name="Wind speed",
icon="mdi:weather-windy",
native_unit_of_measurement=SPEED_MILES_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(

View File

@ -138,6 +138,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="windspeed",
name="Wind speed",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT,
),
@ -175,6 +176,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="windgust",
name="Wind gust",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(
@ -463,30 +465,35 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="windspeed_1d",
name="Wind speed 1d",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(
key="windspeed_2d",
name="Wind speed 2d",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(
key="windspeed_3d",
name="Wind speed 3d",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(
key="windspeed_4d",
name="Wind speed 4d",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(
key="windspeed_5d",
name="Wind speed 5d",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
SensorEntityDescription(

View File

@ -198,6 +198,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
key="wind_gust",
name="Wind gust",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.conditions.get("wind_gust", {}).get("value"),
),
@ -205,6 +206,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
key="wind_speed",
name="Wind speed",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: data.conditions.get("wind_speed", {}).get("value"),
),

View File

@ -170,6 +170,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
"WIND_SPEED": SensorEntityDescription(
key="WIND_SPEED",
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
),
"WIND_DIRECTION": SensorEntityDescription(

View File

@ -344,6 +344,8 @@ class HomematicipEnergySensor(HomematicipGenericEntity, SensorEntity):
class HomematicipWindspeedSensor(HomematicipGenericEntity, SensorEntity):
"""Representation of the HomematicIP wind speed sensor."""
_attr_device_class = SensorDeviceClass.SPEED
def __init__(self, hap: HomematicipHAP, device) -> None:
"""Initialize the windspeed sensor."""
super().__init__(hap, device, post="Windspeed")

View File

@ -81,6 +81,7 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
value_fn=get_value,
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
),
"Rain": LaCrosseSensorEntityDescription(
key="Rain",

View File

@ -200,6 +200,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
netatmo_name="wind_strength",
entity_registry_enabled_default=True,
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT,
),
@ -225,6 +226,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
netatmo_name="gust_strength",
entity_registry_enabled_default=False,
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT,
),

View File

@ -76,12 +76,14 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
key=SENSOR_TYPE_WINDAVERAGE,
name="Wind average",
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_TYPE_WINDGUST: SensorEntityDescription(
key=SENSOR_TYPE_WINDGUST,
name="Wind gust",
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
device_class=SensorDeviceClass.SPEED,
state_class=SensorStateClass.MEASUREMENT,
),
SENSOR_TYPE_UV: SensorEntityDescription(

View File

@ -89,6 +89,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
api_key="windforce",
name="Wind speed",
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT,
),
@ -97,6 +98,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
api_key="windforcemax",
name="Wind speed max",
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
device_class=SensorDeviceClass.SPEED,
icon="mdi:weather-windy-variant",
entity_registry_enabled_default=False,
state_class=SensorStateClass.MEASUREMENT,