Backup of com.xiaomi.smarthome (Android)

I am having trouble when I am trying to back up the Xiaomi Mi Home app to grab the vacuum access token.

I am using Windows and following the step-by-step procedure as described here:

But when I type the ADB-command to make the backup (.\adb backup -noapk com.xiaomi.smarthome -f backup.ab), my Huawei P9 (Android 7) phone says (translated from Norwegian):

“A full backup of all the data is requested”
"Since your unit is encrypted, the backup also needs to be encrypted. Supply a password: "

If I don’t supply a password, I am not able to continue.

If i supply a password, an AES256 encrypted file is created.

So my questions, I am probably doing something wrong:

  • My unit is encrypted? Might de default so in Android 7?
  • “A full backup”? I really just requested the Xiaomi Mi App?

Please help :slight_smile:

If you are adventurous you can install the current git master (which supports token extraction) of python-miio for testing with the following command:
pip install -e git+ (still using python-mirobo as a name here to avoid potential problems with future installations. The package will be renamed to python-miio soon.) In the best case you would only install this inside a virtualenv.

A tool called miio-extract-tokens will be installed which can be used to extract even encrypted backup files. It will simply extract the backup and print out all the tokens from the database, e.g.

miio-extract-tokens --password 1 backup.ab
Saving database to /tmp/tmp2vh74gof
INFO:mirobo.extract_tokens:Reading database from /tmp/tmp2vh74gof
INFO:mirobo.extract_tokens:Reading tokens from Android DB
        Model: lumi.gateway.v3
        IP address: 192.168.XX.XX
        Token: 91c52a27eff00b9548f2XXXX
        MAC: 28:6C:07:XX:XX:XX
        Model: yeelink.light.color1
        IP address: 192.168.XX:XX
        Token: 5f77fdab0e6bc64a31a9c96XXXX
        MAC: F0:B4:29:XX:XX:XX

Hope this helps, please let me know how it went!

1 Like

Thanks @teprrr , I am really impressed by the knowledge and dedication of the HA community! :+1:

I will give it a shot tonight and report progress here.

I have tried to install it to virtualenvironments using Python 2.7 and 3.4 but I get the same error when running miio-extract-tokens:

  (mirobot) marius@marius-ThinkPad-T430 ~/miorobot $ miio-extract-tokens --password xxx
Traceback (most recent call last):
  File "/usr/local/bin/miio-extract-tokens", line 11, in <module>
    load_entry_point('python-miio', 'console_scripts', 'miio-extract-tokens')()
  File "/home/marius/.local/lib/python2.7/site-packages/pkg_resources/", line 570, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/marius/.local/lib/python2.7/site-packages/pkg_resources/", line 2755, in load_entry_point
    return ep.load()
  File "/home/marius/.local/lib/python2.7/site-packages/pkg_resources/", line 2409, in load
    return self.resolve()
  File "/home/marius/.local/lib/python2.7/site-packages/pkg_resources/", line 2415, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/marius/miorobot/src/python-mirobo/miio/", line 2, in <module>
    from miio.protocol import Message, Utils
  File "/home/marius/miorobot/src/python-mirobo/miio/", line 38
    def verify_token(token: bytes):
SyntaxError: invalid syntax

I don’t know what I am doing wrong…

Hey, a good catch! I suppose it is about a missing typing package on python 3.4, python2 is not supported by the library at all.

I just pushed an update into git to install missing requirements, could you please install and try it again?