From baa9f0bb342ef4558f6c462569b8ba5c3a0eaf9e Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Sat, 20 Jan 2018 15:49:01 +0100 Subject: [PATCH] Add a more helpful error message when info() fails with an empty payload 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 --- miio/vacuum_cli.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/miio/vacuum_cli.py b/miio/vacuum_cli.py index 8d64fc024..8980f7d6c 100644 --- a/miio/vacuum_cli.py +++ b/miio/vacuum_cli.py @@ -393,10 +393,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()