From 4d96f75b9a0b54c193bce8b9676722872cc2ae21 Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Sun, 26 Jan 2025 14:14:50 +0800 Subject: [PATCH] fix: the current position --- custom_components/xiaomi_home/cover.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/custom_components/xiaomi_home/cover.py b/custom_components/xiaomi_home/cover.py index b8664f5..5cf094f 100644 --- a/custom_components/xiaomi_home/cover.py +++ b/custom_components/xiaomi_home/cover.py @@ -218,7 +218,12 @@ class Cover(MIoTServiceEntity, CoverEntity): 0: the cover is closed, 100: the cover is fully opened, None: unknown. """ if self._prop_current_position is None: - return None + # Assume that the current position is the same as the target + # position when the current position is not defined in the device's + # MIoT-Spec-V2. + return None if (self._prop_target_position + is None) else self.get_prop_value( + prop=self._prop_target_position) pos = self.get_prop_value(prop=self._prop_current_position) if pos is None or self._prop_position_value_range is None: return None