From 4bd686bdb19471f09d662d917c56c6b79662fc54 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 08303120a9..279fdc145d 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 5f22b25149..88ec055ad0 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 c553904a89..77532b379b 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 dd10c20322..59c33a4888 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 d09ed13015..bf75cd3499 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 d4ea2d0255..588b9f93e0 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 2c4a8c67be..1fae68da2e 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(