From b46805b92cf643d9ec8f2f0af6cb6ee323ce544b Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Wed, 9 Jul 2025 09:16:55 +0800 Subject: [PATCH] fix: airer status for cover entity (#1235) * fix: xiaomi.airer.pro3 airer status rising (#1222) * fix: airer status * fix: filter out non alphabetic characters from status descriptions --- custom_components/xiaomi_home/cover.py | 23 ++++++++++++------- .../xiaomi_home/miot/miot_mips.py | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/custom_components/xiaomi_home/cover.py b/custom_components/xiaomi_home/cover.py index 0d1817c..1116928 100644 --- a/custom_components/xiaomi_home/cover.py +++ b/custom_components/xiaomi_home/cover.py @@ -46,8 +46,9 @@ off Xiaomi or its affiliates' products. Cover entities for Xiaomi Home. """ from __future__ import annotations -import logging from typing import Any, Optional +import re +import logging from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -97,7 +98,6 @@ class Cover(MIoTServiceEntity, CoverEntity): _prop_status: Optional[MIoTSpecProperty] _prop_status_opening: Optional[list[int]] _prop_status_closing: Optional[list[int]] - _prop_status_stop: Optional[list[int]] _prop_status_closed: Optional[list[int]] _prop_current_position: Optional[MIoTSpecProperty] _prop_target_position: Optional[MIoTSpecProperty] @@ -122,7 +122,6 @@ class Cover(MIoTServiceEntity, CoverEntity): self._prop_status = None self._prop_status_opening = [] self._prop_status_closing = [] - self._prop_status_stop = [] self._prop_status_closed = [] self._prop_current_position = None self._prop_target_position = None @@ -159,13 +158,21 @@ class Cover(MIoTServiceEntity, CoverEntity): self.entity_id) continue for item in prop.value_list.items: - if item.name in {'opening', 'open', 'up'}: + item_str: str = item.name + item_name: str = re.sub(r'[^a-z]', '', item_str) + if item_name in { + 'opening', 'open', 'up', 'uping', 'rise', 'rising' + }: self._prop_status_opening.append(item.value) - elif item.name in {'closing', 'close', 'down', 'dowm'}: + elif item_name in { + 'closing', 'close', 'down', 'dowm', 'falling', + 'dropping', 'downing', 'lower' + }: self._prop_status_closing.append(item.value) - elif item.name in {'stop', 'stopped', 'pause'}: - self._prop_status_stop.append(item.value) - elif item.name in {'closed'}: + elif item_name in { + 'stopatlowest', 'stoplowerlimit', 'lowerlimitstop', + 'floor', 'lowerlimit' + }: self._prop_status_closed.append(item.value) self._prop_status = prop elif prop.name == 'current-position': diff --git a/custom_components/xiaomi_home/miot/miot_mips.py b/custom_components/xiaomi_home/miot/miot_mips.py index 8eab9ee..a2aa2c1 100644 --- a/custom_components/xiaomi_home/miot/miot_mips.py +++ b/custom_components/xiaomi_home/miot/miot_mips.py @@ -1178,7 +1178,7 @@ class MipsLocalClient(_MipsClient): or 'piid' not in msg or 'value' not in msg ): - # self.log_error(f'on_prop_msg, recv unknown msg, {payload}') + self.log_info('unknown prop msg, %s', payload) return if handler: self.log_debug('local, on properties_changed, %s', payload)