From 9084a227fdacc164df5ccd9fbf2c022576c3d6da Mon Sep 17 00:00:00 2001 From: Robert Hillis Date: Thu, 16 Dec 2021 03:01:20 -0500 Subject: [PATCH] Use enums in wiffi (#61984) --- homeassistant/components/wiffi/sensor.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/wiffi/sensor.py b/homeassistant/components/wiffi/sensor.py index c16ae3c6aca..e65debedc36 100644 --- a/homeassistant/components/wiffi/sensor.py +++ b/homeassistant/components/wiffi/sensor.py @@ -1,13 +1,9 @@ """Sensor platform support for wiffi devices.""" from homeassistant.components.sensor import ( - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_ILLUMINANCE, - DEVICE_CLASS_PRESSURE, - DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - STATE_CLASS_TOTAL_INCREASING, + SensorDeviceClass, SensorEntity, + SensorStateClass, ) from homeassistant.const import DEGREE, PRESSURE_MBAR, TEMP_CELSIUS from homeassistant.core import callback @@ -25,10 +21,10 @@ from .wiffi_strings import ( # map to determine HA device class from wiffi's unit of measurement UOM_TO_DEVICE_CLASS_MAP = { - WIFFI_UOM_TEMP_CELSIUS: DEVICE_CLASS_TEMPERATURE, - WIFFI_UOM_PERCENT: DEVICE_CLASS_HUMIDITY, - WIFFI_UOM_MILLI_BAR: DEVICE_CLASS_PRESSURE, - WIFFI_UOM_LUX: DEVICE_CLASS_ILLUMINANCE, + WIFFI_UOM_TEMP_CELSIUS: SensorDeviceClass.TEMPERATURE, + WIFFI_UOM_PERCENT: SensorDeviceClass.HUMIDITY, + WIFFI_UOM_MILLI_BAR: SensorDeviceClass.PRESSURE, + WIFFI_UOM_LUX: SensorDeviceClass.ILLUMINANCE, } # map to convert wiffi unit of measurements to common HA uom's @@ -74,9 +70,9 @@ class NumberEntity(WiffiEntity, SensorEntity): self._value = metric.value if self._is_measurement_entity(): - self._attr_state_class = STATE_CLASS_MEASUREMENT + self._attr_state_class = SensorStateClass.MEASUREMENT elif self._is_metered_entity(): - self._attr_state_class = STATE_CLASS_TOTAL_INCREASING + self._attr_state_class = SensorStateClass.TOTAL_INCREASING self.reset_expiration_date()