Add commands to Tuya Vacuum (sd) (#60351)

pull/60345/head
cvroque 2021-11-25 17:24:46 -03:00 committed by GitHub
parent d504c1e3e8
commit f2e03420d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -236,6 +236,7 @@ class DPCode(str, Enum):
PM25_STATE = "pm25_state" PM25_STATE = "pm25_state"
PM25_VALUE = "pm25_value" PM25_VALUE = "pm25_value"
POWDER_SET = "powder_set" # Powder POWDER_SET = "powder_set" # Powder
POWER = "power"
POWER_GO = "power_go" POWER_GO = "power_go"
PRESENCE_STATE = "presence_state" PRESENCE_STATE = "presence_state"
PRESSURE_STATE = "pressure_state" PRESSURE_STATE = "pressure_state"

View File

@ -13,12 +13,15 @@ from homeassistant.components.vacuum import (
STATE_RETURNING, STATE_RETURNING,
SUPPORT_BATTERY, SUPPORT_BATTERY,
SUPPORT_FAN_SPEED, SUPPORT_FAN_SPEED,
SUPPORT_LOCATE,
SUPPORT_PAUSE, SUPPORT_PAUSE,
SUPPORT_RETURN_HOME, SUPPORT_RETURN_HOME,
SUPPORT_START, SUPPORT_START,
SUPPORT_STATE, SUPPORT_STATE,
SUPPORT_STATUS, SUPPORT_STATUS,
SUPPORT_STOP, SUPPORT_STOP,
SUPPORT_TURN_OFF,
SUPPORT_TURN_ON,
StateVacuumEntity, StateVacuumEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -93,9 +96,15 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
if DPCode.SWITCH_CHARGE in self.device.status: if DPCode.SWITCH_CHARGE in self.device.status:
self._supported_features |= SUPPORT_RETURN_HOME 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: if DPCode.STATUS in self.device.status:
self._supported_features |= SUPPORT_STATE | SUPPORT_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: if DPCode.POWER_GO in self.device.status:
self._supported_features |= SUPPORT_STOP | SUPPORT_START self._supported_features |= SUPPORT_STOP | SUPPORT_START
@ -144,12 +153,20 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
"""Flag supported features.""" """Flag supported features."""
return self._supported_features return self._supported_features
def start(self, **kwargs: Any) -> None: def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on.""" """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}]) self._send_command([{"code": DPCode.POWER_GO, "value": True}])
def stop(self, **kwargs: Any) -> None: def stop(self, **kwargs: Any) -> None:
"""Turn the device off.""" """Stop the device."""
self._send_command([{"code": DPCode.POWER_GO, "value": False}]) self._send_command([{"code": DPCode.POWER_GO, "value": False}])
def pause(self, **kwargs: Any) -> None: def pause(self, **kwargs: Any) -> None:
@ -161,7 +178,7 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
self._send_command([{"code": DPCode.MODE, "value": "chargego"}]) self._send_command([{"code": DPCode.MODE, "value": "chargego"}])
def locate(self, **kwargs: Any) -> None: def locate(self, **kwargs: Any) -> None:
"""Return device to dock.""" """Locate the device."""
self._send_command([{"code": DPCode.SEEK, "value": True}]) self._send_command([{"code": DPCode.SEEK, "value": True}])
def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None: