add stop and locate commands
This commit is contained in:
@@ -53,8 +53,10 @@ CONF_FAN_SPEED_DP = "fan_speed_dp"
|
|||||||
CONF_FAN_SPEEDS = "fan_speeds"
|
CONF_FAN_SPEEDS = "fan_speeds"
|
||||||
CONF_CLEAN_TIME_DP = "clean_time_dp"
|
CONF_CLEAN_TIME_DP = "clean_time_dp"
|
||||||
CONF_CLEAN_AREA_DP = "clean_area_dp"
|
CONF_CLEAN_AREA_DP = "clean_area_dp"
|
||||||
|
CONF_LOCATE_DP = "locate_dp"
|
||||||
CONF_PAUSED_STATE = "paused_state"
|
CONF_PAUSED_STATE = "paused_state"
|
||||||
CONF_RETURN_MODE = "return_mode"
|
CONF_RETURN_MODE = "return_mode"
|
||||||
|
CONF_STOP_STATUS = "stop_status"
|
||||||
|
|
||||||
DATA_DISCOVERY = "discovery"
|
DATA_DISCOVERY = "discovery"
|
||||||
|
|
||||||
|
@@ -72,7 +72,9 @@
|
|||||||
"fan_speeds": "Fan speeds list (comma-separated)",
|
"fan_speeds": "Fan speeds list (comma-separated)",
|
||||||
"clean_time_dp": "Clean Time DP (Usually 33)",
|
"clean_time_dp": "Clean Time DP (Usually 33)",
|
||||||
"clean_area_dp": "Clean Area DP (Usually 32)",
|
"clean_area_dp": "Clean Area DP (Usually 32)",
|
||||||
|
"locate_dp": "Locate DP (Usually 31)",
|
||||||
"paused_state": "Pause state (pause, paused, etc)",
|
"paused_state": "Pause state (pause, paused, etc)",
|
||||||
|
"stop_status": "Stop status",
|
||||||
"brightness": "Brightness (only for white color)",
|
"brightness": "Brightness (only for white color)",
|
||||||
"brightness_lower": "Brightness Lower Value",
|
"brightness_lower": "Brightness Lower Value",
|
||||||
"brightness_upper": "Brightness Upper Value",
|
"brightness_upper": "Brightness Upper Value",
|
||||||
@@ -137,7 +139,9 @@
|
|||||||
"fan_speeds": "Fan speeds list (comma-separated)",
|
"fan_speeds": "Fan speeds list (comma-separated)",
|
||||||
"clean_time_dp": "Clean Time DP (Usually 33)",
|
"clean_time_dp": "Clean Time DP (Usually 33)",
|
||||||
"clean_area_dp": "Clean Area DP (Usually 32)",
|
"clean_area_dp": "Clean Area DP (Usually 32)",
|
||||||
|
"locate_dp": "Locate DP (Usually 31)",
|
||||||
"paused_state": "Pause state (pause, paused, etc)",
|
"paused_state": "Pause state (pause, paused, etc)",
|
||||||
|
"stop_status": "Stop status",
|
||||||
"brightness": "Brightness (only for white color)",
|
"brightness": "Brightness (only for white color)",
|
||||||
"brightness_lower": "Brightness Lower Value",
|
"brightness_lower": "Brightness Lower Value",
|
||||||
"brightness_upper": "Brightness Upper Value",
|
"brightness_upper": "Brightness Upper Value",
|
||||||
|
@@ -19,6 +19,7 @@ from homeassistant.components.vacuum import (
|
|||||||
SUPPORT_STATUS,
|
SUPPORT_STATUS,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
SUPPORT_PAUSE,
|
SUPPORT_PAUSE,
|
||||||
|
SUPPORT_LOCATE,
|
||||||
StateVacuumEntity,
|
StateVacuumEntity,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,8 +37,10 @@ from .const import (
|
|||||||
CONF_FAN_SPEEDS,
|
CONF_FAN_SPEEDS,
|
||||||
CONF_CLEAN_TIME_DP,
|
CONF_CLEAN_TIME_DP,
|
||||||
CONF_CLEAN_AREA_DP,
|
CONF_CLEAN_AREA_DP,
|
||||||
|
CONF_LOCATE_DP,
|
||||||
CONF_PAUSED_STATE,
|
CONF_PAUSED_STATE,
|
||||||
CONF_RETURN_MODE,
|
CONF_RETURN_MODE,
|
||||||
|
CONF_STOP_STATUS,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -54,6 +57,7 @@ DEFAULT_MODES = "smart,wall_follow,spiral,single"
|
|||||||
DEFAULT_FAN_SPEEDS = "low,normal,high"
|
DEFAULT_FAN_SPEEDS = "low,normal,high"
|
||||||
DEFAULT_PAUSED_STATE = "paused"
|
DEFAULT_PAUSED_STATE = "paused"
|
||||||
DEFAULT_RETURN_MODE = "chargego"
|
DEFAULT_RETURN_MODE = "chargego"
|
||||||
|
DEFAULT_STOP_STATUS = "standby"
|
||||||
|
|
||||||
def flow_schema(dps):
|
def flow_schema(dps):
|
||||||
"""Return schema used in config flow."""
|
"""Return schema used in config flow."""
|
||||||
@@ -70,7 +74,9 @@ def flow_schema(dps):
|
|||||||
vol.Optional(CONF_FAN_SPEEDS, default=DEFAULT_FAN_SPEEDS): str,
|
vol.Optional(CONF_FAN_SPEEDS, default=DEFAULT_FAN_SPEEDS): str,
|
||||||
vol.Optional(CONF_CLEAN_TIME_DP): vol.In(dps),
|
vol.Optional(CONF_CLEAN_TIME_DP): vol.In(dps),
|
||||||
vol.Optional(CONF_CLEAN_AREA_DP): vol.In(dps),
|
vol.Optional(CONF_CLEAN_AREA_DP): vol.In(dps),
|
||||||
|
vol.Optional(CONF_LOCATE_DP): vol.In(dps),
|
||||||
vol.Optional(CONF_PAUSED_STATE, default=DEFAULT_PAUSED_STATE): str,
|
vol.Optional(CONF_PAUSED_STATE, default=DEFAULT_PAUSED_STATE): str,
|
||||||
|
vol.Optional(CONF_STOP_STATUS, default=DEFAULT_STOP_STATUS): str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,6 +123,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
|
|||||||
supported_features = supported_features | SUPPORT_FAN_SPEED
|
supported_features = supported_features | SUPPORT_FAN_SPEED
|
||||||
if self.has_config(CONF_BATTERY_DP):
|
if self.has_config(CONF_BATTERY_DP):
|
||||||
supported_features = supported_features | SUPPORT_BATTERY
|
supported_features = supported_features | SUPPORT_BATTERY
|
||||||
|
if self.has_config(CONF_LOCATE_DP):
|
||||||
|
supported_features = supported_features | SUPPORT_LOCATE
|
||||||
|
|
||||||
return supported_features
|
return supported_features
|
||||||
|
|
||||||
@@ -166,11 +174,11 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
|
|||||||
_LOGGER.error("Missing command for return home in commands set.")
|
_LOGGER.error("Missing command for return home in commands set.")
|
||||||
|
|
||||||
async def async_stop(self, **kwargs):
|
async def async_stop(self, **kwargs):
|
||||||
"""Turn the vacuum off stopping the cleaning and returning home."""
|
"""Turn the vacuum off stopping the cleaning"""
|
||||||
if self.has_config(CONF_RETURN_MODE):
|
if self.has_config(CONF_STOP_STATUS):
|
||||||
await self._device.set_dp(self._config[CONF_RETURN_MODE], self._config[CONF_MODE_DP])
|
await self._device.set_dp(self._config[CONF_STOP_STATUS], self._config[CONF_MODE_DP])
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Missing command for return home in commands set.")
|
_LOGGER.error("Missing command for stop in commands set.")
|
||||||
|
|
||||||
async def async_clean_spot(self, **kwargs):
|
async def async_clean_spot(self, **kwargs):
|
||||||
"""Perform a spot clean-up."""
|
"""Perform a spot clean-up."""
|
||||||
@@ -178,7 +186,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
|
|||||||
|
|
||||||
async def async_locate(self, **kwargs):
|
async def async_locate(self, **kwargs):
|
||||||
"""Locate the vacuum cleaner."""
|
"""Locate the vacuum cleaner."""
|
||||||
return None
|
if self.has_config(CONF_LOCATE_DP):
|
||||||
|
await self._device.set_dp('', self._config[CONF_LOCATE_DP])
|
||||||
|
|
||||||
async def async_set_fan_speed(self, **kwargs):
|
async def async_set_fan_speed(self, **kwargs):
|
||||||
"""Set the fan speed."""
|
"""Set the fan speed."""
|
||||||
|
Reference in New Issue
Block a user