mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-15 22:10:43 +08:00
feat: set default sensor state_class
This commit is contained in:
parent
d5e243caf0
commit
e7564b0152
@ -159,7 +159,7 @@ class XiaomiMihomeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self._area_name_rule = self.DEFAULT_AREA_NAME_RULE
|
||||
self._action_debug = False
|
||||
self._hide_non_standard_entities = False
|
||||
self._display_binary_mode = ['text']
|
||||
self._display_binary_mode = ['bool']
|
||||
self._display_devices_changed_notify = ['add', 'del', 'offline']
|
||||
self._auth_info = {}
|
||||
self._nick_name = DEFAULT_NICK_NAME
|
||||
|
||||
@ -53,7 +53,7 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.components.sensor import SensorEntity, SensorDeviceClass
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_UNITS
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_UNITS, SensorStateClass
|
||||
|
||||
from .miot.miot_device import MIoTDevice, MIoTPropertyEntity
|
||||
from .miot.miot_spec import MIoTSpecProperty
|
||||
@ -115,6 +115,9 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
|
||||
# Set state_class
|
||||
if spec.state_class:
|
||||
self._attr_state_class = spec.state_class
|
||||
else:
|
||||
# Set default state_class
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
@property
|
||||
def native_value(self) -> Any:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user