From 62185d135f584e7fb67236d1d5f77aaa264311bf Mon Sep 17 00:00:00 2001 From: Brian Martin Date: Mon, 14 Jan 2019 13:13:02 -0500 Subject: [PATCH] Add spotclean to cli Add spotclean to cli --- .vscode/launch.json | 5 +++-- sucks/__init__.py | 8 ++++---- sucks/cli.py | 25 ++++++++++++------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 19f79d2..fbe4892 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,8 +18,9 @@ "program": "${workspaceFolder}/sucks/cli.py", "args" : [ "--debug", - "clean", - "10" + "spotclean", + "0", + "60" ], "console": "integratedTerminal" }, diff --git a/sucks/__init__.py b/sucks/__init__.py index 323eb08..1321896 100644 --- a/sucks/__init__.py +++ b/sucks/__init__.py @@ -360,11 +360,11 @@ class VacBot(): def connect_and_wait_until_ready(self): - if self.vacuum['iot']: - self.iot.connect_and_wait_until_ready() - self.iot.schedule('Ping', 30, lambda: self.send_ping(), repeat=True) + if not self.vacuum['iot']: + #self.iot.connect_and_wait_until_ready() + #self.iot.schedule('Ping', 30, lambda: self.send_ping(), repeat=True) - else: + #else: self.xmpp.connect_and_wait_until_ready() self.xmpp.schedule('Ping', 30, lambda: self.send_ping(), repeat=True) diff --git a/sucks/cli.py b/sucks/cli.py index 727b730..1971b2c 100644 --- a/sucks/cli.py +++ b/sucks/cli.py @@ -179,6 +179,12 @@ def edge(frequency, minutes): return CliAction(Edge(), wait=TimeWait(minutes * 60)) +@cli.command(help='spotcleans provided room(s) for the specified number of minutes') +@click.argument('room', type=click.STRING) +@click.argument('minutes', type=click.FLOAT) +def spotclean(room, minutes): + return CliAction(SpotArea('start', room), wait=TimeWait(minutes * 60)) + @cli.command(help='returns to charger') def charge(): return charge_action() @@ -209,22 +215,15 @@ def run(actions, debug): if actions: config = read_config() api = EcoVacsAPI(config['device_id'], config['email'], config['password_hash'], - config['country'], config['continent']) + config['country'], config['continent']) vacuum = api.devices()[0] - vacbot = VacBot(api.uid, api.REALM, api.resource, api.user_access_token, vacuum, config['continent']) - #vacbot.connect_and_wait_until_ready()( - - - vacbot.run(SpotArea('start')) - - - #vacbot.request_all_statuses() + vacbot.connect_and_wait_until_ready() - # for action in actions: - # click.echo("performing " + str(action.vac_command)) - # vacbot.run(action.vac_command) - # action.wait.wait(vacbot) + for action in actions: + click.echo("performing " + str(action.vac_command)) + vacbot.run(action.vac_command) + action.wait.wait(vacbot) vacbot.disconnect(wait=True)