From f2e03420d19f02bcda7b9f1ae988a17398b9a1c4 Mon Sep 17 00:00:00 2001 From: cvroque <65680394+cvroque@users.noreply.github.com> Date: Thu, 25 Nov 2021 17:24:46 -0300 Subject: [PATCH] Add commands to Tuya Vacuum (sd) (#60351) --- homeassistant/components/tuya/const.py | 1 + homeassistant/components/tuya/vacuum.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 672001dd3fa..c530b83ce49 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -236,6 +236,7 @@ class DPCode(str, Enum): PM25_STATE = "pm25_state" PM25_VALUE = "pm25_value" POWDER_SET = "powder_set" # Powder + POWER = "power" POWER_GO = "power_go" PRESENCE_STATE = "presence_state" PRESSURE_STATE = "pressure_state" diff --git a/homeassistant/components/tuya/vacuum.py b/homeassistant/components/tuya/vacuum.py index 5602413615c..4b7c7660556 100644 --- a/homeassistant/components/tuya/vacuum.py +++ b/homeassistant/components/tuya/vacuum.py @@ -13,12 +13,15 @@ from homeassistant.components.vacuum import ( STATE_RETURNING, SUPPORT_BATTERY, SUPPORT_FAN_SPEED, + SUPPORT_LOCATE, SUPPORT_PAUSE, SUPPORT_RETURN_HOME, SUPPORT_START, SUPPORT_STATE, SUPPORT_STATUS, SUPPORT_STOP, + SUPPORT_TURN_OFF, + SUPPORT_TURN_ON, StateVacuumEntity, ) from homeassistant.config_entries import ConfigEntry @@ -93,9 +96,15 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity): if DPCode.SWITCH_CHARGE in self.device.status: self._supported_features |= SUPPORT_RETURN_HOME + if DPCode.SEEK in self.device.status: + self._supported_features |= SUPPORT_LOCATE + if DPCode.STATUS in self.device.status: self._supported_features |= SUPPORT_STATE | SUPPORT_STATUS + if DPCode.POWER in self.device.status: + self._supported_features |= SUPPORT_TURN_ON | SUPPORT_TURN_OFF + if DPCode.POWER_GO in self.device.status: self._supported_features |= SUPPORT_STOP | SUPPORT_START @@ -144,12 +153,20 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity): """Flag supported features.""" return self._supported_features - def start(self, **kwargs: Any) -> None: + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" + self._send_command([{"code": DPCode.POWER, "value": True}]) + + def turn_off(self, **kwargs: Any) -> None: + """Turn the device off.""" + self._send_command([{"code": DPCode.POWER, "value": False}]) + + def start(self, **kwargs: Any) -> None: + """Start the device.""" self._send_command([{"code": DPCode.POWER_GO, "value": True}]) def stop(self, **kwargs: Any) -> None: - """Turn the device off.""" + """Stop the device.""" self._send_command([{"code": DPCode.POWER_GO, "value": False}]) def pause(self, **kwargs: Any) -> None: @@ -161,7 +178,7 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity): self._send_command([{"code": DPCode.MODE, "value": "chargego"}]) def locate(self, **kwargs: Any) -> None: - """Return device to dock.""" + """Locate the device.""" self._send_command([{"code": DPCode.SEEK, "value": True}]) def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: