From b4daa88d9e9aa712db238971e8c5398a5268761b Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Thu, 16 Dec 2021 07:05:46 -0500 Subject: [PATCH] Use enums in trafikverket_weatherstation (#62027) --- .../trafikverket_weatherstation/sensor.py | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/trafikverket_weatherstation/sensor.py b/homeassistant/components/trafikverket_weatherstation/sensor.py index 01b70d5d3c7..e564002c61c 100644 --- a/homeassistant/components/trafikverket_weatherstation/sensor.py +++ b/homeassistant/components/trafikverket_weatherstation/sensor.py @@ -13,9 +13,10 @@ import voluptuous as vol from homeassistant.components.sensor import ( PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA, - STATE_CLASS_MEASUREMENT, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( @@ -24,8 +25,6 @@ from homeassistant.const import ( CONF_MONITORED_CONDITIONS, CONF_NAME, DEGREE, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_TEMPERATURE, LENGTH_MILLIMETERS, PERCENTAGE, SPEED_METERS_PER_SECOND, @@ -71,8 +70,8 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Air temperature", native_unit_of_measurement=TEMP_CELSIUS, icon="mdi:thermometer", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="road_temp", @@ -80,8 +79,8 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Road temperature", native_unit_of_measurement=TEMP_CELSIUS, icon="mdi:thermometer", - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="precipitation", @@ -96,7 +95,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Wind direction", native_unit_of_measurement=DEGREE, icon="mdi:flag-triangle", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="wind_direction_text", @@ -110,7 +109,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Wind speed", native_unit_of_measurement=SPEED_METERS_PER_SECOND, icon="mdi:weather-windy", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="wind_speed_max", @@ -119,7 +118,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( native_unit_of_measurement=SPEED_METERS_PER_SECOND, icon="mdi:weather-windy-variant", entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="humidity", @@ -127,9 +126,9 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Humidity", native_unit_of_measurement=PERCENTAGE, icon="mdi:water-percent", - device_class=DEVICE_CLASS_HUMIDITY, + device_class=SensorDeviceClass.HUMIDITY, entity_registry_enabled_default=False, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="precipitation_amount", @@ -137,7 +136,7 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = ( name="Precipitation amount", native_unit_of_measurement=LENGTH_MILLIMETERS, icon="mdi:cup-water", - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), TrafikverketSensorEntityDescription( key="precipitation_amountname",