Use new DeviceClass and StateClass enums in aseko_pool_live (#61276)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-08 21:57:25 +01:00 committed by GitHub
parent 25db4a4f1f
commit d2216363c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,9 +3,12 @@ from __future__ import annotations
from aioaseko import Unit, Variable
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_CLASS_TEMPERATURE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -33,7 +36,7 @@ async def async_setup_entry(
class VariableSensorEntity(AsekoEntity, SensorEntity):
"""Representation of a unit variable sensor entity."""
attr_state_class = STATE_CLASS_MEASUREMENT
attr_state_class = SensorStateClass.MEASUREMENT
def __init__(
self, unit: Unit, variable: Variable, coordinator: AsekoDataUpdateCoordinator
@ -61,8 +64,8 @@ class VariableSensorEntity(AsekoEntity, SensorEntity):
}.get(self._variable.type)
self._attr_device_class = {
"airTemp": DEVICE_CLASS_TEMPERATURE,
"waterTemp": DEVICE_CLASS_TEMPERATURE,
"airTemp": SensorDeviceClass.TEMPERATURE,
"waterTemp": SensorDeviceClass.TEMPERATURE,
}.get(self._variable.type)
@property