Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected link in discovery.rst and Xiaomi Air Purifier Pro fix #465

Merged
merged 3 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/discovery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ encryption token must be known.
If the returned a token is with characters other than ``0``\ s or ``f``\ s,
it is likely a valid token which can be used directly for communication.
If not, the token needs to be extracted from the Mi Home Application,
see :ref:`creating_backup` for information how to do this.
see :ref:`logged_tokens` for information how to do this.

.. IMPORTANT::

Expand Down Expand Up @@ -85,14 +85,29 @@ 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.

.. _creating_backup:

Tokens from backups
===================

Extracting tokens from a Mi Home backup is the preferred way to obtain tokens.
Extracting tokens from a Mi Home backup is the preferred way to obtain tokens
if they cannot be looked up in the Mi Home app version 5.4.49 log files
(e.g. no Android device around).
For this to work the devices have to be added to the app beforehand
before the database (or backup) is extracted.

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