Extract philips xiaomi key

Wonder if anyone can help with this. Downloaded the MiToolKit.
Enabled the dev mode on usb (i have a redmi 3S)

Launch the tool kit as an admin. Get the fetch key. I can see the mi home app opening on the phone. But that’s it. No backup process is started and soon after get an error in tool kit that “sorry file is too short”

P.S. One dumb question - I do n’t need to run this from my HA installation. Do i?

1 Like

if you just want to get the token,i hope this method will help you:
1.your phone(android os) has been rooted;
2.find the database file /data/data/com.xiaomi.smarthome/database/miio2.db via ‘RE EXPLORER’(it’s an app);
3.use ‘DB Browser for SQLite’(it’s an app) find the table ‘devicerecord’ in miio2.db,then you will get the token of the philips xiaomi key(token);

1 Like

I know it sounds funny - but didn’t root this one. Not sure want to go through the hassle.
So question is… Is the token regenerated after device rest? If i share the device via MiHome to a rooted phone - will the token get stored in the database?

According to my experience,if you never changed the light’s position,the token is stationary,if not(from living room to bed room,for example),it will be changed.

1 Like

I just followed the official doc (same for Xiaomi robot vacuum) and it works without any problem with non rooted phone

Well glad to hear that ) For me it didn’t work. 2 Phones - share same results. So either there is a catch with Xiaomi’s security setting deep inside (both phones are from this maker) or simply doesn’t work on my setup (W10 running on top of ESXi)

Here is what i get on manaul input. Seems Xiaomi has some lock…

C:\TMP\MiToolkit 1.5\adb\36>adb devices
List of devices attached
bxxxde3c7xxx    device
C:\TMP\MiToolkit 1.5\adb\36>adb backup -noapk com.xiaomi.smarthome -f backup.ab
Now unlock your device and confirm the backup operation...

P.S. Long time didn’t go into the internals of android? Maybe there is an option to do a full backup of the phone via adb or other means and then extract the file?

What do you mean about the lock ?
Normally after you get to that part, you just have to, as mentioned in your log, go to your phone and validate the backup window that should pop-up. You mean no window pops up on your phone?

Btw, if you figure out that part, just to let you know that HA 0.57.2 version released has introduced a bug in the Xiaomi Philips ceiling detection.
You have to edit homeassistant/components/light/xiaomi_miio.py until this fix is published:

There are no pop-ups or back up announcments

Ok. Got it settled. Not sure which one helped so for all the xiaomi brand phone owners:

(I have Russian set for the interface, so if someone can correct the names will be great. Then can push it to the docs)

Go to Programs->Security and then apps. Then at top left choose permissions. Tap the gear icon at top right and switch on allow installation via usb.

Now go to settings. Dev mode and activate the usb debugging. Take a look further below. Activate also USB security settings. It will give you around 5 warnings press ok for all of them. Now you can switch on install via usb which is also there.

Now follow the procedure from HA docs.

than?or then.

Hi all,
Looks like issue mentioned in this post is already solved but I faced with a little bit different situation. Actually I didn’t find better place where point to other problem related to token.
My Mi-tool can do full backup but after all operation finished I can see just lamp names and IP addresses but there no tokens.I tried this with 2 phones running not rooted Android 7.0. Just when my 3rd attempt read DB
was successful with Android 6.0.
Also one of my Android 7.0 phones is encrypted and i was not able to run backup process without entering any password - this also is a problem with MiToolKit

Actually I read tokens with Android 6 and just wanted to write this as point to everyone who can’t read it and hope it to be fixed in new MiToolKit releases

Yep, same for me. I’m also curious how to get the token. It looks like the latest MiHome App is not saving the token locally.

mi home 5.0.19 can read keys.
just google for apk file and install