From 58c671483e32bfcdfac4c3508b615168596484f7 Mon Sep 17 00:00:00 2001 From: Brandon Chen Date: Tue, 19 Aug 2025 10:15:01 +0800 Subject: [PATCH] fix: add RETURN_HOME functionality for new vacuum cleaner model (#1344) --- .../xiaomi_home/miot/specs/specv2entity.py | 5 +++++ custom_components/xiaomi_home/vacuum.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index 48d56c2..b239d63 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -170,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..7a61596 100644 --- a/custom_components/xiaomi_home/vacuum.py +++ b/custom_components/xiaomi_home/vacuum.py @@ -203,6 +203,16 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity): 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.""" if self._prop_status is not None: