Skip to content

Commit

Permalink
Add a more helpful error message when info() fails with an empty payl…
Browse files Browse the repository at this point in the history
…oad (#164)

This happens always when the vacuum has not been in contact with
xiaomi's servers and there's nothing else we can do about it

Fixes #156
  • Loading branch information
rytilahti committed Jan 20, 2018
1 parent c308f6e commit d53c95b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions miio/vacuum_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,14 @@ def map(vac: miio.Vacuum):
@pass_dev
def info(vac: miio.Vacuum):
"""Return device information."""
res = vac.info()
try:
res = vac.info()

click.echo("%s" % res)
_LOGGER.debug("Full response: %s", pf(res.raw))
click.echo("%s" % res)
_LOGGER.debug("Full response: %s", pf(res.raw))
except TypeError:
click.echo("Unable to fetch info, this can happen when the vacuum "
"is not connected to the Xiaomi cloud.")


@cli.command()
Expand Down

0 comments on commit d53c95b

Please sign in to comment.