mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +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 (
|
from homeassistant.components.sensor import (
|
||||||
ATTR_LAST_RESET,
|
ATTR_LAST_RESET,
|
||||||
STATE_CLASS_TOTAL,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
EVENT_HOMEASSISTANT_START,
|
EVENT_HOMEASSISTANT_START,
|
||||||
@ -78,8 +77,8 @@ ATTR_LAST_PERIOD = "last_period"
|
|||||||
ATTR_TARIFF = "tariff"
|
ATTR_TARIFF = "tariff"
|
||||||
|
|
||||||
DEVICE_CLASS_MAP = {
|
DEVICE_CLASS_MAP = {
|
||||||
ENERGY_WATT_HOUR: DEVICE_CLASS_ENERGY,
|
ENERGY_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||||
ENERGY_KILO_WATT_HOUR: DEVICE_CLASS_ENERGY,
|
ENERGY_KILO_WATT_HOUR: SensorDeviceClass.ENERGY,
|
||||||
}
|
}
|
||||||
|
|
||||||
ICON = "mdi:counter"
|
ICON = "mdi:counter"
|
||||||
@ -370,9 +369,9 @@ class UtilityMeterSensor(RestoreEntity, SensorEntity):
|
|||||||
def state_class(self):
|
def state_class(self):
|
||||||
"""Return the device class of the sensor."""
|
"""Return the device class of the sensor."""
|
||||||
return (
|
return (
|
||||||
STATE_CLASS_TOTAL
|
SensorStateClass.TOTAL
|
||||||
if self._sensor_net_consumption
|
if self._sensor_net_consumption
|
||||||
else STATE_CLASS_TOTAL_INCREASING
|
else SensorStateClass.TOTAL_INCREASING
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user