From 0f2097595e30eb42084589b96c46730d58bec7b0 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 8 Dec 2022 20:57:51 +0100 Subject: [PATCH] Use new device class in netatmo (#83367) --- homeassistant/components/netatmo/sensor.py | 38 ++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/netatmo/sensor.py b/homeassistant/components/netatmo/sensor.py index 1fed7cf5e0e..4652f8a64a8 100644 --- a/homeassistant/components/netatmo/sensor.py +++ b/homeassistant/components/netatmo/sensor.py @@ -19,13 +19,13 @@ from homeassistant.const import ( ATTR_LONGITUDE, CONCENTRATION_PARTS_PER_MILLION, DEGREE, - LENGTH_MILLIMETERS, PERCENTAGE, - POWER_WATT, - PRESSURE_MBAR, SOUND_PRESSURE_DB, - SPEED_KILOMETERS_PER_HOUR, - TEMP_CELSIUS, + UnitOfPower, + UnitOfPrecipitationDepth, + UnitOfPressure, + UnitOfSpeed, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry as dr @@ -88,7 +88,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Temperature", netatmo_name="temperature", entity_registry_enabled_default=True, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.TEMPERATURE, ), @@ -113,7 +113,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Pressure", netatmo_name="pressure", entity_registry_enabled_default=True, - native_unit_of_measurement=PRESSURE_MBAR, + native_unit_of_measurement=UnitOfPressure.MBAR, state_class=SensorStateClass.MEASUREMENT, device_class=SensorDeviceClass.PRESSURE, ), @@ -147,27 +147,27 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Rain", netatmo_name="rain", entity_registry_enabled_default=True, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, - icon="mdi:weather-rainy", ), NetatmoSensorEntityDescription( key="sum_rain_1", name="Rain last hour", netatmo_name="sum_rain_1", entity_registry_enabled_default=False, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.TOTAL, - icon="mdi:weather-rainy", ), NetatmoSensorEntityDescription( key="sum_rain_24", name="Rain today", netatmo_name="sum_rain_24", entity_registry_enabled_default=True, - native_unit_of_measurement=LENGTH_MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.TOTAL_INCREASING, - icon="mdi:weather-rainy", ), NetatmoSensorEntityDescription( key="battery_percent", @@ -200,9 +200,8 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Wind Strength", 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", + native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR, + device_class=SensorDeviceClass.WIND_SPEED, state_class=SensorStateClass.MEASUREMENT, ), NetatmoSensorEntityDescription( @@ -226,9 +225,8 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Gust Strength", 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", + native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR, + device_class=SensorDeviceClass.WIND_SPEED, state_class=SensorStateClass.MEASUREMENT, ), NetatmoSensorEntityDescription( @@ -267,7 +265,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = ( name="Power", netatmo_name="power", entity_registry_enabled_default=True, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, state_class=SensorStateClass.TOTAL, device_class=SensorDeviceClass.POWER, ),