Add service send command in Tuya Vacuum (#63417)

Co-authored-by: Franck Nijhof <git@frenck.dev>
pull/64773/head
dougiteixeira 2022-01-23 11:26:55 -03:00 committed by GitHub
parent 58555954ab
commit b3a8ac8932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,7 @@ from homeassistant.components.vacuum import (
SUPPORT_LOCATE,
SUPPORT_PAUSE,
SUPPORT_RETURN_HOME,
SUPPORT_SEND_COMMAND,
SUPPORT_START,
SUPPORT_STATE,
SUPPORT_STATUS,
@ -89,6 +90,7 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
"""Init Tuya vacuum."""
super().__init__(device, device_manager)
self._supported_features |= SUPPORT_SEND_COMMAND
if self.find_dpcode(DPCode.PAUSE, prefer_function=True):
self._supported_features |= SUPPORT_PAUSE
@ -185,3 +187,9 @@ class TuyaVacuumEntity(TuyaEntity, StateVacuumEntity):
def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
"""Set fan speed."""
self._send_command([{"code": DPCode.SUCTION, "value": fan_speed}])
def send_command(self, command: str, params: str = None, **kwargs: Any) -> None:
"""Send raw command."""
if params is None:
raise ValueError("Params cannot be omitted for Tuya vacuum commands")
self._send_command([{"code": command, "value": params}])