Integrating Xiaomi, Roborock or Dreame smart vacuum cleaners into a single smart home management system, such as Home Assistant or HomeKit, often requires unique access keys. Without that data, your smart home won’t be able to send commands to the device bypassing the manufacturer’s cloud servers. The main parameters for local management are Token (access token) and IP-device address on the local network.
The process of obtaining this data may seem difficult for a beginner, but it really boils down to performing sequential actions through a mobile application or third-party software. In this article, we will discuss all the current methods, from using special plugins to manually extracting data from the system logs. You do not need deep knowledge of programming, just follow the instructions carefully.
Why is this so important? Cloud solutions often have delays, and when you shut down the Internet, the vacuum cleaner becomes "stupid." Local control through miio protocol provides instant response and operation without an external network. Let's look at how to get the necessary parameters for your model.
Why do you need a token and IP-Address to Xiaomi Vacuum
Many users mistakenly believe that the standard Mi Home app is enough for complete control, but direct communication is required to create complex scenarios, such as starting a cleanup when everyone leaves the house or stopping when water leaks are detected. IP-The address indicates where the device is located on your network, and Token serves as a digital key that encrypts commands.
The miIO protocol used by Xiaomi’s ecosystem is based on encrypted messaging, and if you try to send a command without the right token, the device will simply ignore the request, and it’s done for security reasons so that neighbors or intruders can’t control your equipment.
Why is the token changing?
Knowing these parameters opens up access to advanced features that are often hidden in official software, so you can customize virtual walls, control suction power in different rooms, and get detailed map statistics in real time.
Preparation: What will be required before the start
Before you start extracting data, you need to make sure your network and devices are ready to go. Local control is only possible when the smartphone and vacuum cleaner are in the same subnet. Make sure that the router has turned off customer isolation (AP Isolation) if it is turned on.
You’ll need a computer (Windows, macOS, or Linux) or a smartphone with superuser rights (for some methods), and it’s critical to know the region you chose when you first set up the vacuum cleaner in the Mi Home app. A mistake in choosing a region will result in the token being received incorrectly or not being able to connect to the server.
☑️ Checking readiness for setup
It is recommended to record the current IP-This will prevent the vacuum cleaner from getting a new address after the router is rebooted, and the integration with the smart home will break. IP It makes life easier in the long run.
Method 1: Use the Home Assistant plugin (Xiaomi Cloud Map Extractor)
The most popular and convenient way for Home Assistant server owners is to use Xiaomi Cloud Map Extractor integration or Xiaomi Miio standard integration.
You will need to get the Xiaomi cloud login data (login and password) and device ID. Once you add integration to the configuration.yaml, the system will try to contact Xiaomi servers and extract the token. However, this method does not work if two-factor authentication is enabled or a server is used outside of China/Europe.
💡
Use a separate Mi Account for the smart home, so as not to risk the main one, which will simplify the process of obtaining a token and protect your personal data in the event of a compromise of the smart home system.
If automatic retrieval didn't work, you can use the Python miio script, which is often bundled with integration documentation, which allows you to query the cloud and display a list of all devices with their tokens in readable form.
Method 2: Receiving a token through Android emulator and mitmproxy
This method is considered the “gold standard” because it works independently of Xiaomi servers and region, and the essence is to intercept network traffic between the Mi Home application and the server, using the mitmproxy tool and an Android emulator, such as NoxPlayer or BlueStacks.
First, you need to install a mitmproxy certificate on the emulator to be able to decrypt the emulator. HTTPS Then you need to prescribe the proxy settings in the Mi Home app. IP-After that, any action in the application (for example, turning on the vacuum cleaner) will generate a request containing a token.
In mitmproxy logs, you need to search for domains like api.io.mi.com or api.mi.com. The query body (JSON) contains the token field. This is the 32-character string you want, and despite its apparent complexity, this method yields 100% results even for new models.
| Parameter | Description | Where to find out. |
|---|---|---|
| Tokken | 32-character access key | V JSON-server response (token field) |
| IP-address | Local address of the device | In the Mi Home app or router |
| Did | Unique device ID | In the information about the device in Mi Home |
| Region | Server region (cn, ru, eu) | When setting up an account |
💡
The mitmproxy method is versatile and suitable for any Xiaomi ecosystem devices, including lamps, sockets and cameras, not just vacuum cleaners.
Method 3: Using Python Python Library
For advanced users familiar with the command line, python-miio is a great solution, which allows you to interact with the device directly. If you already have a token (for example, received through the cloud), you can check it and find out the IP by performing a detection command.
Run a network scan by the team miio discover. The utility will try to find all Xiaomi devices on the local network. IP-Address and model: To receive a token through this tool will still require preliminary preparation through the cloud method or emulator.
miio --ip 192.168.1.55 --token 1234567890abcdef1234567890abcdef infoThis command will display detailed information about the vacuum cleaner status, if the token is correct, and you will see the charge level, filter status, firmware version and current operating mode, and this is the best way to check the key's performance before adding the device to Home Assistant.
⚠️ Warning: Make sure the firewall on your computer does not block UDP-It's through this port that you have local communication with the vacuum cleaner. If the port is closed, the teams just won't get to the device.
Search IP-Addresses via router and Mi Home app
Find it. IP-The easiest way to address is through your router's interface (DHCP Client List) and find the device by name. Usually Xiaomi vacuum cleaners are called miio-followed by numerals, or have the model name, for example, roborock.vacuum.c1.
Alternatively, use the Mi Home app, go to the vacuum cleaner settings, select About device or Wi-Fi settings, and it often displays the current one. IP-However, if you change routers, the address may have changed, so checking through the router is more reliable.
For a stable operation of a smart home, it is highly desirable to reserve this address. In the router settings, find the option "Static". DHCP» Or "Address Reservation" and tie it down. MAC-vacuum-cleaner address to a specific IP. This will save you the need to update your configuration after every power outage.
What to do if the IP has changed?
Typical errors and troubleshooting
One of the most common problems is the error "Token invalid" or "Device offline." This often happens if the vacuum cleaner reconnects to the network and changes IP, and the configuration is left with the old address.
Users also face a timeout problem when questioning the device, which may indicate that the vacuum cleaner is in sleep mode and does not respond to requests, or the Wi-Fi signal is too weak at the base installation point. -70 dBm.
⚠️ Warning: Do not attempt to obtain a token while the vacuum cleaner is in the process of cleaning or updating the firmware. at these times, the device may not be available for external requests or block new connections.
If you use Docker to run Home Assistant, make sure the container is running in network: host mode. Without this mode, broadcast requests for device detection may not travel across the boundaries of the container network, and the system simply won't "see" your vacuum.