mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-18 08:00:42 +08:00
Merge 3546517093 into 9af59e28bd
This commit is contained in:
commit
0008c39795
@ -88,4 +88,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""On/Off state. True if the binary sensor is on, False otherwise."""
|
"""On/Off state. True if the binary sensor is on, False otherwise."""
|
||||||
|
"""If it is a door and windows sensor, revert the value."""
|
||||||
|
if self._attr_device_class == 'door':
|
||||||
|
return not (self._value is True)
|
||||||
return self._value is True
|
return self._value is True
|
||||||
|
|||||||
@ -47,6 +47,7 @@ Conversion rules of MIoT-Spec-V2 instance to Home Assistant entity.
|
|||||||
"""
|
"""
|
||||||
from homeassistant.components.sensor import SensorDeviceClass
|
from homeassistant.components.sensor import SensorDeviceClass
|
||||||
from homeassistant.components.event import EventDeviceClass
|
from homeassistant.components.event import EventDeviceClass
|
||||||
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||||
|
|
||||||
# pylint: disable=pointless-string-statement
|
# pylint: disable=pointless-string-statement
|
||||||
"""SPEC_DEVICE_TRANS_MAP
|
"""SPEC_DEVICE_TRANS_MAP
|
||||||
@ -336,6 +337,10 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = {
|
|||||||
'format': {'int', 'float'},
|
'format': {'int', 'float'},
|
||||||
'access': {'read'}
|
'access': {'read'}
|
||||||
},
|
},
|
||||||
|
'binary_sensor': {
|
||||||
|
'format': {'bool'},
|
||||||
|
'access': {'read'}
|
||||||
|
},
|
||||||
'switch': {
|
'switch': {
|
||||||
'format': {'bool'},
|
'format': {'bool'},
|
||||||
'access': {'read', 'write'}
|
'access': {'read', 'write'}
|
||||||
@ -391,6 +396,14 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = {
|
|||||||
'device_class': SensorDeviceClass.DURATION,
|
'device_class': SensorDeviceClass.DURATION,
|
||||||
'entity': 'sensor'
|
'entity': 'sensor'
|
||||||
},
|
},
|
||||||
|
'submersion-state': {
|
||||||
|
'device_class': BinarySensorDeviceClass.MOISTURE,
|
||||||
|
'entity': 'binary_sensor'
|
||||||
|
},
|
||||||
|
'contact-state': {
|
||||||
|
'device_class': BinarySensorDeviceClass.DOOR,
|
||||||
|
'entity': 'binary_sensor'
|
||||||
|
},
|
||||||
'has-someone-duration': 'no-one-determine-time',
|
'has-someone-duration': 'no-one-determine-time',
|
||||||
'no-one-duration': 'no-one-determine-time'
|
'no-one-duration': 'no-one-determine-time'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user