mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-20 09:19:37 +08:00
fix: fix sensor entity type error
This commit is contained in:
parent
e7564b0152
commit
22f843d7ff
@ -106,18 +106,15 @@ class Sensor(MIoTPropertyEntity, SensorEntity):
|
|||||||
# device_class is not empty but unit is empty.
|
# device_class is not empty but unit is empty.
|
||||||
# Set the default unit according to device_class.
|
# Set the default unit according to device_class.
|
||||||
unit_sets = DEVICE_CLASS_UNITS.get(
|
unit_sets = DEVICE_CLASS_UNITS.get(
|
||||||
self._attr_device_class, None)
|
self._attr_device_class, None) # type: ignore
|
||||||
self._attr_native_unit_of_measurement = list(
|
self._attr_native_unit_of_measurement = list(
|
||||||
unit_sets)[0] if unit_sets else None
|
unit_sets)[0] if unit_sets else None
|
||||||
# Set icon
|
|
||||||
if spec.icon:
|
|
||||||
self._attr_icon = spec.icon
|
|
||||||
# Set state_class
|
# Set state_class
|
||||||
if spec.state_class:
|
if spec.state_class:
|
||||||
self._attr_state_class = spec.state_class
|
self._attr_state_class = spec.state_class
|
||||||
else:
|
# Set icon
|
||||||
# Set default state_class
|
if spec.icon:
|
||||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
self._attr_icon = spec.icon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> Any:
|
def native_value(self) -> Any:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user