mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-15 22:10:43 +08:00
feat: add state_class for sensor
This commit is contained in:
parent
507018d4be
commit
6d2cb94284
@ -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
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user