Xiaomi Mi Vacuum Token from iOS?

Not sure how to be more clear… Again read the docs, do exacty what is written and you’ll be fine. If not, post what you have done.

comments are just a note regarding android. Follow instructiions at the bottom of page:

iOS

  1. Configure the robot with the Mi-Home app.
  2. Using iTunes, create an unencrypted backup of your iPhone.
  3. Install iBackup Viewer, open it, and open your backup.
  4. Open the “Raw Data” module.
  5. Navigate to com.xiaomi.mihome.
  6. Search for a file that looks like this: 123456789_mihome.sqlite – note that _mihome.sqlite is not the correct file.
  7. Save this file to your filesystem.
  8. Install DB Browser for SQLite.
  9. Open DB Browser and load the .sqlite file you saved from your backup.
  10. Click on the Execute SQL tab.
  11. Input and run this query: SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME LIKE “%Vacuum%”
  12. Copy the returned 32-digit hexadecimal string to your clipboard.
  13. Open Terminal and execute this command: echo '0: ’ | xxd -r -p | opensslenc -d -aes-128-ecb -nopad -nosalt -K 00000000000000000000000000000000
  14. Use the resulting string as your token.
1 Like

I had trouble getting my token out of iOS… I ended up extracting the SQL database from an iPhone backup if you have access to OS X. Maybe it will help you, here are my notes

I guess there are two things that aren’t clear:

  1. how do you do this with Linux? The iBackup Viewer app that’s referenced seems to only be available for Mac or Windows

  2. what about the box below from the docs? Does this not apply at all for iOS?

As per python-miio issue 185 the Mi-Home app no longer stores the token within the database (it’s retrieved from Xiaomi servers from version 5.0.31+). Currently the only known fix is to uninstall, then install a downgraded version of the apk. Apkmirror is a trusted source for older versions of the app. Mi-Home version 5.0.0 is confirmed as working for the following Android methods.

Thanks @oakbrad that’s really helpful!

You need MacOS or Windows as you need a backup created in iTunes. The “info box” applies to Android only. If you have an IOS device but no Windows or MacOS you could install the Mi-Home version 5.0.0 app on an Android emulator.

Same here stuck on the DB Browser part. I see the file bit the command SELECT ZTOKEN FROM ZDEVICE WHERE ZNAME LIKE “%Vacuum%” returns nothing.

I have IOS and Mac OS

It probably means you’ve selected the wrong file @ point 6.

I’ve never had any luck with the search actually. I did write a blog post with screen shots about how to retrieve the token here.

Maybe that will help. It’s pretty easy to find even without searching.

4 Likes

Very useful @DavidFW1960 !

1 Like

I had no trouble extracting the token from an iTunes backup of my phone but should have realised the command had to be run on a unix system when the instructions here mentioned Terminal instead of Command Prompt. @David’s instructions were much clearer.

2 Likes

Thank You David!! Can you please add these pictures somewhere to the poor instructions of home assistant integration?