Integration of the robot vacuum cleaner Xiaomi in Home Assistant: from token to automation

The Xiaomi and Roborock 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, connecting to the home is a must-have. HA allows you to create complex automation: cleaning according to a schedule taking into account motion sensors, zoning the rooms by time of day or even synchronization with other devices (for example, starting a vacuum cleaner after closing windows).

However, the integration process often raises questions: where to get a token for authorization, how to set up a map display in real time, or why the vacuum cleaner does not respond to commands through a computer. HA? This article covers all the steps from device preparation to fine-tuning, including solving typical problems.We will look at both the official methods through Xiaomi Miio, and alternative ways for older models where standard integration does not work.

1.Preparation: compatibility check and requirements

Before you start setting up, make sure your vacuum cleaner model is supported by Home Assistant. Xiaomi/Roborock release 2018 Compatible years, but there are exceptions:

  • βœ… Supported by: Roborock S5/S6/S7/S8, Xiaomi Mi Robot Vacuum 1S/2/Pro, Dreame D9/F9 newer.
  • ⚠️ Limited support: Xiaomi Mi Robot Vacuum 1 (first generation) – requires manual token acquisition.
  • ❌ Not supported: some OEM-models for the Chinese market (for example, Viomi without global firmware).

Also check the version of the vacuum cleaner firmware: for correct operation with the HA It is recommended to update it to the latest through the official Mi Home or Roborock app. S5) may not support API-team.

Model vacuum cleanerMinimum firmware versionIs a handheld token required?Support for maps in HA
Roborock S74.1.0No (automatic)Yes.
Xiaomi Mi Robot Vacuum 2 Pro3.3.9Yes.Partially.
Dreame D10 Plus1.5.4No.Yes.
Roborock S5 Max3.6.6No.Yes.

Requirements for Home Assistant:

  • ⚑ Version. HA 2023.12 or later (for full Miio Protocol support) v2).
  • 🌐 Stable connection of vacuum cleaner and server HA to one network (Wi-Fi 2.4 GHz).
  • πŸ”‘ Xiaomi account with tied vacuum cleaner (to automatically receive token).

⚠️ Note: If the vacuum cleaner is connected to the network via 5 GHz, transfer it to 2.4 GHz – many models do not support dual-band Wi-Fi when integrating with the network. HA.

2. Obtaining an authorization token

The token is a unique key that allows Home Assistant to send commands to the vacuum cleaner, and there are two ways to get it:

If your model supports automatic integration (see table above), follow the following steps:

  1. Install the official Mi Home app (or Roborock for the respective models).
  2. Log in to the account to which the vacuum cleaner is attached.
  3. In Home Assistant, go to Settings β†’ Devices and services β†’ Add integration β†’ Xiaomi Miio.
  4. Select the server region (China, Europe or Russia – depending on the version of the application).
  5. Enter the username and password from the Xiaomi account β€” HA automatically receive the token.

Advantage: it does not require manual manipulation of configuration files, disadvantage: if you change the password in the Xiaomi account, the token will reset, and the integration will have to be configured again.

Method 2: Manual token extraction (for older models)

If the automatic method does not work (for example, for Mi Robot Vacuum 1), use this method:

Install the Packet Capture (Android) app or HTTP Toolkit (PC)

Connect your phone/PC to the same network as the vacuum cleaner

Log in to Mi Home and start capturing traffic

Find a request to api.io.mi.com with the token option

-->

Detailed instructions:

  1. Download MiHome Token Extractor (for Android) or use it Fiddler/Wireshark PC-only.
  2. Start capturing traffic and open the Mi Home app.
  3. Find in the logs a request to the domain api.io.mi.com with the method POST and the "token" parameter": "...".
  4. Copy the value of the token (32 characters) – this is your key.

⚠️ Warning: Don't share the token with third parties! it gives full access to vacuum control. If the token has fallen into the wrong hands, dump it through the Mi Home app (lodge and log in again).

Automatically through HA

Manually by Capturing Traffic

I haven't tried it yet.

Another option-->

3. Set up integration in Home Assistant

After receiving the token, add the vacuum cleaner to HA:

  1. Open configuration.yaml (via File Editor or en route) /config/configuration.yaml).
  2. Add the following block (replace). IP_ADRES and YOUR TOKEN for real values: vacuum: - platform: xiaomi_miio host: IP_Address token: Your Token Name: "Robot vacuum cleaner Xiaomi"
  3. Save the file and reboot the Home Assistant.

If you use YAML-Mod, after restarting, the vacuum cleaner will appear in the Devices section. UI-Mod (without editing configuration.yaml):

  1. Go to Settings β†’ Devices and Services β†’ Add Integration.
  2. Choose Xiaomi Miio.
  3. Enter. IP-vacuum cleaner address and token, then click Send.

Connection Check: After adding, open the Developers tab β†’ Conditions and find the essence vacuum.xiaomi_vacuum. If it displays status (idle, cleaning, etc.), the integration has been successful.

πŸ’‘

If the vacuum cleaner doesn't respond to commands, check if your router blocks local traffic between devices. IP-vacuum address except for firewall.

4. Advanced settings: maps, zones and automation

Basic integration allows you to send commands (start, pause, return_to_base). To unlock your full potential, set up:

Displaying the map in real time

For models with mapping support (Roborock) S6/S7, Dreame D10 etc.):

  1. Install the Xiaomi Miio Map expansion through HACS (Home Assistant Community Store).
  2. Add to configuration.yaml: xiaomi_miio_map: vacuums: - host: IP_ADRES TOKEN: Your Token name: "xiaomi_vacuum" draw: ['all'] attributes: - calibration_points
  3. Reboot. HA and add a map to the dashboard via the Picture Entity widget, specifying the essence camera.xiaomi_vacuum_map.

Maps are updated with a delay 2-5 If the card is not displayed, check if the option "Save card" is enabled in the vacuum cleaner settings (via the official app).

Set-up of cleaning areas

To start cleaning in specific areas (e.g., only in the kitchen):

  1. In the official Mi Home or Roborock app, create virtual walls and zones.
  2. Export zone coordinates through Developer Tools β†’ Services in HA, call-up xiaomi_miio.vacuum_clean_zone.
  3. Save the coordinates to script or automation. Example of a zone cleaning command: service: xiaomi_miio.vacuum_clean_zone data: entity_id: vacuum.xiaomi_vacuum zone: [[25000, 25000, 30000, 30000]] # Coordinators: [x1, y1, x2, y2] repeats: 2
How do you get the coordinates of the zones?
1. Start cleaning the entire area through HA. 2. Open Developer Tools β†’ States and find the attribute cleaned_area vacuum-driven. 3. Zone coordinates are specified in millimeters from the base station (0,0). For accuracy, use the Valetudo application (alternative firmware) or roulette in the official application.

Examples of automation

  • πŸ•’ Scheduled cleaning: Start vacuum cleaner at 10:00 if no one is home (presence sensor).
  • πŸšͺ Synchronization with windows: when closing the last window (sensor) binary_sensor.window) clean-up.
  • πŸ• Pets mode: if the motion sensor in the corridor works more often 5 times per hour, the vacuum cleaner removes only the area near the bowl.

5. Solving typical problems

Even with the right setup, you can get errors, and here are the most common ways to fix them:

Problem.Possible causeDecision
Vacuum cleaner not responding to commandsWrong. IP tokenCheck it out. IP via router, regenerate token
Map not updatedOutdated vacuum cleaner firmwareUpdate the firmware through the official application
Unable to connect errorLocking ports with firewallOpen ports 54321 and 80 for local IP vacuumer
Commands are executed with a delayNetwork or server congestion HAReduce the number of surveys in configuration.yaml (scan_interval: 30)

If the vacuum cleaner is disconnected from Wi-Fi:

  • Check the strength of the router signal at the docking station location (should be β‰₯ -60 dBm).
  • Set up static. IP for the router vacuum cleaner (by MAC-address).
  • Turn off the energy-saving Wi-Fi mode on the vacuum cleaner (some firmware has it).

⚠️ Note: If after updating the vacuum cleaner firmware, it stopped responding to commands through HA, Reset the token and reset the integration. The manufacturer sometimes changes the authorization protocol.

6. Alternative methods of integration

If the Xiaomi Miio standard integration doesn’t work, consider alternatives:

1.Valetudo firmware

Valetudo is an open alternative to standard firmware that provides full local control over the vacuum cleaner without the Xiaomi cloud.

Advantages:

  • πŸ”’ No dependence on Xiaomi servers (works even when the Internet is disconnected).
  • πŸ—ΊοΈ Support for extended maps and zones.
  • πŸ› οΈ Possibility of installing custom scripts.

Disadvantages: requires manual stitching (risk of losing warranty), not all models are supported.

Installation instructions:

  1. Download Valetudo from the official website.
  2. Connect to the vacuum cleaner SSH (The instructions for each model are different).
  3. Download the firmware via scp or web interface.
  4. Set up integration with HA through REST API or MQTT.

2. Integration through MQTT

If your vacuum cleaner supports MQTT (For example, through Valetudo or custom firmware, set up messaging:

  1. Install. MQTT-broker (e.g. Mosquitto) in HA.
  2. In the vacuum cleaner configuration, specify the broker’s address and topics for teams (vacuum/command) and (vacuum/state).
  3. Create automation in HA, posting.

Example of a team to start cleaning through MQTT:

topic: vacuum/command


payload: '{"command": "start"}'

3. Cloud Bridge (for remote access)

If you need to control the vacuum cleaner from the outside of the home network:

  • Configure Nabu Casa Cloud or DuckDNS for remote access HA.
  • Use a Telegram bot or Google Assistant to send commands.

πŸ’‘

Alternative methods are suitable for power users. If you're a beginner, start with the standard Xiaomi Miio integration.

7. Optimization and Operational Tips

To make the vacuum cleaner work more efficiently:

  • πŸ“‘ Docking station: install it in the center of the apartment, at least 0.5 m from the walls and furniture. Avoid places with direct sunlight (the sensor may overheat).
  • πŸ”‹ Battery care: If the vacuum cleaner is not used for more than a week, remove the battery or store it with a charge 40-60%.
  • 🧹 Clean sensors: wipe optical sensors every month (especially on models with a high-performance sensor). LDS-lidar) cotton swab soaked in alcohol.
  • πŸ“± Updates HA: After updating Home Assistant, check the compatibility of Xiaomi Miio integration in the official repository.

Automation tip: To reduce vacuum cleaner wear, set up the condition to start cleaning only at the battery level > 50 percent, an example of an automation condition:

condition:


- condition: numeric_state




entity_id: sensor.xiaomi_vacuum_battery




above: 50

For models with support for wet cleaning (Roborock) S7, Dreame W10):

  • Use distilled water to extend the life of the pump.
  • After each cleaning, wash the water tank and wipe the fabric nozzle.
  • In automation, add delay: "00:02:00" between dry and wet cleaning - this will reduce the load on the engine.

FAQ: Frequent questions

Can you connect Xiaomi vacuum cleaner to Home Assistant without a token?
No, the token is mandatory for authorization, but for some models (e.g. Roborock). S5 with Valetudo firmware, you can use local API without a cloud token, in which case the integration is configured via RESTful Command or MQTT.
Why doesn’t the vacuum cleaner return to the base after cleaning?
The reasons may be as follows: the dock is in the β€œblind zone” (check the map in the β€œblind zone”). HA). Low battery charge (less than) 20%) β€” The vacuum cleaner tries to get to the base, but it doesn't have time. Mechanical lock (stuck under the furniture). Solution: manually return the vacuum cleaner to the base and restart cleaning. If the problem recurs, check the collision sensors (sensor.xiaomi_vacuum_collision into HA).
How to reset a token if I forgot it or it stopped working?
You can reset the token in two ways: via the official application: Open Mi Home or Roborock. Go to the vacuum cleaner settings β†’ "Untie the device. Re-attach the vacuum cleaner to your account, and a new token will be generated. Through vacuum cleaner reset to factory settings: Press Home and Power buttons for 5 seconds. After the vacuum cleaner is reset, configure the vacuum cleaner as a new device. After the token is reset, update it to Home Assistant configuration.
Can you control the vacuum cleaner through Home Assistant if it is connected to another network (for example, in the country)?
Yes, but it will require: Set up remote access to Home Assistant (Nabu Casa Cloud, Tailscale or port diffuser) to make sure the vacuum cleaner is connected to the Internet and its use. IP-The address does not change (set up static). IP - Use the router. MQTT or REST API You can send commands through the cloud, and you can take into account that this approach can delay you to the cloud. 2-3 Seconds due to cloud routing.
What models? Xiaomi/Roborock It is best integrated with Home Assistant?
According to user reviews and tests, the best models for integration: Roborock S7 Pro Ultra - full support for maps, zones and wet cleaning.Dreame D10 Plus - stable. API, Xiaomi Mi Robot Vacuum-Mop 2 Pro - optimal price/functional ratio. S5 Max, but it doesn't have Miio Protocol support v2, What can cause lags when managing through HA.