feat: make submersion-state, contact-state, occupancy-status as binary_sensor (#905)

This commit is contained in:
Necroneco
2025-03-27 15:45:46 +08:00
committed by GitHub
parent 19ed04f2f5
commit b0428dc95a
2 changed files with 21 additions and 0 deletions

View File

@@ -89,4 +89,8 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""On/Off state. True if the binary sensor is on, False otherwise."""
if self.spec.name == 'contact-state':
return self._value is False
elif self.spec.name == 'occupancy-status':
return bool(self._value)
return self._value is True