How to get Xiaomi token on iOS device

May 25, 2020

Based on this tutorial you can extract tokens for all Xiaomi devices like Air Purifier, Smartmi Standing Fan, Da Fang camera or Mi LED Desk Lamp. It works for all iOS devices regardless it's jailbroken or not. You can use extracted token to control your Xiaomi device using alternative apps like Apple HomeKit through Homebridge, Domoticz or Home Assistant.

If you have tried the method using miIO library without luck this might be the solution for you.

Before start you have to get and install Xiaomi Home iOS app. Also you need to add there and configure your Xiaomi device with WiFi. If you can control your device using Xiaomi Home means that you are good and you can continue on this tutorial.

How to get the device token out of the iOS backup

  1. Back up your iOS device with your computer like described here.
  2. Install iBackupTool.
npm i ibackuptool --save
  1. List all the backups on your computer.
ibackuptool -l
  1. Extract Xiaomi Home database from your backup.
ibackuptool -b "UUID_FROM_PREVIOUS_STEP" -r backup.files --extract extraction_destination --filter "mihome.sqlite"

iOS backups list

  1. Open Xiaomi Home databse.
cd extraction_destination/AppDomain-com.xiaomi.mihome/Documents/

sqlite3 1595971111_mihome.sqlite

SQLite database query

  1. Run this query to get Xiaomi tokens.
  1. Go to this webpage and decrypt extracted Xiaomi token.

How to decrypt Xiaomi tokens