Xiaomiβs robot vacuum cleaners (including Mi Robot Vacuum, Viomi, Dreame models) require a unique token to integrate with third-party smart home systems β Home Assistant, ioBroker or Node-RED. This token acts as a βpasswordβ for remote device management via the MIOT- protocol. The problem is that Xiaomi does not officially provide the token to users, hiding it in encrypted packages of the Mi Home application.
In this article, 5 current ways to extract a token on a PC (including methods for Windows, Linux and macOS), analyze typical errors (for example, Invalid token or Device not found), and how to check the token for health without risking blocking an account. All instructions are tested on models from 2020-2026 and are compatible with the latest firmware versions.
Why Xiaomi vacuum cleaner token cannot be officially obtained
Xiaomi intentionally restricts access to device tokens for three reasons:
- π Security: The token allows you to control the vacuum cleaner remotely, which creates the risk of unauthorized access (for example, through vulnerabilities in Home Assistant).
- π Ecosystem Control: Xiaomi is pushing its own Mi Home platform and restricting integration with competitors (e.g. Google Home or Apple HomeKit).
- π Monetization: Some features (such as zoning or schedules) may be paid for on third-party systems, whereas on Mi Home they are free.
However, the token can be extracted legally β it is stored in the cache of the application on your smartphone or transmitted in plain form when connected to the vacuum cleaner via Wi-Fi. The main thing is not to violate the user agreement (for example, do not distribute tokens publicly).
Method 1: Retrieving a token through Mi Home (Android) + PC
The most reliable method is to intercept traffic between the Mi Home app on your smartphone and Xiaomi servers.
- π± Android smartphone with Mi Home installed (version no lower than 6.0).
- π» A computer with Windows/Linux/macOS and a Fiddler or Charles Proxy program.
- π One Wi-Fi router (vacuum cleaner and smartphone must be on the same network).
Step-by-step:
- Install Fiddler (free) or Charles Proxy (paid but with a trial).
- On your smartphone, turn on Developer Mode (7 times click on the Build Number in your phone settings) and activate Debugging over USB.
- Connect your smartphone to your PC via USB and in Fiddler go to Tools β Options β Connections. Check Allow remote computers to connect.
- On your smartphone, in Wi-Fi settings, hold your finger on your network, select Change Network β Additionally, and in the Proxy field, specify the IP- address of your PC and the 8888 port.
- Start Mi Home, update the vacuum cleaner data (for example, open its map). In Fiddler, filter the queries by domain api.io.mi.com.
- Find a query with a URL containing /home/rpc/. The server response will have a string like βtokenβ: βyour token hereβ (usually 32 characters).
Install Fiddler/Charles on PC
Enable the developer mode on Android
Connect your smartphone to your PC via USB
Set up a proxy on your smartphone
Update the vacuum cleaner data in Mi Home-->
β οΈ Warning: If there is no token in the serverβs response, check:
- Mi Home version (in the old versions, the token was transferred openly, in the new versions it is encrypted).
- Account region (China Mainland and Europe server tokens are different).
- Availability of a VPN (disable it β it can redirect traffic)
Method 2: Use Mi Home Lite (without root)
The Mi Home Lite app stores tokens unencrypted in a configuration file, which works without root rights but requires access to the smartphone file system.
Instructions:
- Install Mi Home Lite from APKPure (official store may not be suitable).
- Log in and add a vacuum cleaner (if it was already in Mi Home, the data is synchronized automatically).
- Connect your smartphone to your PC and use ADB to copy the file: adb pull /data/data/com.xiaomi.smarthome.lite/shared_prefs/mihome_lite_preferences.xml
- Open the downloaded file in any text editor and find the string <string name="device_token_DID vacuum cleaner">... where the DID is a unique device identifier (e.g., 123456789).
How do I know the DID vacuum cleaner?
β οΈ Warning: If the mihome_lite_preferences.xml file is empty or there is no token in it, try:
- Restart Mi Home Lite and update vacuum cleaner data.
- Use another file: /data/data/com.xiaomi.smarthome.lite/databases/mihome.db (SQLite editor needed).
Method 3: Through ADB (for advanced users)
If you have root access on your smartphone, the token can be extracted directly from the Mi Home database using ADB. This method is suitable for Xiaomi and Viomi,Released models after 2019.
Steps:
- Install ADB Tools on your PC and connect your smartphone over USB.
- Run the command to access the shell: adb shell su cd /data/data/com.xiaomi.smarthome/databases sqlite3 mihome.db
- Enter SQL- request to search for the token: SELECT token FROM devices WHERE deviceID='DID vacuum cleaner';
If the token is not displayed, try an alternative request:
SELECT * FROM devices;π‘
If ADB issues a βpermission deniedβ error, check if root rights are enabled on your smartphone and if Magisk is installed (for modern Android).
| Model vacuum cleaner | Compatibility with ADB | Notes |
|---|---|---|
| Mi Robot Vacuum 1S | β Yes. | The token is stored in mihome.db |
| Viomi V3 | β Yes. | You may need a SQLite Editor. |
| Dreame D9 | β οΈ Partially. | Token is encrypted, you need a Python script |
| Mi Robot Vacuum-Mop 2 Lite | β Yes. | It only works with Mi Home versions 5.9-6.1. |
Method 4: Intercept the token through HTTP-proxy (without PC)
If you donβt have a computer, you can get the token using the HTTP- proxy directly on your smartphone. This will require the Packet Capture app (or HTTP Toolkit for Android).
Algorithm:
- Install Packet Capture and enable traffic recording.
- Start Mi Home and update the status of the vacuum cleaner (for example, click Cleaning).
- Stop posting and filter queries for the keyword miot-spec.org.
- In the body of the answer, find the token field. If it's not, check the api.io.mi.com queries.
β οΈ Warning: Some versions of the Mi Home use HTTPS with pinning, which blocks interception, in which case only changing the certificates (instruction below) will help.
How to get around HTTPS-pinning in Mi Home?
Method 5: Generation of a token through a Python script
For Dreame models (such as Dreame D9 or DreameBot L10 Pro), the token can be generated using Python and the miio library.
Instructions:
- Install Python 3.8+ and the Miio: Pip install python-miio library
- Download the mi_token_extractor.py script.
- Run the script with parameters (replace the IP_ vacuum cleaner and DID): python mi_token_extractor.py IP_ DID vacuum cleaner
Example of conclusion:
Device ID: 123456789
Token: a1b2c3d4e5f678901234567890abcdef
Model: dreame.vacuum.p2046β οΈ Warning: If the script gives an error Device did not respond, check:
- The vacuum cleaner is on and connected to the same Wi-Fi as the PC.
- Windows Firewall allows traffic to port 54321 (using the MIOT protocol).
- IP- address of the vacuum cleaner is static (assign it in the router settings).
How to check the token for performance
Before using the token in Home Assistant or other service, be sure to check it.
- Install Node.js and the Miio: npm install miio library
- Create a test_token.js file with the code: const miio = require('miio'); miio.device({address: 'IP_ vacuum cleaner', token: 'your token' }).then(device => console.log('Success! Model:', device.model)).catch(err => console.error('Error:', err));
- Start the script: node test_token.js.
If the output contains a vacuum cleaner model (e.g. roborock.vacuum.s5), the token is working.
| Mistake. | Reason. | Decision |
|---|---|---|
| Invalid token | Wrong token or region | Check the region of the account in Mi Home (configure the server in the script) |
| Device not found | The vacuum cleaner is off or offline | Reboot the vacuum cleaner and router |
| Timeout | Firewall locking | Disable Windows Defender or add an exception to miio |
π‘
If the token stopped working after 1-2 weeks, Xiaomi could reset it.Repeat the extraction procedure or use Home Assistant with Xiaomi Miio Auto integration, which updates the tokens automatically.
Frequent mistakes and their solutions
When you extract a token, you're faced with typical problems, and here's how to solve them:
- π The token changes after the Mi Home update: Xiaomi periodically resets the tokens for security.Use Home Assistant with the Xiaomi Cloud Map Extractor plugin, which updates the token automatically.
- π Region error: If the vacuum cleaner is bought for China and the account is registered in Europe, the token will not work. The solution is to change the region in Mi Home (account settings β Country/Region).
- π Account is blocked: if tokens are extracted too often, Xiaomi may temporarily block access.Wait 24 hours or contact support via the official website.
If none of these methods worked, try:
- Reset the vacuum cleaner to the factory settings (press the power button for 10 seconds).
- Use a virtual machine with Android-x86 and a clean Mi Home installation.
- Contact the Home Assistant community β there are up-to-date scripts for new models.