mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-18 16:10:44 +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
|
# External params
|
||||||
platform: str
|
platform: str
|
||||||
device_class: any
|
device_class: any
|
||||||
|
state_class: any
|
||||||
icon: str
|
icon: str
|
||||||
external_unit: any
|
external_unit: any
|
||||||
|
|
||||||
@ -96,6 +97,7 @@ class MIoTSpecBase:
|
|||||||
|
|
||||||
self.platform = None
|
self.platform = None
|
||||||
self.device_class = None
|
self.device_class = None
|
||||||
|
self.state_class = None
|
||||||
self.icon = None
|
self.icon = None
|
||||||
self.external_unit = None
|
self.external_unit = None
|
||||||
|
|
||||||
|
|||||||
@ -105,6 +105,9 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
|
|||||||
# Set icon
|
# Set icon
|
||||||
if spec.icon:
|
if spec.icon:
|
||||||
self._attr_icon = spec.icon
|
self._attr_icon = spec.icon
|
||||||
|
# Set state_class
|
||||||
|
if spec.state_class:
|
||||||
|
self._attr_state_class = spec.state_class
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> any:
|
def native_value(self) -> any:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user