From f2200ba003947ad93dbd2a63e76d83a2f19e6d4b Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Fri, 29 Aug 2025 17:36:25 +0800 Subject: [PATCH] fix: contact-state value format (#1387) --- custom_components/xiaomi_home/binary_sensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_home/binary_sensor.py b/custom_components/xiaomi_home/binary_sensor.py index 8019104..b2d00b6 100644 --- a/custom_components/xiaomi_home/binary_sensor.py +++ b/custom_components/xiaomi_home/binary_sensor.py @@ -70,8 +70,8 @@ async def async_setup_entry( for miot_device in device_list: if miot_device.miot_client.display_binary_bool: for prop in miot_device.prop_list.get('binary_sensor', []): - new_entities.append(BinarySensor( - miot_device=miot_device, spec=prop)) + new_entities.append( + BinarySensor(miot_device=miot_device, spec=prop)) if new_entities: async_add_entities(new_entities) @@ -90,7 +90,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity): 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 + return bool(self._value) is False elif self.spec.name == 'occupancy-status': return bool(self._value) return self._value is True