diff --git a/custom_components/localtuya/const.py b/custom_components/localtuya/const.py index c803baa..80dc4d6 100644 --- a/custom_components/localtuya/const.py +++ b/custom_components/localtuya/const.py @@ -53,8 +53,10 @@ CONF_FAN_SPEED_DP = "fan_speed_dp" CONF_FAN_SPEEDS = "fan_speeds" CONF_CLEAN_TIME_DP = "clean_time_dp" CONF_CLEAN_AREA_DP = "clean_area_dp" +CONF_LOCATE_DP = "locate_dp" CONF_PAUSED_STATE = "paused_state" CONF_RETURN_MODE = "return_mode" +CONF_STOP_STATUS = "stop_status" DATA_DISCOVERY = "discovery" diff --git a/custom_components/localtuya/translations/en.json b/custom_components/localtuya/translations/en.json index 4392803..e268d4d 100644 --- a/custom_components/localtuya/translations/en.json +++ b/custom_components/localtuya/translations/en.json @@ -72,7 +72,9 @@ "fan_speeds": "Fan speeds list (comma-separated)", "clean_time_dp": "Clean Time DP (Usually 33)", "clean_area_dp": "Clean Area DP (Usually 32)", + "locate_dp": "Locate DP (Usually 31)", "paused_state": "Pause state (pause, paused, etc)", + "stop_status": "Stop status", "brightness": "Brightness (only for white color)", "brightness_lower": "Brightness Lower Value", "brightness_upper": "Brightness Upper Value", @@ -137,7 +139,9 @@ "fan_speeds": "Fan speeds list (comma-separated)", "clean_time_dp": "Clean Time DP (Usually 33)", "clean_area_dp": "Clean Area DP (Usually 32)", + "locate_dp": "Locate DP (Usually 31)", "paused_state": "Pause state (pause, paused, etc)", + "stop_status": "Stop status", "brightness": "Brightness (only for white color)", "brightness_lower": "Brightness Lower Value", "brightness_upper": "Brightness Upper Value", diff --git a/custom_components/localtuya/vacuum.py b/custom_components/localtuya/vacuum.py index 094e0f5..7e11f8d 100644 --- a/custom_components/localtuya/vacuum.py +++ b/custom_components/localtuya/vacuum.py @@ -19,6 +19,7 @@ from homeassistant.components.vacuum import ( SUPPORT_STATUS, SUPPORT_STOP, SUPPORT_PAUSE, + SUPPORT_LOCATE, StateVacuumEntity, ) @@ -36,8 +37,10 @@ from .const import ( CONF_FAN_SPEEDS, CONF_CLEAN_TIME_DP, CONF_CLEAN_AREA_DP, + CONF_LOCATE_DP, CONF_PAUSED_STATE, CONF_RETURN_MODE, + CONF_STOP_STATUS, ) _LOGGER = logging.getLogger(__name__) @@ -54,6 +57,7 @@ DEFAULT_MODES = "smart,wall_follow,spiral,single" DEFAULT_FAN_SPEEDS = "low,normal,high" DEFAULT_PAUSED_STATE = "paused" DEFAULT_RETURN_MODE = "chargego" +DEFAULT_STOP_STATUS = "standby" def flow_schema(dps): """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_CLEAN_TIME_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_STOP_STATUS, default=DEFAULT_STOP_STATUS): str, } @@ -117,6 +123,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity): supported_features = supported_features | SUPPORT_FAN_SPEED if self.has_config(CONF_BATTERY_DP): supported_features = supported_features | SUPPORT_BATTERY + if self.has_config(CONF_LOCATE_DP): + supported_features = supported_features | SUPPORT_LOCATE return supported_features @@ -166,11 +174,11 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity): _LOGGER.error("Missing command for return home in commands set.") async def async_stop(self, **kwargs): - """Turn the vacuum off stopping the cleaning and returning home.""" - if self.has_config(CONF_RETURN_MODE): - await self._device.set_dp(self._config[CONF_RETURN_MODE], self._config[CONF_MODE_DP]) + """Turn the vacuum off stopping the cleaning""" + if self.has_config(CONF_STOP_STATUS): + await self._device.set_dp(self._config[CONF_STOP_STATUS], self._config[CONF_MODE_DP]) 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): """Perform a spot clean-up.""" @@ -178,7 +186,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity): async def async_locate(self, **kwargs): """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): """Set the fan speed."""