Skip to content

Commit

Permalink
Merge branch 'v5.2.1+' into Basic-xmas-lights
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrisb authored Sep 20, 2023
2 parents 9e2df13 + ac802a5 commit 6669126
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
3 changes: 3 additions & 0 deletions custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
CONF_PAUSED_STATE = "paused_state"
CONF_RETURN_MODE = "return_mode"
CONF_STOP_STATUS = "stop_status"
CONF_PAUSE_DP = "pause_dp"
CONF_PREFER_POWERGO = "use_powergo_to_start"
CONF_CLEANING_STATUS_VALUE = "cleaning_status_value"

# number
CONF_MIN_VALUE = "min_value"
Expand Down
4 changes: 3 additions & 1 deletion custom_components/localtuya/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@
"state_on": "On Value",
"state_off": "Off Value",
"powergo_dp": "Power DP (Usually 25 or 2)",
"pause_dp": "Pause DP",
"use_powergo_to_start": "If no modes list use 'Power DP' instead of 'Pause DP' to start Cleaning",
"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)",
"modes": "Modes list",
"modes": "Modes list (comma-separated, The first listed is used to start cleaning)",
"return_mode": "Return home mode",
"fan_speed_dp": "Fan speeds DP (Usually 30)",
"fan_speeds": "Fan speeds list (comma-separated)",
Expand Down
5 changes: 4 additions & 1 deletion custom_components/localtuya/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@
"state_on": "Valore di ON",
"state_off": "Valore di OFF",
"powergo_dp": "Potenza DP (di solito 25 o 2)",
"pause_dp": "Pausa DP",
"use_powergo_to_start": "Se non è presente alcun elenco di modalità, utilizzare 'Potenza DP' invece di 'Pausa DP' per avviare la pulizia",
"idle_status_value": "Stato di inattività (separato da virgole)",
"returning_status_value": "Stato di ritorno alla base",
"docked_status_value": "Stato di tornato alla base (separato da virgole)",
"cleaning_status_value": "Cleaning Status (separato da virgole)",
"fault_dp": "DP di guasto (di solito 11)",
"battery_dp": "DP di stato batteria (di solito 14)",
"mode_dp": "DP di modalità (di solito 27)",
"modes": "Elenco delle modalità",
"modes": "Elenco delle modalità (separato da virgole, Il primo elencato viene utilizzato per avviare la pulizia)",
"return_mode": "Ritorno in modalità home",
"fan_speed_dp": "DP di velocità del ventilatore (di solito 30)",
"fan_speeds": "DP di elenco delle velocità del ventilatore (separato da virgola)",
Expand Down
5 changes: 4 additions & 1 deletion custom_components/localtuya/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@
"state_on": "Valor ligado",
"state_off": "Valor desligado",
"powergo_dp": "Potência DP (Geralmente 25 ou 2)",
"pause_dp": "Pausa DP",
"use_powergo_to_start": "Se não houver lista de modos, use 'Potência DP' em vez de 'Pausa DP' para iniciar a limpeza",
"idle_status_value": "Status ocioso (separado por vírgula)",
"returning_status_value": "Status de retorno",
"docked_status_value": "Status encaixado (separado por vírgula)",
"cleaning_status_value": "Status limpeza (separado por vírgula)",
"fault_dp": "Falha DP (Geralmente 11)",
"battery_dp": "Status da bateria DP (normalmente 14)",
"mode_dp": "Modo DP (Geralmente 27)",
"modes": "Lista de modos",
"modes": "Lista de modos (separado por vírgula, O primeiro listado é usado para iniciar a limpeza)",
"return_mode": "Modo de retorno para casa",
"fan_speed_dp": "Velocidades do ventilador DP (normalmente 30)",
"fan_speeds": "Lista de velocidades do ventilador (separadas por vírgulas)",
Expand Down
68 changes: 39 additions & 29 deletions custom_components/localtuya/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@
STATE_IDLE,
STATE_PAUSED,
STATE_RETURNING,
SUPPORT_BATTERY,
SUPPORT_FAN_SPEED,
SUPPORT_LOCATE,
SUPPORT_PAUSE,
SUPPORT_RETURN_HOME,
SUPPORT_START,
SUPPORT_STATE,
SUPPORT_STATUS,
SUPPORT_STOP,
VacuumEntityFeature,
StateVacuumEntity,
)

Expand All @@ -43,6 +35,9 @@
CONF_RETURN_MODE,
CONF_RETURNING_STATUS_VALUE,
CONF_STOP_STATUS,
CONF_PAUSE_DP,
CONF_PREFER_POWERGO,
CONF_CLEANING_STATUS_VALUE,
)

_LOGGER = logging.getLogger(__name__)
Expand All @@ -62,32 +57,39 @@
DEFAULT_FAN_SPEEDS = "low,normal,high"
DEFAULT_PAUSED_STATE = "paused"
DEFAULT_RETURN_MODE = "chargego"
DEFAULT_STOP_STATUS = "standby"

DEFAULT_CLEANING_STATUS = "smart,random,wall_follow,spiral,left_spiral,right_spiral,right_bow,left_bow,partial_bow,mop"

def flow_schema(dps):
"""Return schema used in config flow."""
return {

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,
vol.Optional(CONF_BATTERY_DP): vol.In(dps),
vol.Optional(CONF_PAUSED_STATE, default=DEFAULT_PAUSED_STATE): str,

vol.Required(CONF_POWERGO_DP): vol.In(dps),
vol.Optional(CONF_PAUSE_DP): vol.In(dps),
vol.Optional(CONF_PREFER_POWERGO, default=False): bool,

vol.Optional(CONF_MODE_DP): vol.In(dps),
vol.Optional(CONF_MODES, default=DEFAULT_MODES): str,
vol.Optional(CONF_RETURN_MODE, default=DEFAULT_RETURN_MODE): str,
vol.Optional(CONF_STOP_STATUS): str,

vol.Optional(CONF_FAN_SPEED_DP): vol.In(dps),
vol.Optional(CONF_FAN_SPEEDS, default=DEFAULT_FAN_SPEEDS): str,

vol.Optional(CONF_BATTERY_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_RECORD_DP): vol.In(dps),

vol.Optional(CONF_LOCATE_DP): vol.In(dps),
vol.Optional(CONF_FAULT_DP): vol.In(dps),
vol.Optional(CONF_PAUSED_STATE, default=DEFAULT_PAUSED_STATE): str,
vol.Optional(CONF_STOP_STATUS, default=DEFAULT_STOP_STATUS): str,
}


Expand Down Expand Up @@ -127,24 +129,24 @@ def __init__(self, device, config_entry, switchid, **kwargs):
_LOGGER.debug("Initialized vacuum [%s]", self.name)

@property
def supported_features(self):
def supported_features(self) -> VacuumEntityFeature:
"""Flag supported features."""
supported_features = (
SUPPORT_START
| SUPPORT_PAUSE
| SUPPORT_STOP
| SUPPORT_STATUS
| SUPPORT_STATE
VacuumEntityFeature.START
| VacuumEntityFeature.PAUSE
| VacuumEntityFeature.STOP
| VacuumEntityFeature.STATUS
| VacuumEntityFeature.STATE
)

if self.has_config(CONF_RETURN_MODE):
supported_features = supported_features | SUPPORT_RETURN_HOME
supported_features = supported_features | VacuumEntityFeature.RETURN_HOME
if self.has_config(CONF_FAN_SPEED_DP):
supported_features = supported_features | SUPPORT_FAN_SPEED
supported_features = supported_features | VacuumEntityFeature.FAN_SPEED
if self.has_config(CONF_BATTERY_DP):
supported_features = supported_features | SUPPORT_BATTERY
supported_features = supported_features | VacuumEntityFeature.BATTERY
if self.has_config(CONF_LOCATE_DP):
supported_features = supported_features | SUPPORT_LOCATE
supported_features = supported_features | VacuumEntityFeature.LOCATE

return supported_features

Expand Down Expand Up @@ -175,14 +177,22 @@ def fan_speed_list(self) -> list:

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

async def async_pause(self, **kwargs):
"""Stop the vacuum cleaner, do not return to base."""
await self._device.set_dp(False, self._config[CONF_POWERGO_DP])
if self.has_config(CONF_PAUSE_DP):
# toggling this because CONF_PAUSE_DP may be inverted
await self._device.set_dp(not self.dps_conf(CONF_PAUSE_DP) ,self._config[CONF_PAUSE_DP])
else:
await self._device.set_dp( True if self._state == STATE_PAUSED else False , self._config[CONF_POWERGO_DP])

async def async_return_to_base(self, **kwargs):
"""Set the vacuum cleaner to return to the dock."""
Expand All @@ -200,7 +210,7 @@ async def async_stop(self, **kwargs):
self._config[CONF_STOP_STATUS], self._config[CONF_MODE_DP]
)
else:
_LOGGER.error("Missing command for stop in commands set.")
await self._device.set_dp(False, self._config[CONF_POWERGO_DP])

async def async_clean_spot(self, **kwargs):
"""Perform a spot clean-up."""
Expand Down

0 comments on commit 6669126

Please sign in to comment.