From 2e0fc65bf3e3f7491474b2e1de72197049f31b22 Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Thu, 16 Dec 2021 03:01:46 -0500 Subject: [PATCH] Use enums in wirelesstag (#61985) --- .../components/wirelesstag/sensor.py | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/wirelesstag/sensor.py b/homeassistant/components/wirelesstag/sensor.py index 8038b42bffe..5c7de69cc2a 100644 --- a/homeassistant/components/wirelesstag/sensor.py +++ b/homeassistant/components/wirelesstag/sensor.py @@ -7,16 +7,12 @@ import voluptuous as vol from homeassistant.components.sensor import ( PLATFORM_SCHEMA, - STATE_CLASS_MEASUREMENT, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) -from homeassistant.const import ( - CONF_MONITORED_CONDITIONS, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_TEMPERATURE, -) +from homeassistant.const import CONF_MONITORED_CONDITIONS from homeassistant.core import callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -34,28 +30,28 @@ SENSOR_LIGHT = "light" SENSOR_TYPES: dict[str, SensorEntityDescription] = { SENSOR_TEMPERATURE: SensorEntityDescription( key=SENSOR_TEMPERATURE, - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), SENSOR_AMBIENT_TEMPERATURE: SensorEntityDescription( key=SENSOR_AMBIENT_TEMPERATURE, - device_class=DEVICE_CLASS_TEMPERATURE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.TEMPERATURE, + state_class=SensorStateClass.MEASUREMENT, ), SENSOR_HUMIDITY: SensorEntityDescription( key=SENSOR_HUMIDITY, - device_class=DEVICE_CLASS_HUMIDITY, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.HUMIDITY, + state_class=SensorStateClass.MEASUREMENT, ), SENSOR_MOISTURE: SensorEntityDescription( key=SENSOR_MOISTURE, device_class=SENSOR_MOISTURE, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ), SENSOR_LIGHT: SensorEntityDescription( key=SENSOR_LIGHT, - device_class=DEVICE_CLASS_ILLUMINANCE, - state_class=STATE_CLASS_MEASUREMENT, + device_class=SensorDeviceClass.ILLUMINANCE, + state_class=SensorStateClass.MEASUREMENT, ), }