fix: revert value of door and windows sensor with binary sensor class

fix: revert value of door and windows sensor with binary sensor class

Binary sensor class in Home Assistant uses true to indicate open, which is opposite of Xiaomi Home.
This commit reverts the value of  door and windows sensor to make them the same.
This commit is contained in:
Yi Zhai 2024-12-19 16:59:39 +08:00 committed by GitHub
parent 162f943924
commit 9cc2c52d44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,4 +88,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""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