added Power control DP

This commit is contained in:
rikman122
2021-06-12 12:55:24 +02:00
parent 1f98b6533b
commit 3e78b0b9ba
3 changed files with 17 additions and 15 deletions

View File

@@ -42,6 +42,7 @@ CONF_FAN_SPEED_HIGH = "fan_speed_high"
CONF_SCALING = "scaling" CONF_SCALING = "scaling"
# vacuum # vacuum
CONF_POWERGO_DP = "powergo_dp"
CONF_IDLE_STATUS_VALUE = "idle_status_value" CONF_IDLE_STATUS_VALUE = "idle_status_value"
CONF_RETURNING_STATUS_VALUE = "returning_status_value" CONF_RETURNING_STATUS_VALUE = "returning_status_value"
CONF_DOCKED_STATUS_VALUE = "docked_status_value" CONF_DOCKED_STATUS_VALUE = "docked_status_value"

View File

@@ -60,12 +60,13 @@
"scaling": "Scaling Factor", "scaling": "Scaling Factor",
"state_on": "On Value", "state_on": "On Value",
"state_off": "Off Value", "state_off": "Off Value",
"powergo_dp": "Power DP (Usually 25 or 2)",
"idle_status_value": "Idle Status (comma-separated)", "idle_status_value": "Idle Status (comma-separated)",
"returning_status_value": "Returning Status", "returning_status_value": "Returning Status",
"docked_status_value": "Docked Status (comma-separated)", "docked_status_value": "Docked Status (comma-separated)",
"battery_dp": "Battery status DP (Usually 14)", "battery_dp": "Battery status DP (Usually 14)",
"mode_dp": "Mode DP (Usually 27)", "mode_dp": "Mode DP (Usually 27)",
"modes": "Modes list [start,pause/stop,return home,others...]", "modes": "Modes list in this order: return home,others...",
"fan_speed_dp": "Fan speeds DP (Usually 30)", "fan_speed_dp": "Fan speeds DP (Usually 30)",
"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)",
@@ -122,12 +123,13 @@
"scaling": "Scaling Factor", "scaling": "Scaling Factor",
"state_on": "On Value", "state_on": "On Value",
"state_off": "Off Value", "state_off": "Off Value",
"powergo_dp": "Power DP (Usually 25 or 2)",
"idle_status_value": "Idle Status (comma-separated)", "idle_status_value": "Idle Status (comma-separated)",
"returning_status_value": "Returning Status", "returning_status_value": "Returning Status",
"docked_status_value": "Docked Status (comma-separated)", "docked_status_value": "Docked Status (comma-separated)",
"battery_dp": "Battery status DP (Usually 14)", "battery_dp": "Battery status DP (Usually 14)",
"mode_dp": "Mode DP (Usually 27)", "mode_dp": "Mode DP (Usually 27)",
"modes": "Modes list [start,pause/stop,return home,others...]", "modes": "Modes list in this order: return home,others...",
"fan_speed_dp": "Fan speeds DP (Usually 30)", "fan_speed_dp": "Fan speeds DP (Usually 30)",
"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)",

View File

@@ -23,6 +23,7 @@ from homeassistant.components.vacuum import (
from .common import LocalTuyaEntity, async_setup_entry from .common import LocalTuyaEntity, async_setup_entry
from .const import ( from .const import (
CONF_POWERGO_DP,
CONF_IDLE_STATUS_VALUE, CONF_IDLE_STATUS_VALUE,
CONF_RETURNING_STATUS_VALUE, CONF_RETURNING_STATUS_VALUE,
CONF_DOCKED_STATUS_VALUE, CONF_DOCKED_STATUS_VALUE,
@@ -42,16 +43,17 @@ CLEAN_AREA = "clean_area"
MODES_LIST = "cleaning_mode_list" MODES_LIST = "cleaning_mode_list"
MODE = "cleaning_mode" MODE = "cleaning_mode"
DEFAULT_IDLE_STATUS = "standby,sleep" DEFAULT_IDLE_STATUS = "standby,sleep,pause"
DEFAULT_RETURNING_STATUS = "docking" DEFAULT_RETURNING_STATUS = "docking"
DEFAULT_DOCKED_STATUS = "charging,chargecompleted" DEFAULT_DOCKED_STATUS = "charging,chargecompleted"
DEFAULT_MODES = "smart,standby,chargego,wall_follow,spiral,single" DEFAULT_MODES = "chargego,smart,standby,wall_follow,spiral,single"
DEFAULT_FAN_SPEEDS = "low,normal,high" DEFAULT_FAN_SPEEDS = "low,normal,high"
def flow_schema(dps): def flow_schema(dps):
"""Return schema used in config flow.""" """Return schema used in config flow."""
return { return {
vol.Required(CONF_IDLE_STATUS_VALUE, default=DEFAULT_IDLE_STATUS): str, 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_DOCKED_STATUS_VALUE, default=DEFAULT_DOCKED_STATUS): str,
vol.Optional(CONF_RETURNING_STATUS_VALUE, default=DEFAULT_RETURNING_STATUS): str, vol.Optional(CONF_RETURNING_STATUS_VALUE, default=DEFAULT_RETURNING_STATUS): str,
vol.Optional(CONF_BATTERY_DP): vol.In(dps), vol.Optional(CONF_BATTERY_DP): vol.In(dps),
@@ -82,10 +84,7 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
if self.has_config(CONF_MODES): if self.has_config(CONF_MODES):
self._modes_list = self._config[CONF_MODES].split(",") self._modes_list = self._config[CONF_MODES].split(",")
self._attrs[MODES_LIST] = self._modes_list self._attrs[MODES_LIST] = self._modes_list
if len(self._modes_list) >= 3: self._return_mode = self._modes_list[0]
self._start_mode = self._modes_list[0]
self._pause_mode = self._modes_list[1]
self._return_mode = self._modes_list[2]
self._docked_status_list = [] self._docked_status_list = []
if self.has_config(CONF_DOCKED_STATUS_VALUE): if self.has_config(CONF_DOCKED_STATUS_VALUE):
@@ -146,25 +145,25 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
async def async_start(self, **kwargs): async def async_start(self, **kwargs):
"""Turn the vacuum on and start cleaning.""" """Turn the vacuum on and start cleaning."""
await self._device.set_dp(self._start_mode, self._config[CONF_MODE_DP]) await self._device.set_dp(True, self._config[CONF_POWERGO_DP])
async def async_pause(self, **kwargs): async def async_pause(self, **kwargs):
"""Stop the vacuum cleaner, do not return to base.""" """Stop the vacuum cleaner, do not return to base."""
if self._pause_mode: await self._device.set_dp(False, self._config[CONF_POWERGO_DP])
await self._device.set_dp(self._pause_mode, self._config[CONF_MODE_DP])
else:
_LOGGER.error("Missing command for pause in commands set.")
async def async_return_to_base(self, **kwargs): async def async_return_to_base(self, **kwargs):
"""Set the vacuum cleaner to return to the dock.""" """Set the vacuum cleaner to return to the dock."""
if self._return_mode: if self._return_mode:
await self._device.set_dp(self._return_mode, self._config[CONF_MODE_DP]) await self._device.set_dp(self._return_mode, self._config[CONF_MODE_DP])
else: else:
_LOGGER.error("Missing command for pause 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 and returning home."""
self.async_pause() if self._return_mode:
await self._device.set_dp(self._return_mode, self._config[CONF_MODE_DP])
else:
_LOGGER.error("Missing command for return home 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."""