From d53c95b2b1ea83c9d2fd92f75190ed49dea929a3 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Sat, 20 Jan 2018 16:20:46 +0100 Subject: [PATCH] Add a more helpful error message when info() fails with an empty payload (#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 --- 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 3384331c4..96b4f2e51 100644 --- a/miio/vacuum_cli.py +++ b/miio/vacuum_cli.py @@ -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()