Lost access to control of the robot vacuum cleaner Xiaomi through Mi Home or third-party applications like Home Assistant? Without a token, the device will not respond to commands from the outside, neither through APIs nor through voice assistants. This article will help find or generate a token for any model, from the Mi Robot Vacuum first version to Xiaomi Vacuum-Mop 2 Ultra.
We'll look at 5 working methods, from official receipt via Mi Home to workarounds for devices with a China-based connection, and explain why a token might stop working and how to fix it. Importantly, the procedure is different for devices released before and after 2021 β more on that below.
What is Xiaomi vacuum cleaner token and why you need it
The token is a unique 32-digit access key that Xiaomi servers generate when you first link the vacuum cleaner to your account.
- π Integration with Home Assistant, ioBroker or other smart home systems.
- π± Control through informal applications (for example, Valetudo for cloud-free firmware).
- π£οΈ Voice control via Alice, Google Assistant or Siri (unless Mi Home is used).
- π οΈ Debugging and diagnostics through Python scripts or MQTT.
Without a token, the vacuum cleaner will only work through the original Mi Home app (or Xiaomi Home for new models), and if you reset your device to factory settings or change your account, the token will automatically be canceled and you will have to re-receive it.
Method 1: Receiving a token through Mi Home (official method)
The easiest way is to extract the token from the Mi Home app traffic, which works for devices linked to an account in China, Europe, Russia (but not for servers in Singapore or India).
- π± Android smartphone (on iOS method does not work due to restrictions) HTTP-traffic).
- π A vacuum cleaner already linked to your Mi Home account.
- π» Computer with Fiddler or Charles Proxy (for interception of traffic).
Step-by-step:
- Install Mi Home on Android and log in.
- Set up Fiddler to intercept HTTPS-Traffic (enable Decrypt) HTTPS traffic).
- On the smartphone in the Wi-Fi settings, specify a proxy server (IP of your PC and port 8888).
- Open Mi Home, go to the vacuum cleaner page and update the data (pull the screen down).
- In Fiddler, search for the domain api.io.mi.com with the path /app/genToken β the answer will be the line βtokenβ: βyour tokenβ.
βοΈ Preparation for the interception of the token
β οΈ Note: If there is no token in the server response, check the account region. For Chinese servers (cn), the token can be transmitted in encrypted form - additional decoding via miio-cli will be required.
Method 2: Removing a token from a Mi Home backup
If you have a Mi Home data backup (made through Settings β About β Backup), the token can be extracted from the file without intercepting traffic.The method works for backups created before April 2023 (after which Xiaomi changed the encryption format).
Instructions:
- Download the backup to your computer (file with the.mihome extension).
- Rename the extension to.zip and unpack the archive.
- Open the mihome.sql file in the text editor.
- Find the line with "token" = "- after it will be your key.
For new backups (after 2023), you will need a mihome-bin-decrypt tool:
python3 mihome_bin_decrypt.py -i backup.mihome -o output.sqlHow to find out the date of creation of the backup?
Method 3: Using a miio-cli script for new models
For vacuum cleaners released after 2021 (such as the Xiaomi Vacuum-Mop 2 Pro or DreameBot L10 Ultra), Xiaomi has implemented additional protection.The token is now tied to a unique device ID (did) and requires confirmation through the Mi Home API.
The receiving algorithm:
- Install Node.js and the miio-cli library: npm install -g miio-cli
- Sign in to Mi Home via the console: miio login (enter the login / password from the account to which the vacuum cleaner is attached).
- Get a list of devices: miio devices Find your vacuum cleaner in the list and copy it did.
- Create a token: miio token --did your did
If the command returns the Invalid device id error, it means:
- π΄ The device is linked to another account.
- π΄ Vacuum cleaner not connected to Wi-Fi.
- π΄ Your account is linked to the cn server (China) and you are using the European version of miio-cli.
π‘
If the miio-cli does not find the device, try to manually specify the region:
miio --region cn devicesmiio --region ru devicesMethod 4: Receiving a token through Valetudo (for hardwired devices)
If your vacuum cleaner is running on Valetudo custom firmware (an alternative to Mi Home without the cloud), the token can be generated directly in the web interface:
- Connect to the vacuum cleaner IP-address (e.g, http://192.168.1.100).
- Go to Settings β Cloud Interface β Mi Home Token.
- Press the Generate Token and the system will create a new key.
Advantages of this method:
- β Token is not tied to Xiaomi account β works even after reset.
- β No dependency on Mi Home servers (suitable for blocking by region).
- β You can use Home Assistant without cloud intermediaries.
β οΈ Note: Valetudo firmware will void the warranty and may result in the device being locked if Xiaomi detects a modification.Before installing, back up the original firmware!
Method 5: Buying a token from third parties β risks and alternatives
Offers for the sale of tokens for Xiaomi vacuum cleaners (for example, on AliExpress or thematic forums) are usually priced at 200-500 rubles, but this method has critical drawbacks:
| Risk | Effects of consequences | How to avoid |
|---|---|---|
| π Account data breach | The seller can access your Mi Home and other devices. | Use a separate account for the vacuum cleaner. |
| π« Locking the device | Xiaomi may block the vacuum cleaner for suspicious activity. | Buy tokens only from trusted sellers with a guarantee. |
| β³ Temporary token | The key may stop working in 1-3 months. | Check with the seller the expiration date. |
Alternatively, you can rent a cloud server (like Nabu Casa for Home Assistant) that manages the authorization itself, starting at $5 per month, but without the risk of being blocked.
π‘
Buying a token is a last resort, and try Valetudoβs official methods or firmware first if youβre ready to lose your warranty.
Frequent mistakes and their solutions
If the token does not work or the vacuum cleaner does not respond to commands, check:
- π Server Region: China (cn) firmware devices will not work with tokens received through European servers (eu). β Region).
- π Reset device: After hard reset (holding the button 10 seconds), the token is reset.
- π‘ Lockdown IP: If you frequently request a token, Xiaomi may block your IP 24 hours. Use it. VPN (The region is the same as the Mi Home server).
- β±οΈ Token expires: Keys obtained through miio-cli are valid for 1 year.
If the vacuum cleaner gives an error Device not found when using the token, check:
- Is it connected to the same Wi-Fi network as the device that sends the commands?
- Hasn't he changed? IP-Address (use static address) IP router).
- Has the device firmware been updated (sometimes Xiaomi changes the protocols of interaction).