Fix tuya vacuum return_to_base function (#144362)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Jiacheng Ma 2025-07-08 01:03:35 -07:00 committed by GitHub
parent ac5d4f4a81
commit 0dc145aee3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -91,14 +91,15 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
if self.find_dpcode(DPCode.PAUSE, prefer_function=True): if self.find_dpcode(DPCode.PAUSE, prefer_function=True):
self._attr_supported_features |= VacuumEntityFeature.PAUSE self._attr_supported_features |= VacuumEntityFeature.PAUSE
if self.find_dpcode(DPCode.SWITCH_CHARGE, prefer_function=True) or ( self._return_home_use_switch_charge = False
( if self.find_dpcode(DPCode.SWITCH_CHARGE, prefer_function=True):
enum_type := self.find_dpcode( self._attr_supported_features |= VacuumEntityFeature.RETURN_HOME
DPCode.MODE, dptype=DPType.ENUM, prefer_function=True self._return_home_use_switch_charge = True
) elif (
enum_type := self.find_dpcode(
DPCode.MODE, dptype=DPType.ENUM, prefer_function=True
) )
and TUYA_MODE_RETURN_HOME in enum_type.range ) and TUYA_MODE_RETURN_HOME in enum_type.range:
):
self._attr_supported_features |= VacuumEntityFeature.RETURN_HOME self._attr_supported_features |= VacuumEntityFeature.RETURN_HOME
if self.find_dpcode(DPCode.SEEK, prefer_function=True): if self.find_dpcode(DPCode.SEEK, prefer_function=True):
@ -159,12 +160,10 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
def return_to_base(self, **kwargs: Any) -> None: def return_to_base(self, **kwargs: Any) -> None:
"""Return device to dock.""" """Return device to dock."""
self._send_command( if self._return_home_use_switch_charge:
[ self._send_command([{"code": DPCode.SWITCH_CHARGE, "value": True}])
{"code": DPCode.SWITCH_CHARGE, "value": True}, else:
{"code": DPCode.MODE, "value": TUYA_MODE_RETURN_HOME}, self._send_command([{"code": DPCode.MODE, "value": TUYA_MODE_RETURN_HOME}])
]
)
def locate(self, **kwargs: Any) -> None: def locate(self, **kwargs: Any) -> None:
"""Locate the device.""" """Locate the device."""