Xiaomiβs robot vacuum cleaners have long been an integral part of smart homes, but working with them through third-party applications (such as Home Assistant, Yandex Alice or IoBroker) requires a unique device token. API, And getting it often raises questions for users.
In this article, we will discuss all the current ways to obtain a token for Xiaomi Vacuum models (including Mi Robot Vacuum, Viomi, Dreame, etc.), from official methods through the Mi Home app to alternative solutions for power users.
If you are just starting to learn smart technology or have already encountered errors when integrating a vacuum cleaner into third-party systems, here you will find step-by-step instructions with illustrations, compatibility tables and answers to frequent questions.
1.What is Xiaomi vacuum cleaner token and why you need it
A token (or device token) is a unique identifier that is assigned to each Xiaomi device when first associated with a Mi Account. It consists of 32 characters (digits and Latin letters) and looks like this:
641a2d7d6d3a4b1c8e9f0a1b2c3d4e5fWithout this key, third-party applications and services will not be able to:
- π± Control the vacuum cleaner through voice assistants (Alice, Google Assistant)
- π Automate cleaning on schedule outside of Mi Home
- π Receive data on the status of the device (charge, errors, room maps)
- π§ Integrate vacuum cleaner into Home Assistant or Node-RED systems
It is important to understand that the token is not the same as the password from Wi-Fi or Mi Account. It is tied specifically to the device and does not change when you reset the vacuum cleaner settings (if you do not untie it from the account), while the token gives full control of the device, so it cannot be transferred to third parties.
β οΈ WARNING: If you find a βXiaomi token databaseβ on the Internet or someone offers to buy a token, it is fraud. Such keys are either non-working or associated with stolen accounts. Using someone elseβs tokens can lead to the blocking of your device.
2. Method 1: Receiving a token through the Mi Home app (official method)
The easiest and safest way to extract the token directly from the official Mi Home app is to do this without technical skills, but you will need to:
- π± Smartphone with Mi Home installed (version not lower than 6.0)
- π A vacuum cleaner tied to your Mi Account
- π Access to the phone file system (for Android)
Instructions for Android:
- Open Mi Home and make sure the vacuum cleaner is connected to the network.
- Go to Profile. β Settings β General settings β About the programme.
- Click 5-7 times on the app version until the wording Developer Mode is enabled appears.
- Back to Settings β General settings - there will be a new item Developer Mode.
- Select Local Network (Mi IoT) and find your vacuum cleaner in the list. The token will be listed in the Token field.
There is no official way for iOS, but you can use a workaround through MITM-Proxy (consider in method 4) Alternatively, install Mi Home temporarily on a friend's Android device.
Vacuum is connected to Wi-Fi|Mi Account is tied to the device|Mi Home version at least 6.0|Android has enabled debugging on USB (if you use ADB)-->
β οΈ Note: After upgrading to version 6.4.7 and above, the token may not be fully displayed in developer mode (the last characters are replaced with stars.
3. Method 2: Retrieval of the token through the file mihome.db (Android)
If the developer mode doesnβt show the token, or youβre using an older version of Mi Home, you can extract the key directly from the applicationβs database.
- π± Root rights or access to files through ADB
- π» A program to view SQLite databases (for example, DB Browser for SQLite)
Step-by-step:
- Connect your phone to your PC and enable debugging. USB (Settings β The phone. β Assembly number - press 7 times).
- In the command line, do: adb pull /data/data/com.xiaomi.smarthome/databases/mihome.db
- Open the downloaded file mihome.db in DB Browser.
- Go to the Data Overview tab and select the devicerecord table.
- Find a line with your vacuum cleaner (by model name) β the token will be in the token column.
If you donβt have root rights, you have access to ADB, utility sqlite3 right on the phone:
adb shell
su
cd /data/data/com.xiaomi.smarthome/databases/
sqlite3 mihome.db"SELECT token FROM devicerecord WHERE name LIKE'%vacuum%';| Model vacuum cleaner | Name in mihome.db | Note |
|---|---|---|
| Xiaomi Mi Robot Vacuum | miio:vac or vacuum.v1 | Old models (2016β2018) |
| Xiaomi Mi Robot Vacuum-Mop 2 | viomi.vacuum.v7 or dreame.vas | The token can be stored in a device, not in a devicerecord. |
| Dreame D9 | dreame.vac.mc1808 | Mi Home version not lower than 6.1.4 is required |
| Viomi V3 | viomi.vacuum.v18 | The token can be encrypted (use method 5) |
π‘
If the devicerecord table is empty, try searching for a token in the device table or check that the vacuum cleaner is turned on and connected to Wi-Fi at the time of data extraction.
4. Method 3: Use of the MITM-proxy (iOS/Android)
This method is suitable for iOS and Android, but requires a Man-In-The-Middle setup.The bottom line is that you intercept network traffic between your phone and Xiaomi servers when the Mi Home app accesses the vacuum cleaner.
You'll need:
- π» Computer with Charles Proxy or Fiddler installed
- π± Phone and computer in the same Wi-Fi network
- π§ Certificate for interception HTTPS-traffic
Instructions:
- Install and run Charles Proxy on PC.
- In the phone settings add a proxy server (IP Your PC and port 8888).
- In Charles, enable traffic recording (Proxy) β Start Recording).
- Open Mi Home and update the status of the vacuum cleaner (for example, click Cleaning).
- In Charles, search for api.io.mi.com domain with a path /app/genToken or /home/rpc/....
- The server response will have a string of the type "token":"641a2d7d6d3a4b1c8e9f0a1b2c3d4e5f".
β οΈ Attention: Xiaomi is actively fighting traffic interception.If you see a bug SSL handshake failed, so the server found the proxy: π Reboot Mi Home and Repeat the Interception π΅ Shut down. IPv6 phone-on π Use another proxy tool (e.g., mitmproxy)
Official (via Mi Home)|Through the database (mihome.db)|MITM-proxy|Third-party utilities (Python scripts)|I haven't tried it yet.-->
5. Method 4: Automated token extraction using Python scripts
For users familiar with programming, there are pre-built Python scripts that automate the process of getting a token, one of the most popular being mihome-bin or Python-Miio.
Installation and use:
- Install Python 3.8+ and python-miio: pip install python-miio
- Download the script miio_extract_token.py.
- Connect your phone to your PC and start the script: python miio_extract_token.py
- Follow the instructions on the screen (you will need to enter the username / password from Mi Account).
Script automatically:
- π Finds the mihome.db file on your phone
- π Retrieves tokens of all associated devices
- π Save them in a tokens.txt file
Advantages of the method:
- β It works without root rights (uses it). ADB backup)
- β Supports new models of vacuum cleaners
- β We can run on Windows/Linux/Mac
What if the script gives a Device Not Found error?
6. Method 5: Receiving a token through the Xiaomi cloud (for power users)
This is a method that works if you have access to Mi Account, but you don't have the ability to work with your phone. API Xiaomi to extract token through the cloud.
You'll need:
- π₯οΈ Computer with Curl or Postman
- π Login and password from the Mi Account
- π Device ID vacuum cleaner (can be found in Mi Home in device settings)
Steps:
- Get serviceToken (temporary key for the service) API): curl -X POST"https://account.xiaomi.com/pass/serviceLoginAuth2" \ -H"Content-Type: application/x-www-form-urlencoded" \ -d"clientId=180100041053&packageName=com.xiaomi.smarthome&sign=YOUR_SIGN&locale=ru_RU&user=YOUR_EMAIL&hash=YOUR_PASSWORD_HASH" Where YOUR_PASSWORD_HASH β it MD5-your password hash (can be generated here).
- Use serviceToken to get a list of devices: curl -X POST"https://api.io.mi.com/app/home/device_list" \ -H"x-xiaomi-protocal-flag-cli: PROTOCAL-HTTP2" \ -H"Cookie: serviceToken=YOUR_SERVICE_TOKEN"
- In the answer, find your vacuum cleaner by deviceID - the token will be in the token field.
β οΈ Note: This method violates Xiaomiβs user agreement and can lead to a temporary account lock when used frequently. API, The request may stop working.
π‘
The most reliable ways to obtain a token are through the developer mode in Mi Home (method 1) or Python script (method 4). API Risky and may stop working after updates.
7. Frequent errors and their solutions
When trying to get a token, users often face problems, and consider the most common and ways to eliminate them:
| Mistake. | Possible cause | Decision |
|---|---|---|
| Token Not Found in Developer Mode | Older version of Mi Home or regional restrictions | Update the app to the latest version or install a global version APK |
| The mihome.db file is empty or missing | The application did not sync the data or reset settings | Restart Mi Home, wait for sync and try again |
| SSL error-certification MITM-proxy | Xiaomi blocks unverified certificates | Install the root certificate Charles in trusted on the phone |
| The token is made up of stars () | Restrictions on the new Mi Home (6.4.7)+) | Use the method with mihome.db or Python script |
| Invalid token when connecting to Home Assistant | Token received for another region or device reset | Check that the vacuum cleaner is tied to the same account as in Mi Home |
If none of these methods worked, try:
- π Re-connect the vacuum cleaner to the account (Device settings) β Untie and add again).
- π± Install an old version of Mi Home (e.g. 6.1.4) β sometimes newer versions hide the token.
- π§ Write in support of Xiaomi with a request to provide a token (specify the model and Device) ID).
8 Security: How to Protect Your Token and Account
The vacuum cleaner token is the key to controlling the device, so its leakage can lead to:
- πͺ Unauthorized access to the vacuum cleaner (on/off, changing settings)
- π Leaking your home layout data (if a vacuum cleaner builds a map)
- π Blocking your Mi Account in case of suspicious activity
Safety regulations:
- π Donβt give the token to anyone, even for testingΒ».
- π Store the token in a secure location (for example, in a password manager).
- π Regularly check the list of attached devices in Mi Home for unknown gadgets.
- π‘οΈ Enable two-factor authentication in your Mi Account.
If you suspect that the token has been compromised:
- Untie the vacuum cleaner from your Mi Home account immediately.
- Change the password from the Mi Account.
- Tie the vacuum cleaner again - a new token will be generated.
π‘
If you are integrating a vacuum cleaner into Home Assistant, use a component xiaomi_miio Encrypt your configuration file. Never place a token in GitHub's open repositories!