mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Use enums in utility_meter (#62033)
This commit is contained in:
parent
94ae6ac2b2
commit
44f4656fe6
@ -8,14 +8,13 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_LAST_RESET,
|
||||
STATE_CLASS_TOTAL,
|
||||
STATE_CLASS_TOTAL_INCREASING,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_UNIT_OF_MEASUREMENT,
|
||||
CONF_NAME,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
@ -78,8 +77,8 @@ ATTR_LAST_PERIOD = "last_period"
|
||||
ATTR_TARIFF = "tariff"
|
||||
|
||||
DEVICE_CLASS_MAP = {
|
||||
ENERGY_WATT_HOUR: DEVICE_CLASS_ENERGY,
|
||||
ENERGY_KILO_WATT_HOUR: DEVICE_CLASS_ENERGY,
|
||||
ENERGY_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
ENERGY_KILO_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||
}
|
||||
|
||||
ICON = "mdi:counter"
|
||||
@ -370,9 +369,9 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
||||
def state_class(self):
|
||||
"""Return the device class of the sensor."""
|
||||
return (
|
||||
STATE_CLASS_TOTAL
|
||||
SensorStateClass.TOTAL
|
||||
if self._sensor_net_consumption
|
||||
else STATE_CLASS_TOTAL_INCREASING
|
||||
else SensorStateClass.TOTAL_INCREASING
|
||||
)
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user