mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use enums in wiffi (#61984)
This commit is contained in:
parent
e1f5b63f1e
commit
9084a227fd
@ -1,13 +1,9 @@
|
|||||||
"""Sensor platform support for wiffi devices."""
|
"""Sensor platform support for wiffi devices."""
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_HUMIDITY,
|
SensorDeviceClass,
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
|
||||||
DEVICE_CLASS_PRESSURE,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import DEGREE, PRESSURE_MBAR, TEMP_CELSIUS
|
from homeassistant.const import DEGREE, PRESSURE_MBAR, TEMP_CELSIUS
|
||||||
from homeassistant.core import callback
|
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
|
# map to determine HA device class from wiffi's unit of measurement
|
||||||
UOM_TO_DEVICE_CLASS_MAP = {
|
UOM_TO_DEVICE_CLASS_MAP = {
|
||||||
WIFFI_UOM_TEMP_CELSIUS: DEVICE_CLASS_TEMPERATURE,
|
WIFFI_UOM_TEMP_CELSIUS: SensorDeviceClass.TEMPERATURE,
|
||||||
WIFFI_UOM_PERCENT: DEVICE_CLASS_HUMIDITY,
|
WIFFI_UOM_PERCENT: SensorDeviceClass.HUMIDITY,
|
||||||
WIFFI_UOM_MILLI_BAR: DEVICE_CLASS_PRESSURE,
|
WIFFI_UOM_MILLI_BAR: SensorDeviceClass.PRESSURE,
|
||||||
WIFFI_UOM_LUX: DEVICE_CLASS_ILLUMINANCE,
|
WIFFI_UOM_LUX: SensorDeviceClass.ILLUMINANCE,
|
||||||
}
|
}
|
||||||
|
|
||||||
# map to convert wiffi unit of measurements to common HA uom's
|
# map to convert wiffi unit of measurements to common HA uom's
|
||||||
@ -74,9 +70,9 @@ class NumberEntity(WiffiEntity, SensorEntity):
|
|||||||
self._value = metric.value
|
self._value = metric.value
|
||||||
|
|
||||||
if self._is_measurement_entity():
|
if self._is_measurement_entity():
|
||||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
elif self._is_metered_entity():
|
elif self._is_metered_entity():
|
||||||
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
|
|
||||||
self.reset_expiration_date()
|
self.reset_expiration_date()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user