From 9886169d73b8d329a5321246efc546387bd7cef2 Mon Sep 17 00:00:00 2001 From: swiergot Date: Mon, 21 Jan 2019 20:04:22 +0100 Subject: [PATCH] Corrected link in discovery.rst and Xiaomi Air Purifier Pro fix (#465) * New method to obtain tokens * Max level for Air Purifier Pro v7 --- docs/discovery.rst | 15 ++++++++++++++- miio/airpurifier.py | 6 +++--- miio/tests/test_airpurifier.py | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/discovery.rst b/docs/discovery.rst index 9274c2545..93f400319 100644 --- a/docs/discovery.rst +++ b/docs/discovery.rst @@ -85,7 +85,20 @@ potentially containing a valid token. Tokens full of ``0``\ s or ``f``\ s (as above) are either already paired with the mobile app or will not yield a token through this method. -In those cases the procedure shown in :ref:`creating_backup` has to be used. +In those cases the procedure shown in :ref:`logged_tokens` has to be used. + +.. _logged_tokens: + +Tokens from Mi Home logs +======================== + +The easiest way to obtain tokens is to browse through log files of the Mi Home +app version 5.4.49 for Android. It seems that version was released with debug +messages turned on by mistake. An APK file with the old version can be easily +found using one of the popular web search engines. After downgrading use a file +browser to navigate to directory ``SmartHome/logs/plug_DeviceManager``, then +open the most recent file and search for the token. When finished, use Google +Play to get the most recent version back. .. _logged_tokens: diff --git a/miio/airpurifier.py b/miio/airpurifier.py index 4001f85b6..f40097c70 100644 --- a/miio/airpurifier.py +++ b/miio/airpurifier.py @@ -455,14 +455,14 @@ def set_mode(self, mode: OperationMode): ) def set_favorite_level(self, level: int): """Set favorite level.""" - if level < 0 or level > 16: + if level < 0 or level > 17: raise AirPurifierException("Invalid favorite level: %s" % level) # Possible alternative property: set_speed_favorite # Set the favorite level used when the mode is `favorite`, - # should be between 0 and 16. - return self.send("set_level_favorite", [level]) # 0 ... 16 + # should be between 0 and 17. + return self.send("set_level_favorite", [level]) # 0 ... 17 @command( click.argument("brightness", type=EnumType(LedBrightness, False)), diff --git a/miio/tests/test_airpurifier.py b/miio/tests/test_airpurifier.py index 82d594b62..02c568d83 100644 --- a/miio/tests/test_airpurifier.py +++ b/miio/tests/test_airpurifier.py @@ -156,7 +156,7 @@ def favorite_level(): self.device.set_favorite_level(-1) with pytest.raises(AirPurifierException): - self.device.set_favorite_level(17) + self.device.set_favorite_level(18) def test_set_led_brightness(self): def led_brightness():