From 8aa0c5d2ca368525030b988d856241594d96b71d Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 7 Aug 2025 14:00:32 +0800 Subject: [PATCH 1/2] fix: add RETURN_HOME functionality for new vacuum cleaner model --- custom_components/xiaomi_home/miot/specs/specv2entity.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index 48d56c2..f54b549 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -160,6 +160,13 @@ SPEC_DEVICE_TRANS_MAP: dict = { } }, 'optional': { + 'vacuum-extend': { + 'optional': { + 'actions': { + 'stop-and-gocharge' + } + } + }, 'identify': { 'required': { 'actions': {'identify'} From a022b3635657b0ab4a85e19cd29890629797523a Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 15 Aug 2025 21:18:11 +0800 Subject: [PATCH 2/2] refactor: enhance vacuum RETURN_HOME support with start-charge fallback --- .../xiaomi_home/miot/specs/specv2entity.py | 12 +++++------- custom_components/xiaomi_home/vacuum.py | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index f54b549..b239d63 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -160,13 +160,6 @@ SPEC_DEVICE_TRANS_MAP: dict = { } }, 'optional': { - 'vacuum-extend': { - 'optional': { - 'actions': { - 'stop-and-gocharge' - } - } - }, 'identify': { 'required': { 'actions': {'identify'} @@ -177,6 +170,11 @@ SPEC_DEVICE_TRANS_MAP: dict = { 'properties': { 'battery-level': {'read'} } + }, + 'optional': { + 'actions': { + 'start-charge' + } } } }, diff --git a/custom_components/xiaomi_home/vacuum.py b/custom_components/xiaomi_home/vacuum.py index 3957f86..c02f925 100644 --- a/custom_components/xiaomi_home/vacuum.py +++ b/custom_components/xiaomi_home/vacuum.py @@ -202,6 +202,14 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity): elif action.name == 'identify': self._attr_supported_features |= VacuumEntityFeature.LOCATE self._action_identify = action + + # Use start-charge from battery service as fallback if stop-and-gocharge is not available + if self._action_stop_and_gocharge is None: + for action in entity_data.actions: + if action.name == 'start-charge': + self._attr_supported_features |= VacuumEntityFeature.RETURN_HOME + self._action_stop_and_gocharge = action + break async def async_start(self) -> None: """Start or resume the cleaning task."""