Xiaomi Token - at wits’ end

Hey all -
In the process of rebuilding my HA install, this time in a docker on Ubuntu 18.04.

As part of the rebuild, I bought another Xiaomi Mijia 1S and a Xiaomi Air Purifier.

Like I did with the last ones, I went to go extract the token from the Mi Home app, and have had zero luck.

I’ve installed multiple versions of the app, extracted the db files, used sqlite, inspected log files and I never find anything related to tokens.

miio discover, 5.4.24, 5.0.19, 5.4.49

Any suggestions on what I’m missing here?

All you need is Mi Home v5.4.54 apk:

Extract token from log file

This method will only work when you install the Mi Home app version v5.4.54. You can find it here. It looks like Xiaomi made a mistake in this app version where the log file written to internal memory exposes the device tokens of your Xiaomi miio devices.

  • Setup your Android device with the Mi Home app version 5.4.54
  • Log in with you Xiaomi account
  • Use a file explorer to navigate to /sdcard/SmartHome/logs/Plug_Devicemanager/
  • Look for a log file named yyyy-mm-dd.txt and open it with a file editor
  • Search for a string similar to this with you device name and token
{"did":"117383849","token":"90557f1373xxxxxxx8314a74d547b5","longitude":"x","latitude":"y","name":"Mi Robot Vacuum","pid":"0","localip":"192.168.88.68","mac":"40:31:3C:AA:BB:CC","ssid":"Your AP Name","bssid":"E4:8D:8C:EE:FF:GG","parent_id":"","parent_model":"","show_mode":1,"model":"rockrobo.vacuum.v1","adminFlag":1,"shareFlag":0,"permitLevel":16,"isOnline":true,"desc":"Zoned cleanup","extra":{"isSetPincode":0,"fw_version":"3.3.9_003460","needVerifyCode":0,"isPasswordEncrypt":0},"event":{"event.back_to_dock":"{\"timestamp\":1548817566,\"value\":[0]}
  • Copy the token from this string and you are done.

Refer https://github.com/jghaanstra/com.xiaomi-miio/blob/9702232ee35444a36a29cdb336d668eda4046c6a/docs/obtain_token.md

There is a method which worked for me several times I did it but it’s little shady,

Install Android emulator (NOX), install modded MiHome app from here:

link named “something 5.5.51” check it leads to .apk file

This version has “about” screen for every device and token written plain simple like this:

CNHjaGNW2HDoj7I1F5OMPGv7ViO5rRhIwKEwfBmq1SU

Also found this release which supposed to show tokens but have not tested yet:

1 Like

I ended up wiping my tablet and started over…all’s good with v5.4.54.

Thanks much for the input!

It took me a little bit to find this post, but I did and 7 months later, using the Mi Home app version 5.4.54 worked perfectly to get the token and setup within Home Assistant. Thanks for sharing.

1 Like