Use new DeviceClass and StateClass enums in atome (#61284)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61231/head
epenet 2021-12-08 22:03:24 +01:00 committed by GitHub
parent aca2c3a27a
commit fd7328ce23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -7,16 +7,14 @@ import voluptuous as vol
from homeassistant.components.sensor import (
PLATFORM_SCHEMA,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import (
CONF_NAME,
CONF_PASSWORD,
CONF_USERNAME,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
)
@ -253,13 +251,13 @@ class AtomeSensor(SensorEntity):
self._sensor_type = sensor_type
if sensor_type == LIVE_TYPE:
self._attr_device_class = DEVICE_CLASS_POWER
self._attr_device_class = SensorDeviceClass.POWER
self._attr_native_unit_of_measurement = POWER_WATT
self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_state_class = SensorStateClass.MEASUREMENT
else:
self._attr_device_class = DEVICE_CLASS_ENERGY
self._attr_device_class = SensorDeviceClass.ENERGY
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
def update(self):
"""Update device state."""