Skip to content

Commit

Permalink
Sync current customisations
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrisb committed Sep 19, 2023
1 parent 1ab9707 commit 3239545
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
CONF_IDLE_STATUS_VALUE = "idle_status_value"
CONF_RETURNING_STATUS_VALUE = "returning_status_value"
CONF_DOCKED_STATUS_VALUE = "docked_status_value"
CONF_CLEANING_STATUS_VALUE = "cleaning_status_value"
CONF_BATTERY_DP = "battery_dp"
CONF_MODE_DP = "mode_dp"
CONF_MODES = "modes"
Expand Down
1 change: 1 addition & 0 deletions custom_components/localtuya/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"idle_status_value": "Idle Status (comma-separated)",
"returning_status_value": "Returning Status",
"docked_status_value": "Docked Status (comma-separated)",
"cleaning_status_value": "Cleaning Status (comma-separated)",
"fault_dp": "Fault DP (Usually 11)",
"battery_dp": "Battery status DP (Usually 14)",
"mode_dp": "Mode DP (Usually 27)",
Expand Down
16 changes: 14 additions & 2 deletions custom_components/localtuya/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
CONF_CLEAN_RECORD_DP,
CONF_CLEAN_TIME_DP,
CONF_DOCKED_STATUS_VALUE,
CONF_CLEANING_STATUS_VALUE,
CONF_FAN_SPEED_DP,
CONF_FAN_SPEEDS,
CONF_FAULT_DP,
Expand Down Expand Up @@ -57,6 +58,7 @@
DEFAULT_RETURNING_STATUS = "docking"
DEFAULT_DOCKED_STATUS = "charging,chargecompleted"
DEFAULT_MODES = "smart,wall_follow,spiral,single"
DEFAULT_CLEANING_STATUS = "smart_clean,zone_clean,part_clean,wallfollow,selectroom"
DEFAULT_FAN_SPEEDS = "low,normal,high"
DEFAULT_PAUSED_STATE = "paused"
DEFAULT_RETURN_MODE = "chargego"
Expand All @@ -69,6 +71,7 @@ def flow_schema(dps):
vol.Required(CONF_IDLE_STATUS_VALUE, default=DEFAULT_IDLE_STATUS): str,
vol.Required(CONF_POWERGO_DP): vol.In(dps),
vol.Required(CONF_DOCKED_STATUS_VALUE, default=DEFAULT_DOCKED_STATUS): str,
vol.Required(CONF_CLEANING_STATUS_VALUE, default=DEFAULT_CLEANING_STATUS): str,
vol.Optional(
CONF_RETURNING_STATUS_VALUE, default=DEFAULT_RETURNING_STATUS
): str,
Expand Down Expand Up @@ -111,6 +114,10 @@ def __init__(self, device, config_entry, switchid, **kwargs):
if self.has_config(CONF_DOCKED_STATUS_VALUE):
self._docked_status_list = self._config[CONF_DOCKED_STATUS_VALUE].split(",")

self._cleaning_status_list = []
if self.has_config(CONF_CLEANING_STATUS_VALUE):
self._cleaning_status_list = self._config[CONF_CLEANING_STATUS_VALUE].split(",")

self._fan_speed_list = []
if self.has_config(CONF_FAN_SPEEDS):
self._fan_speed_list = self._config[CONF_FAN_SPEEDS].split(",")
Expand Down Expand Up @@ -168,7 +175,10 @@ def fan_speed_list(self) -> list:

async def async_start(self, **kwargs):
"""Turn the vacuum on and start cleaning."""
await self._device.set_dp(True, self._config[CONF_POWERGO_DP])
if hasattr(self, "_modes_list") and self._state != STATE_PAUSED:
await self._device.set_dp(self._modes_list[0], self._config[CONF_MODE_DP])
else:
await self._device.set_dp(True, self._config[CONF_POWERGO_DP])

async def async_pause(self, **kwargs):
"""Stop the vacuum cleaner, do not return to base."""
Expand Down Expand Up @@ -219,12 +229,14 @@ def status_updated(self):
self._state = STATE_IDLE
elif state_value in self._docked_status_list:
self._state = STATE_DOCKED
elif state_value in self._cleaning_status_list:
self._state = STATE_CLEANING
elif state_value == self._config[CONF_RETURNING_STATUS_VALUE]:
self._state = STATE_RETURNING
elif state_value == self._config[CONF_PAUSED_STATE]:
self._state = STATE_PAUSED
else:
self._state = STATE_CLEANING
self._state = state_value

if self.has_config(CONF_BATTERY_DP):
self._battery_level = self.dps_conf(CONF_BATTERY_DP)
Expand Down

0 comments on commit 3239545

Please sign in to comment.