feat: add state_class for sensor

This commit is contained in:
tiger 2024-12-17 19:24:09 +08:00
parent 507018d4be
commit 6d2cb94284
2 changed files with 5 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class MIoTSpecBase:
# External params
platform: str
device_class: any
state_class: any
icon: str
external_unit: any
@ -96,6 +97,7 @@ class MIoTSpecBase:
self.platform = None
self.device_class = None
self.state_class = None
self.icon = None
self.external_unit = None

View File

@ -105,6 +105,9 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
# Set icon
if spec.icon:
self._attr_icon = spec.icon
# Set state_class
if spec.state_class:
self._attr_state_class = spec.state_class
@property
def native_value(self) -> any: