Xiaomiβs robot vacuum cleaners have long been an integral part of the smart home ecosystem, but their true potential is only revealed when integrated with Home Assistant. Unlike the standard Mi Home app, where functionality is limited to basic commands, Home Assistant allows you to create complex automations: running a scheduled cleaning service based on your location, binding to humidity sensors, or even voice control through Alice or Google Assistant.
However, the connection process often raises questions: where to get a token, why the vacuum cleaner does not appear in the interface, how to circumvent regional restrictions Mi Home? In this guide, weβll break down all the current integration methods (including bypassing cloud constraints through a local protocol), analyze common bugs, and show you how to make the most of your Mi Robot Vacuum, Viomi, or Dreame in the Home Assistant ecosystem. We will pay special attention to models with support LDS-Laser (e.g. Xiaomi Mi Robot Vacuum-Mop 2 Pro) where advanced zoning and mapping features are available.
1.Preparation: What will be needed for integration
Before you start setting up, make sure you have everything you need. The minimum requirements depend on the method of connection you choose (cloud or on-premises), but the basic set is the same for all options:
- π± Smartphone with Mi Home app installed (version no lower than 6.0.100) Important: account must be tied to the same region as the vacuum cleaner (usually Mainland China, Europe or Russia).
- π₯οΈ Home Assistant Work Server (version 2023.12 or later) will suit both installation on a Raspberry Pi and container in Docker.
- π Token devices β a unique identifier for accessing API. It can be obtained in several ways (we will discuss below).
- π A stable Internet connection (for cloud method) or a local area network (for direct connection).
If you use a Xiaomi vacuum cleaner older 2019 Years (e.g. Mi Robot Vacuum) 1S), Check MiIO support in the official Home Assistant documentation. Some budget models (e.g. Viomi) V2) You may need to manually adjust. device_id.
β οΈ Note: Dreame vacuum cleaners (e.g. Dreame) D9) They use a separate DreameVacuum protocol, and they need different integration β dreame_vacuum Home Assistant.
To simplify the process, we recommend in advance:
- π Update the vacuum cleaner to the latest version through Mi Home.
- π‘ Connect the vacuum cleaner and Home Assistant server to the same local network (preferably over 5 GHz Wi-Fi for stability).
- π Write it down. MAC-vacuum cleaner address (can be found in router settings or in Mi Home in Device section) β Settings β About the device).
2. Obtaining a device token: 3 working methods
Token is the key to access API There are several ways to get it, varying in complexity and reliability, and let's look at it from the simplest to the most technical.
Method 1: Through the Mi Home app (for beginners)
The easiest way, but it doesn't work for all regions, is if your account is linked to Mainland China servers:
- Open Mi Home and go to the vacuum cleaner settings.
- Click on three dots in the upper right corner β About the programme.
- Tap 5-7 times on the firmware version until the Debug menu appears.
- Select Get Token β the system will generate the token and copy it to the clipboard.
Method 2: Through Python script (universally)
If the first method didn't work, use miio-cli, which is suitable for all regions, but requires minimal command line knowledge.
pip install python-miio
miio discover --handshake 0
miio inspect --ip <IP_ vacuum cleaner> --token < your token account Mi>Where <IP_vacuumer> β local IP-address of the device, and <Your Token Account Mi> You can get it through this repository (instruction in English).
Method 3: Through HTTP-interception (for experienced)
An alternative method is to intercept the token when logging into Mi Home via Fiddler or Charles Proxy.
How to intercept a token through Charles Proxy
| Method | Difficulty | Works for regions | PC required |
|---|---|---|---|
| Through Mi Home (Debug) | β | Only China. | No. |
| Python-script mio-cli | ββ | All right. | Yes. |
| HTTP-interception | βββ | All right. | Yes. |
β οΈ Note: Tokens obtained through Mi Home Debug can be reset after a firmware update. Use the miio-cli method for reliability.
3. Set up integration in Home Assistant
Once the token is received, we move on to adding a vacuum cleaner to Home Assistant. There are two main approaches: over a cloud bridge (easier, but depends on Xiaomi servers) and through a local connection (more reliable, but requires additional settings).
Method 1: Cloud integration (via Mi Home)
If you donβt want to mess around with the local network, use the official Xiaomi Miio integration:
- In Home Assistant, go to Settings β Devices and Services β Add Integration.
- Type in the Xiaomi Miio search and select it.
- Indicate. IP-vacuum cleaner address, token and select region (e.g. cn for China).
- Press Submit β the device will appear in the list.
Method 2: Local Connection (recommended)
For stability, it is better to use the local MiIO protocol, which will eliminate dependence on the Xiaomi cloud and speed up the response to commands.
- Add the following code to the configuration.yaml file: vacuum: - platform: xiaomi_miio host:!secret vacuum_ip token:!secret vacuum_token name: "Xiaomi Vacuum" model: "roborock.vacuum.a10" # Please indicate your model (list below)
- Add secrets.yaml to the file: vacuum_ip: "192.168.1.100" # Replace it with IP your vacuum cleaner vacuum_token: "your token here"
- Reboot Home Assistant.
List of popular models for the model parameter:
- roborock.vacuum.s5 β Xiaomi Mi Robot Vacuum-Mop
- viomi.vacuum.v7 β Viomi V7
- dreame.vacuum.p2008 β Dreame D9
- rockrobo.vacuum.v1 β Mi Robot Vacuum 1S
βοΈ Checking for successful integration
4. Advanced settings: maps, zones and automation
Basic integration allows you to just start and stop cleaning, but the real magic starts when you plug in maps of the space and set up zonal cleaning.
Connecting cards (for models with) LDS)
Laser scanner models (Mi Robot Vacuum-Mop 2 Pro, Dreame) Z10 Pro) support map display in Home Assistant:
- Install the Xiaomi Miio Map Extractor HACS.
- Add to configuration.yaml: camera: - platform: xiaomi_miio_map host:!secret vacuum_ip token:!secret vacuum_token name: "Vacuum Map" draw: ["charger", "path", "robot", "zones"] attributes: - calibrated - cleaning
- After the reboot, a map with the current location of the vacuum cleaner will appear in the Media section.
Configuring zones and virtual walls
To clean only certain rooms, use zoned cleanup. Example of a kitchen cleaning command (coordinates taken from the map):
service: vacuum.send_command
target:
entity_id: vacuum.xiaomi_vacuum
data:
command: app_zoned_clean
params: [[25000, 25000, 30000, 30000, 2]] # [x1, y1, x2, y2, repetitions]To create virtual walls (for example, so that the vacuum cleaner does not come into the nursery), use the parameter. app_segment_clean zone-identified.
π‘
If the map is not displayed, check that the vacuum cleaner is on base and not in cleaning mode. Also make sure that the Mi Home settings enable the Send Card Data setting (in some firmware it is disabled by default).
5. Typical errors and their solutions
Even if you follow the instructions accurately, you can have problems, and we'll look at some of the most common mistakes and how to fix them.
| Mistake. | Reason. | Decision |
|---|---|---|
| Failed to connect when adding a device | Wrong. IP token | Check it out. IP via router, regenerate token |
| Vacuum doesn't respond to commands | Xiaomi Cloud Servers are Unavailable | Go to local connection |
| Unsupported device | Incorrectly specified model in configuration.yaml | Check the list of supported models in the documentation |
| Map not updated | The vacuum cleaner is not online or the firmware is outdated | Update your firmware, check your Wi-Fi connection |
If you see a Device error not found, but IP And the token is right, try it:
- π Reboot the vacuum cleaner (hold the power button for 5 seconds).
- π‘ Reconnect it to Wi-Fi.
- π§ Temporarily disable the firewall on the router.
β οΈ Note: Xiaomi vacuum cleaners with firmware more recent than 2023 can block local connections if the Mi Home does not turn on developer mode. β Settings β Developer mode.
Automation: Examples of Useful Scenarios
Now that the vacuum cleaner is connected, you can create automations that will save you time. Here are some ready-made examples for automations.yaml:
Automatic cleaning on schedule
Start cleaning every day at 10:00 am if no one is home:
alias: "Schedule cleaning"
trigger:
- platform: time
at: "10:00:00"
condition:
- condition: state
entity_id: person.your_name
state: "not_home"
action:
- service: vacuum.start
target:
entity_id: vacuum.xiaomi_vacuumCleaning at high concentration of dust
If you have an air quality sensor (such as Xiaomi Air Purifier), you can run the vacuum cleaner when you exceed it. PM2.5:
alias: "Prevention of pollution"
trigger:
- platform: numeric_state
entity_id: sensor.air_quality_pm25
above: 50
action:
- service: vacuum.start
target:
entity_id: vacuum.xiaomi_vacuum
- delay: "00:30:00" # Cleaning 30 minutes
- service: vacuum.return_to_base
target:
entity_id: vacuum.xiaomi_vacuumVoice control through Alice
To control the voice vacuum cleaner, integrate Home Assistant with Yandex Alice via Yandex Smart Home:
- In configuration.yaml add: yandex_smart_home: filter: include_entities: - vacuum.xiaomi_vacuum exclude_domains: - script
- In the Yandex app, add Home Assistant as a control device.
- Now you can say, "Alice, turn on the vacuum cleaner" or "Alice, put the vacuum back on base."
π‘
For reliable operation of automation always check the conditions, for example, do not start cleaning if the vacuum cleaner is already working or the charge level is below 20%.
7. Optimization and Operational Tips
To ensure that the vacuum cleaner works stably and lasts longer, follow these recommendations:
- π Charging: Do not keep the vacuum cleaner permanently on base. The optimal is to charge up to 80% and discharge up to 20% (this prolongs the life of the battery). In Home Assistant, you can set up automation that will turn the vacuum cleaner off the base after reaching 80%:
alias: "Charge limitation"
trigger:
- platform: numeric_state
entity_id: sensor.xiaomi_vacuum_battery
above: 80
action:
- service: vacuum.return_to_base
target:
entity_id: vacuum.xiaomi_vacuum- π‘ Wi-Fi: Xiaomi vacuum cleaners don't work well with 5GHz networks. If you have a dual-band router, tie the vacuum cleaner to the 2.4GHz network manually.
- πΊοΈ Maps: Periodically (every 1-2 months) reset the map in the vacuum cleaner settings and retrain the vacuum cleaner.
- π οΈ Maintenance: Clean sensors and brushes at least 1 time per week. clogged sensors lead to chaotic cleaning.
Critical feature of models with laser navigator (LDS): Do not use them in direct sunlight. The laser sensor can malfunction, and the vacuum cleaner will go blind".