Move imports to top for ecovacs ()

* Moved imports in ecovacs integration

* Imported sucks once, reused it multiple times
pull/28253/head
springstan 2019-11-26 03:01:48 +01:00 committed by Paulus Schoutsen
parent cc346e57e6
commit cc255da038
2 changed files with 11 additions and 19 deletions
homeassistant/components/ecovacs

View File

@ -3,6 +3,7 @@ import logging
import random
import string
from sucks import EcoVacsAPI, VacBot
import voluptuous as vol
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP
@ -44,8 +45,6 @@ def setup(hass, config):
hass.data[ECOVACS_DEVICES] = []
from sucks import EcoVacsAPI, VacBot
ecovacs_api = EcoVacsAPI(
ECOVACS_API_DEVICEID,
config[DOMAIN].get(CONF_USERNAME),

View File

@ -1,6 +1,8 @@
"""Support for Ecovacs Ecovacs Vaccums."""
import logging
import sucks
from homeassistant.components.vacuum import (
SUPPORT_BATTERY,
SUPPORT_CLEAN_SPOT,
@ -123,9 +125,8 @@ class EcovacsVacuum(VacuumDevice):
def return_to_base(self, **kwargs):
"""Set the vacuum cleaner to return to the dock."""
from sucks import Charge
self.device.run(Charge())
self.device.run(sucks.Charge())
@property
def battery_icon(self):
@ -150,15 +151,13 @@ class EcovacsVacuum(VacuumDevice):
@property
def fan_speed_list(self):
"""Get the list of available fan speed steps of the vacuum cleaner."""
from sucks import FAN_SPEED_NORMAL, FAN_SPEED_HIGH
return [FAN_SPEED_NORMAL, FAN_SPEED_HIGH]
return [sucks.FAN_SPEED_NORMAL, sucks.FAN_SPEED_HIGH]
def turn_on(self, **kwargs):
"""Turn the vacuum on and start cleaning."""
from sucks import Clean
self.device.run(Clean())
self.device.run(sucks.Clean())
def turn_off(self, **kwargs):
"""Turn the vacuum off stopping the cleaning and returning home."""
@ -166,34 +165,28 @@ class EcovacsVacuum(VacuumDevice):
def stop(self, **kwargs):
"""Stop the vacuum cleaner."""
from sucks import Stop
self.device.run(Stop())
self.device.run(sucks.Stop())
def clean_spot(self, **kwargs):
"""Perform a spot clean-up."""
from sucks import Spot
self.device.run(Spot())
self.device.run(sucks.Spot())
def locate(self, **kwargs):
"""Locate the vacuum cleaner."""
from sucks import PlaySound
self.device.run(PlaySound())
self.device.run(sucks.PlaySound())
def set_fan_speed(self, fan_speed, **kwargs):
"""Set fan speed."""
if self.is_on:
from sucks import Clean
self.device.run(Clean(mode=self.device.clean_status, speed=fan_speed))
self.device.run(sucks.Clean(mode=self.device.clean_status, speed=fan_speed))
def send_command(self, command, params=None, **kwargs):
"""Send a command to a vacuum cleaner."""
from sucks import VacBotCommand
self.device.run(VacBotCommand(command, params))
self.device.run(sucks.VacBotCommand(command, params))
@property
def device_state_attributes(self):