Integrating smart tech into a single ecosystem often requires special access keys. If youβre an owner of Xiaomi Mi Robot Vacuum or any other brand model, you may need a device token to connect to third-party smart home systems like Home Assistant, or to use advanced features via APIs.
Windows users face difficulties, as official utilities for extracting this key are often sharpened for Linux or macOS. However, there are proven methods to circumvent this limitation.
In this article, we will discuss the current ways to obtain a token without having to install complex virtual machines or disassemble a device, and you will learn to use emulators and specialized software to safely extract the necessary data.
What is a device token and why is it needed
The token is a unique string of 32 hexadecimal characters that serves as the authorization key between your smartphone and a smart device. Without this key, the MiIO protocol used by Xiaomi will not allow third-party software to send commands to the vacuum cleaner.
The main purpose of the token implementation is security, even if the attacker finds out IP-The address of your router, it can't control the hardware without this secret bundle, which is why the token doesn't show up in the standard interface of the Mi Home app.
Obtaining this code is necessary in the following cases:
- π Set up integration with Home Assistant to create complex automation scenarios.
- π Using local management through LAN, Installations to be executed instantly without cloud server delays.
- π Diagnostics and debugging of the device through the command line or specialized utilities like miio-cli.
β οΈ Warning: The token is a secret access key. Never give it to anyone else or publish screenshots of it in public.
It is important to understand that the token is tied to a specific Xiaomi Cloud account and a specific device. If you drop the vacuum cleaner to the factory settings or link it to another account, the token will change and you will have to repeat the procedure.
Workplace preparation and necessary tools
Before we start extracting data, we need to prepare the software environment on your Windows computer, and since it is impossible to connect directly to the phone database without root rights, we will go by emulation or using web interfaces.
You will need a stable internet connection and Xiaomi account, which is already tied to the vacuum cleaner. Make sure that the Mi Home app on your smartphone works correctly and displays the device on the network.
To work on Windows, we will need the following components:
- π» Google Chrome or Chromium-based browser (Edge, Yandex.Browser) with installed extensions for working with the browser API.
- π± Android Emulator (e.g. BlueStacks, NoxPlayer or LDPlayer) β optional if the web method doesnβt work.
- π¦ Python 3.x A set of miio or python-miio libraries for advanced users who want to automate the process.
It is also recommended to back up important data, although the methods described are safe and do not require flashing the device.
Method 1: Use of browser extension (the easiest)
The fastest way to get a token on Windows is to use a specialized browser extension, which does not require heavy emulators and works directly through the Xiaomi Web authorization interface.
First, you need to install an extension, such as Xiaomi Cloud Tokens Extractor. After installation, open the extension bar and find the corresponding plugin. You will be prompted to enter the username and password from your Mi Account.
The process is as follows:
- Click on the extension icon and select your server region (e.g. Europe or Russia).
- Enter the credentials and click the Get Tokens button.
- The system will request a confirmation code, which will come in the form of an SMS or push notification to your phone.
- Enter the code in the extension field, and after successful authorization, you will see a list of all the devices with their tokens.
Find your vacuum cleaner (usually designated as roborock.vacuum or similar identifier) and copy the 32-digit code. This is the key you want.
β οΈ Attention: Using third-party extensions requires you to enter a password from your account.Make sure you use an open source extension with positive community reviews to eliminate the risk of data theft.
If the extension canβt find the devices, check if the server region is correctly selected. A server error (e.g., choosing China over Europe) will result in an empty list of devices, even if the login is correct.
Method 2: Android Emulator on Windows
If the web method didnβt work or you prefer a more isolated environment, you can run a full-fledged Mi Home app inside the Android emulator on your PC, which is considered more secure since you donβt pass the password to third-party scripts.
Download and install any popular emulator, such as NoxPlayer or BlueStacks. Once you run the emulator, you need to download it. APK-It is best to download the latest version from the official Xiaomi website or a reliable resource like APKPure, since emulators often do not have Google Play Store or it works incorrectly.
Next, perform the following actions:
- π² Install. APK to the emulator and launch the application.
- π Sign in to your Xiaomi account.
- π Enable Root access in the emulator settings (usually through the emulator settings in the Root permissions section").
- π Install a file manager with access to system folders (e.g., Root Explorer).
βοΈ Preparation of the emulator
After authorization and the vacuum cleaner appears in the list of devices, go to the file manager on the way:
/data/data/com.xiaomi.smarthome/files/miio_storageOr, depending on the version of the app:
/data/data/com.xiaomi.smarthome/databases/miio.dbYou need to find a file with the.token extension or a database containing tokens. UID Copy this file onto a computer and open it with a text editor or HEX-editor to see the string of token.
Method 3: Using Python scripts (For Advanced)
For those who are not afraid of the command line, the python-miio library is a great solution, and it works on any operating system, including Windows, with Python installed.
First, install Python from the official site, be sure to tick Add Python to PATH when you install it. Then open the command prompt (cmd) or PowerShell and install the required library with the command:
pip install python-miioNext, we need to get the token through interception or using a known bug in older versions of the protocol, but the most reliable way for Windows is to use the miio utility in conjunction with an emulator or a pre-received token. However, if you have the ability to run a Linux script or use WSL (Windows Subsystem for Linux), you can use the command:
miio extract-tokens --username your login --password your passwordThe table below shows a comparison of methods in terms of complexity and reliability:
| Method | Difficulty | Security | Skills required |
|---|---|---|---|
| Browser extension | Low. | Medium | Basic |
| Android emulator | Medium | Tall. | Average. |
| Python / CLI | Tall. | Tall. | Advanced |
| Root on the phone | Very high. | Tall. | Expert |
Using Python gives you the most control. You can not only get a token, but you can also immediately send a test command to the vacuum cleaner, for example, start cleaning or send it to the base.
β οΈ Warning: When working with the command line, carefully check the syntax of commands. Error in arguments can lead to blocking IP-Xiaomi servers because of too frequent requests.
Problems with server regions and their solution
One of the most common problems when trying to learn a token is the wrong region: Xiaomiβs ecosystem is divided into several independent clusters: China, Europe, Russia, India, the United States and others.
If your account is registered in the Russia region and you are trying to get a token through the China server, the request will return an authorization error or an empty list of devices.
How to determine the correct server:
- π Open the Mi Home app on your phone.
- π€ Go to the profile (the tab "My").
- π Look at the top of the screen and see the current region (e.g., "Russia" or "Germany").
What if the region is not defined?
Also, you should consider that some devices may be βlockedβ in the Chinese region, and if you bought a vacuum cleaner on AliExpress, it may require a connection to a cn server (China), even if you are in Europe, in which case the application will have to change region, which may take time.
Set up local management after receiving the token
Once you have successfully copied the 32-character key, itβs time to apply it, most often in the integration settings in Home Assistant or in the configuration file of the plugin for the smart home.
The process of adding a device usually looks like this: you choose the Xiaomi Miio platform, type in IP-the address of the vacuum cleaner (it can be found in the router or in the Mi Home application in the properties of the device) and insert the received token.
To check the performance, you can use a simple command in the terminal (if you have python-miio installed):
miio --ip 192.168.1.XXX --token your statusIn return, you should receive JSON-object with the current vacuum cleaner state: charge level, cleaning status, dust container volume and noise level.
π‘
Keep the token safe. It's best to write it to a password manager or an encrypted file. Losing the token will require you to repeat the whole procedure all over again, especially if you reset the device.
Now your vacuum cleaner is fully integrated into the local network, and you can create automations, like running a cleaning operation when all the family's phones leave the geofence at home, or sending a notification to Telegram if the dust container is full.
π‘
Getting the token is a key step to turning a regular Xiaomi vacuum cleaner into a full-fledged element of a smart home with local control without delay.