Skip to content

Commit

Permalink
mirobo: make sure config always exists
Browse files Browse the repository at this point in the history
  • Loading branch information
rytilahti committed Dec 2, 2021
1 parent 1f3da25 commit 300307e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions miio/integrations/vacuum/roborock/vacuum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ def cli(ctx, ip: str, token: str, debug: int, id_file: str):
click.echo("You have to give ip and token!")
sys.exit(-1)

config = {"seq": 0, "manual_seq": 0}
with contextlib.suppress(FileNotFoundError, TypeError, ValueError), open(
id_file, "r"
) as f:
x = json.load(f)
start_id = x.get("seq", 0)
manual_seq = x.get("manual_seq", 0)
_LOGGER.debug("Read stored sequence ids: %s", x)
config = json.load(f)

start_id = config["seq"]
manual_seq = config["manual_seq"]
_LOGGER.debug("Using config: %s", config)

vac = RoborockVacuum(ip, token, start_id, debug)

Expand Down

0 comments on commit 300307e

Please sign in to comment.