From f852934f29d5d983dcbf57309b871e8ef7d001a2 Mon Sep 17 00:00:00 2001 From: Alone Date: Fri, 20 Dec 2024 11:36:33 +0800 Subject: [PATCH] fix: use binary sensor to implement read-only bool property --- custom_components/xiaomi_home/miot/miot_device.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/miot/miot_device.py b/custom_components/xiaomi_home/miot/miot_device.py index fa48345..66f7c3c 100644 --- a/custom_components/xiaomi_home/miot/miot_device.py +++ b/custom_components/xiaomi_home/miot/miot_device.py @@ -560,7 +560,10 @@ def spec_transform(self) -> None: # Irregular property will not be transformed. pass elif prop.readable or prop.notifiable: - prop.platform = 'sensor' + if prop.format_ == 'bool': + prop.platform = 'binary_sensor' + else: + prop.platform = 'sensor' if prop.platform: self.append_prop(prop=prop) # STEP 3.2: event conversion