From 8c2cfe0281b1951c2cdaa01d48082e9af4a6b4d9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:19:34 +0200 Subject: [PATCH] Use SensorDeviceClass.DISTANCE in components (#79285) * Use SensorDeviceClass.DISTANCE in components * Adjust mysensors --- homeassistant/components/buienradar/sensor.py | 1 + homeassistant/components/environment_canada/sensor.py | 1 + homeassistant/components/metoffice/sensor.py | 2 +- homeassistant/components/mysensors/sensor.py | 1 + homeassistant/components/opengarage/sensor.py | 1 + homeassistant/components/starline/sensor.py | 1 + homeassistant/components/wallbox/sensor.py | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index 08303120a92..279fdc145d5 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -170,6 +170,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="visibility", name="Visibility", native_unit_of_measurement=LENGTH_KILOMETERS, + device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index 5f22b251493..88ec055ad03 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -172,6 +172,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = ( key="visibility", name="Visibility", native_unit_of_measurement=LENGTH_KILOMETERS, + device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, value_fn=lambda data: data.conditions.get("visibility", {}).get("value"), ), diff --git a/homeassistant/components/metoffice/sensor.py b/homeassistant/components/metoffice/sensor.py index c553904a895..77532b379b6 100644 --- a/homeassistant/components/metoffice/sensor.py +++ b/homeassistant/components/metoffice/sensor.py @@ -114,8 +114,8 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="visibility_distance", name="Visibility distance", - device_class=None, native_unit_of_measurement=LENGTH_KILOMETERS, + device_class=SensorDeviceClass.DISTANCE, icon="mdi:eye", entity_registry_enabled_default=False, ), diff --git a/homeassistant/components/mysensors/sensor.py b/homeassistant/components/mysensors/sensor.py index dd10c203228..59c33a48884 100644 --- a/homeassistant/components/mysensors/sensor.py +++ b/homeassistant/components/mysensors/sensor.py @@ -100,6 +100,7 @@ SENSORS: dict[str, SensorEntityDescription] = { "V_DISTANCE": SensorEntityDescription( key="V_DISTANCE", native_unit_of_measurement=LENGTH_METERS, + device_class=SensorDeviceClass.DISTANCE, icon="mdi:ruler", ), "V_IMPEDANCE": SensorEntityDescription( diff --git a/homeassistant/components/opengarage/sensor.py b/homeassistant/components/opengarage/sensor.py index d09ed130152..bf75cd34998 100644 --- a/homeassistant/components/opengarage/sensor.py +++ b/homeassistant/components/opengarage/sensor.py @@ -29,6 +29,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="dist", native_unit_of_measurement=LENGTH_CENTIMETERS, + device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/homeassistant/components/starline/sensor.py b/homeassistant/components/starline/sensor.py index d4ea2d02555..588b9f93e08 100644 --- a/homeassistant/components/starline/sensor.py +++ b/homeassistant/components/starline/sensor.py @@ -81,6 +81,7 @@ SENSOR_TYPES: tuple[StarlineSensorEntityDescription, ...] = ( key="mileage", name_="Mileage", native_unit_of_measurement=LENGTH_KILOMETERS, + device_class=SensorDeviceClass.DISTANCE, icon="mdi:counter", ), ) diff --git a/homeassistant/components/wallbox/sensor.py b/homeassistant/components/wallbox/sensor.py index 2c4a8c67bed..1fae68da2e4 100644 --- a/homeassistant/components/wallbox/sensor.py +++ b/homeassistant/components/wallbox/sensor.py @@ -85,6 +85,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = { name="Added Range", precision=0, native_unit_of_measurement=LENGTH_KILOMETERS, + device_class=SensorDeviceClass.DISTANCE, state_class=SensorStateClass.TOTAL_INCREASING, ), CHARGER_ADDED_ENERGY_KEY: WallboxSensorEntityDescription(