From 073cdf2dcb9c623cb72721c00f680092e3312ef8 Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Fri, 29 Aug 2025 17:35:46 +0800 Subject: [PATCH 1/3] fix: integer value step (#1388) --- custom_components/xiaomi_home/miot/miot_spec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/miot/miot_spec.py b/custom_components/xiaomi_home/miot/miot_spec.py index 9cabdcb..7f6a5b2 100644 --- a/custom_components/xiaomi_home/miot/miot_spec.py +++ b/custom_components/xiaomi_home/miot/miot_spec.py @@ -601,7 +601,10 @@ class MIoTSpecProperty(_MIoTSpecBase): if value is None: return None if self.format_ == int: - return int(round(value)) + if self.value_range is None: + return int(round(value)) + return int( + round(value / self.value_range.step) * self.value_range.step) if self.format_ == float: return round(value, self.precision) if self.format_ == bool: From f2200ba003947ad93dbd2a63e76d83a2f19e6d4b Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Fri, 29 Aug 2025 17:36:25 +0800 Subject: [PATCH 2/3] 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 From ec833b6539963aeabe4f03ce929d429f3009c620 Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Tue, 2 Sep 2025 17:22:40 +0800 Subject: [PATCH 3/3] feat: subscribe the proxy gateway child device up messages even though the device is offline (#1393) * feat: subscribe the proxy gateway child device up messages even though the device is offline (#1313) * feat: do not subscribe proxy gateway child device online/offline state message --- custom_components/xiaomi_home/miot/miot_client.py | 7 +++++-- custom_components/xiaomi_home/miot/miot_mips.py | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/custom_components/xiaomi_home/miot/miot_client.py b/custom_components/xiaomi_home/miot/miot_client.py index f8f3141..e6fe6a8 100644 --- a/custom_components/xiaomi_home/miot/miot_client.py +++ b/custom_components/xiaomi_home/miot/miot_client.py @@ -1374,10 +1374,13 @@ class MIoTClient: """Update cloud devices. NOTICE: This function will operate the cloud_list """ - # MIoT cloud service may not publish the online state updating message + # MIoT cloud may not publish the online state updating message # for the BLE device. Assume that all BLE devices are online. + # MIoT cloud does not publish the online state updating message for the + # child device under the proxy gateway (eg, VRF air conditioner + # controller). Assume that all proxy gateway child devices are online. for did, info in cloud_list.items(): - if did.startswith('blt.'): + if did.startswith('blt.') or did.startswith('proxy.'): info['online'] = True for did, info in self._device_list_cache.items(): if filter_dids and did not in filter_dids: diff --git a/custom_components/xiaomi_home/miot/miot_mips.py b/custom_components/xiaomi_home/miot/miot_mips.py index 8c51c8b..6e7186d 100644 --- a/custom_components/xiaomi_home/miot/miot_mips.py +++ b/custom_components/xiaomi_home/miot/miot_mips.py @@ -998,9 +998,11 @@ class MipsCloudClient(_MipsClient): did, MIoTDeviceState.ONLINE if msg['event'] == 'online' else MIoTDeviceState.OFFLINE, ctx) - if did.startswith('blt.'): - # MIoT cloud may not publish BLE device online/offline state message. - # Do not subscribe BLE device online/offline state. + if did.startswith('blt.') or did.startswith('proxy.'): + # MIoT cloud may not publish BLE device or proxy gateway child device + # online/offline state message. + # Do not subscribe BLE device or proxy gateway child device + # online/offline state. return True return self.__reg_broadcast_external( topic=topic, handler=on_state_msg, handler_ctx=handler_ctx)