Skip to content

Commit

Permalink
Corrected link in discovery.rst and Xiaomi Air Purifier Pro fix (#465)
Browse files Browse the repository at this point in the history
* New method to obtain tokens
* Max level for Air Purifier Pro v7
  • Loading branch information
swiergot authored and syssi committed Jan 21, 2019
1 parent 5dd2abb commit 9886169
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
15 changes: 14 additions & 1 deletion docs/discovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions miio/airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion miio/tests/test_airpurifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 9886169

Please sign in to comment.