Add state class to screenlogic sensors (#64941)

pull/64956/head
J. Nick Koston 2022-01-25 18:35:44 -10:00 committed by GitHub
parent cb571d86be
commit 87d1478ca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -6,7 +6,11 @@ from screenlogicpy.const import (
EQUIPMENT,
)
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -122,6 +126,13 @@ class ScreenLogicSensor(ScreenlogicEntity, SensorEntity):
device_type = self.sensor.get("device_type")
return SL_DEVICE_TYPE_TO_HA_DEVICE_CLASS.get(device_type)
@property
def state_class(self):
"""Return the state class of the sensor."""
if self._data_key == "scg_super_chlor_timer":
return None
return SensorStateClass.MEASUREMENT
@property
def native_value(self):
"""State of the sensor."""