lint test fixes

This commit is contained in:
rikman122
2021-11-08 20:35:46 +01:00
parent 0f3ad66849
commit ca01833061
2 changed files with 25 additions and 26 deletions

View File

@@ -53,7 +53,7 @@ localtuya:
current: 18 # Optional current: 18 # Optional
current_consumption: 19 # Optional current_consumption: 19 # Optional
voltage: 20 # Optional voltage: 20 # Optional
- platform: vacuum - platform: vacuum
friendly_name: Vacuum friendly_name: Vacuum
id: 28 id: 28

View File

@@ -18,7 +18,6 @@ from homeassistant.components.vacuum import (
SUPPORT_STATE, SUPPORT_STATE,
SUPPORT_STATUS, SUPPORT_STATUS,
SUPPORT_STOP, SUPPORT_STOP,
SUPPORT_PAUSE,
SUPPORT_LOCATE, SUPPORT_LOCATE,
StateVacuumEntity, StateVacuumEntity,
) )
@@ -45,10 +44,10 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
CLEAN_TIME = "clean_time" CLEAN_TIME = "clean_time"
CLEAN_AREA = "clean_area" 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"
DEFAULT_RETURNING_STATUS = "docking" DEFAULT_RETURNING_STATUS = "docking"
@@ -59,13 +58,15 @@ DEFAULT_PAUSED_STATE = "paused"
DEFAULT_RETURN_MODE = "chargego" DEFAULT_RETURN_MODE = "chargego"
DEFAULT_STOP_STATUS = "standby" DEFAULT_STOP_STATUS = "standby"
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_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),
vol.Optional(CONF_MODE_DP): vol.In(dps), vol.Optional(CONF_MODE_DP): vol.In(dps),
vol.Optional(CONF_MODES, default=DEFAULT_MODES): str, vol.Optional(CONF_MODES, default=DEFAULT_MODES): str,
@@ -85,7 +86,7 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
def __init__(self, device, config_entry, switchid, **kwargs): def __init__(self, device, config_entry, switchid, **kwargs):
"""Initialize a new LocaltuyaVacuum.""" """Initialize a new LocaltuyaVacuum."""
super().__init__(device, config_entry, switchid ,_LOGGER, **kwargs) super().__init__(device, config_entry, switchid , _LOGGER, **kwargs)
self._state = None self._state = None
self._battery_level = None self._battery_level = None
self._attrs = {} self._attrs = {}
@@ -98,7 +99,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
self._docked_status_list = [] self._docked_status_list = []
if self.has_config(CONF_DOCKED_STATUS_VALUE): if self.has_config(CONF_DOCKED_STATUS_VALUE):
self._docked_status_list = self._config[CONF_DOCKED_STATUS_VALUE].split(",") self._docked_status_list = self._config[CONF_DOCKED_STATUS_VALUE].split(",")
@@ -115,7 +116,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
@property @property
def supported_features(self): def supported_features(self):
"""Flag supported features.""" """Flag supported features."""
supported_features = SUPPORT_START | SUPPORT_PAUSE | SUPPORT_STOP | SUPPORT_STATUS | SUPPORT_STATE supported_features = (SUPPORT_START | SUPPORT_PAUSE
| SUPPORT_STOP | SUPPORT_STATUS | SUPPORT_STATE)
if self.has_config(CONF_RETURN_MODE): if self.has_config(CONF_RETURN_MODE):
supported_features = supported_features | SUPPORT_RETURN_HOME supported_features = supported_features | SUPPORT_RETURN_HOME
@@ -153,11 +155,6 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
"""Return the list of available fan speeds.""" """Return the list of available fan speeds."""
return self._fan_speed_list return self._fan_speed_list
@property
def error(self):
"""Return error message."""
return ""
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(True, self._config[CONF_POWERGO_DP]) await self._device.set_dp(True, self._config[CONF_POWERGO_DP])
@@ -169,14 +166,16 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
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.has_config(CONF_RETURN_MODE): if self.has_config(CONF_RETURN_MODE):
await self._device.set_dp(self._config[CONF_RETURN_MODE], self._config[CONF_MODE_DP]) await self._device.set_dp(self._config[CONF_RETURN_MODE],
self._config[CONF_MODE_DP])
else: else:
_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""" """Turn the vacuum off stopping the cleaning."""
if self.has_config(CONF_STOP_STATUS): if self.has_config(CONF_STOP_STATUS):
await self._device.set_dp(self._config[CONF_STOP_STATUS], 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 stop in commands set.") _LOGGER.error("Missing command for stop in commands set.")
@@ -189,9 +188,8 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
if self.has_config(CONF_LOCATE_DP): if self.has_config(CONF_LOCATE_DP):
await self._device.set_dp('', self._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, fan_speed, **kwargs):
"""Set the fan speed.""" """Set the fan speed."""
fan_speed = kwargs["fan_speed"]
await self._device.set_dp(fan_speed, self._config[CONF_FAN_SPEED_DP]) await self._device.set_dp(fan_speed, self._config[CONF_FAN_SPEED_DP])
async def async_send_command(self, command, params=None, **kwargs): async def async_send_command(self, command, params=None, **kwargs):
@@ -216,20 +214,21 @@ class LocaltuyaVacuum(LocalTuyaEntity, StateVacuumEntity):
if self.has_config(CONF_BATTERY_DP): if self.has_config(CONF_BATTERY_DP):
self._battery_level = self.dps_conf(CONF_BATTERY_DP) self._battery_level = self.dps_conf(CONF_BATTERY_DP)
self._cleaning_mode = "" self._cleaning_mode = ""
if self.has_config(CONF_MODES): if self.has_config(CONF_MODES):
self._cleaning_mode = self.dps_conf(CONF_MODE_DP) self._cleaning_mode = self.dps_conf(CONF_MODE_DP)
self._attrs[MODE] = self._cleaning_mode self._attrs[MODE] = self._cleaning_mode
self._fan_speed = "" self._fan_speed = ""
if self.has_config(CONF_FAN_SPEEDS): if self.has_config(CONF_FAN_SPEEDS):
self._fan_speed = self.dps_conf(CONF_FAN_SPEED_DP) self._fan_speed = self.dps_conf(CONF_FAN_SPEED_DP)
if self.has_config(CONF_CLEAN_TIME_DP): if self.has_config(CONF_CLEAN_TIME_DP):
self._attrs[CLEAN_TIME] = self.dps_conf(CONF_CLEAN_TIME_DP) self._attrs[CLEAN_TIME] = self.dps_conf(CONF_CLEAN_TIME_DP)
if self.has_config(CONF_CLEAN_AREA_DP): if self.has_config(CONF_CLEAN_AREA_DP):
self._attrs[CLEAN_AREA] = self.dps_conf(CONF_CLEAN_AREA_DP) self._attrs[CLEAN_AREA] = self.dps_conf(CONF_CLEAN_AREA_DP)
async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaVacuum, flow_schema)
async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaVacuum, flow_schema)