From 4bd7825c28076c7a547c3ae6a4d9833dfa45114e Mon Sep 17 00:00:00 2001 From: LiShuzhen Date: Wed, 9 Jul 2025 09:13:39 +0800 Subject: [PATCH] fix: filter out non alphabetic characters from status descriptions --- custom_components/xiaomi_home/cover.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/custom_components/xiaomi_home/cover.py b/custom_components/xiaomi_home/cover.py index ef36bbc..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 @@ -157,16 +158,18 @@ class Cover(MIoTServiceEntity, CoverEntity): self.entity_id) continue for item in prop.value_list.items: - if item.name in { + 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 { + elif item_name in { 'closing', 'close', 'down', 'dowm', 'falling', 'dropping', 'downing', 'lower' }: self._prop_status_closing.append(item.value) - elif item.name in { + elif item_name in { 'stopatlowest', 'stoplowerlimit', 'lowerlimitstop', 'floor', 'lowerlimit' }: