How to find out the token of the vacuum cleaner Xiaomi Vacuum Cleaner: 5 proven ways

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:

641a2d7d6d3a4b1c8e9f0a1b2c3d4e5f

Without 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:

  1. Open Mi Home and make sure the vacuum cleaner is connected to the network.
  2. Go to Profile. β†’ Settings β†’ General settings β†’ About the programme.
  3. Click 5-7 times on the app version until the wording Developer Mode is enabled appears.
  4. Back to Settings β†’ General settings - there will be a new item Developer Mode.
  5. 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:

  1. Connect your phone to your PC and enable debugging. USB (Settings β†’ The phone. β†’ Assembly number - press 7 times).
  2. In the command line, do: adb pull /data/data/com.xiaomi.smarthome/databases/mihome.db
  3. Open the downloaded file mihome.db in DB Browser.
  4. Go to the Data Overview tab and select the devicerecord table.
  5. 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 cleanerName in mihome.dbNote
Xiaomi Mi Robot Vacuummiio:vac or vacuum.v1Old models (2016–2018)
Xiaomi Mi Robot Vacuum-Mop 2viomi.vacuum.v7 or dreame.vasThe token can be stored in a device, not in a devicerecord.
Dreame D9dreame.vac.mc1808Mi Home version not lower than 6.1.4 is required
Viomi V3viomi.vacuum.v18The 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:

  1. Install and run Charles Proxy on PC.
  2. In the phone settings add a proxy server (IP Your PC and port 8888).
  3. In Charles, enable traffic recording (Proxy) β†’ Start Recording).
  4. Open Mi Home and update the status of the vacuum cleaner (for example, click Cleaning).
  5. In Charles, search for api.io.mi.com domain with a path /app/genToken or /home/rpc/....
  6. 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:

  1. Install Python 3.8+ and python-miio: pip install python-miio
  2. Download the script miio_extract_token.py.
  3. Connect your phone to your PC and start the script: python miio_extract_token.py
  4. 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?
This error means that the script could not find the file mihome.db. Possible reasons and solutions: 1. Mi Home hasn’t been updated in a long time – update the application and try again. 2. Android 11+ with access restrictions - allow in the settings of the phone ADB Backup for Mi Home (Settings) β†’ Annexes β†’ Mi Home β†’ Permits β†’ Backup). 3. The vacuum cleaner is not tied to the account - check in Mi Home that the device is displayed in the list. 4. Uses the Chinese version of Mi Home - some regional versions encrypt the database. Try installing a global version of the application.

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:

  1. 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).
  2. 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"
  3. 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 causeDecision
Token Not Found in Developer ModeOlder version of Mi Home or regional restrictionsUpdate the app to the latest version or install a global version APK
The mihome.db file is empty or missingThe application did not sync the data or reset settingsRestart Mi Home, wait for sync and try again
SSL error-certification MITM-proxyXiaomi blocks unverified certificatesInstall 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 AssistantToken received for another region or device resetCheck 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:

  1. Untie the vacuum cleaner from your Mi Home account immediately.
  2. Change the password from the Mi Account.
  3. 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!

FAQ: Answers to Frequent Questions

Can I get a token without a phone?
Yes, but with limitations. You can use method 5 (cloud). API), You need to access your Mi Account and Device account. ID The alternative is to borrow a friend's Android phone temporarily to extract the token through mihome.db.
Why does the token change after the vacuum cleaner is dumped?
The token is not tied to the device, but to a pair of β€œaccounts”. + When you reset, the vacuum cleaner forgets the account binding, and after you add it again, a new token is generated. The old key stops working.
Does the token work for Dreame and Viomi vacuum cleaners?
Yes, but with nuances, Dreame and Viomi devices (like Dreame) D9 viomi V3) MiIo protocols are also used, so the token can be obtained in the same way, but in mihome.db they can be listed under different names (see table in method 2).
Can I use one token for several vacuum cleaners?
No. Each device has a unique token, even if they're tied to one Mi Account. For example, if you have two Xiaomi Mi Robot Vacuum vacuum cleaners, each will have its own key.
What to do if the token stopped working?
The reasons may be different: πŸ”„ Xiaomi has updated the authentication protocol (try to get a new token). πŸ“΅ Vacuum cleaner has been disconnected from Wi-Fi for more than a month (repeated binding is required). πŸ”’ Mi Account blocked for suspicious activity Solution: untie and re-attach the vacuum cleaner to the account, then get a new token.