From 3af3d9414dde3773611a8c471c827c66ff08753e Mon Sep 17 00:00:00 2001 From: dougiteixeira <31328123+dougiteixeira@users.noreply.github.com> Date: Tue, 25 Jan 2022 04:29:13 -0300 Subject: [PATCH] Changing the Return to home in Tuya vacuum (#64810) Co-authored-by: Franck Nijhof --- homeassistant/components/tuya/vacuum.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/tuya/vacuum.py b/homeassistant/components/tuya/vacuum.py index b67775990bd..c10c6a05980 100644 --- a/homeassistant/components/tuya/vacuum.py +++ b/homeassistant/components/tuya/vacuum.py @@ -33,6 +33,7 @@ from . import HomeAssistantTuyaData from .base import EnumTypeData, IntegerTypeData, TuyaEntity from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode, DPType +TUYA_MODE_RETURN_HOME = "chargego" TUYA_STATUS_TO_HA = { "charge_done": STATE_DOCKED, "chargecompleted": STATE_DOCKED, @@ -96,6 +97,12 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity): if self.find_dpcode(DPCode.SWITCH_CHARGE, prefer_function=True): self._supported_features |= SUPPORT_RETURN_HOME + elif ( + enum_type := self.find_dpcode( + DPCode.MODE, dptype=DPType.ENUM, prefer_function=True + ) + ) and TUYA_MODE_RETURN_HOME in enum_type.range: + self._supported_features |= SUPPORT_RETURN_HOME if self.find_dpcode(DPCode.SEEK, prefer_function=True): self._supported_features |= SUPPORT_LOCATE @@ -178,7 +185,12 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity): def return_to_base(self, **kwargs: Any) -> None: """Return device to dock.""" - self._send_command([{"code": DPCode.MODE, "value": "chargego"}]) + self._send_command( + [ + {"code": DPCode.SWITCH_CHARGE, "value": True}, + {"code": DPCode.MODE, "value": TUYA_MODE_RETURN_HOME}, + ] + ) def locate(self, **kwargs: Any) -> None: """Locate the device."""