How to Program a Xiaomi Robot Vacuum: From Basic Settings to Advanced Automation

Robot vacuum cleaners Xiaomi long ceased to be just β€œsmart mops” – today it is a full-fledged assistant with open API, However, most users are limited to basic features from the Mi Home app, without even realizing that their Mi Robot Vacuum or Xiaomi Robot Vacuum-Mop 2 Pro can be programmed to perform complex tasks: From humidity-based cleaning to integration with Home Assistant-based smart home.

In this article, we will analyze all the ways of programming Xiaomi robot vacuum cleaners – from simple settings in the official application to work with tokens. API, creation of custom scripts and firmware alternative software. Particular attention will be paid to models with LDS-Lidar (e.g. Mi Robot Vacuum-Mop P or S7 MaxV), because they support the most flexible scenarios, and if you've never done a computer programming project, don't worry: the first sections are for beginners, and we'll take the hard parts through concrete examples with step-by-step instructions.

Warning: the depth of the setup depends on the model of your robot. 1S) have limited capabilities, while flagship models like Xiaomi Robot Vacuum-Mop 2 Ultra allow you to control even the mop pressure and the speed of rotation of the brushes through the API. In order not to get confused, at the end of the article we will give a comparative table of possibilities by model.

Basic settings in the Mi Home app: what can be programmed without technical knowledge

The official Mi Home app (or Xiaomi Home for European regions) is the easiest way to program a robot vacuum cleaner, and it offers basic features that cover 80% of users’ needs:

  • πŸ“… Cleaning schedule – setting up automatic cleaning by day of the week and time.
  • πŸ—ΊοΈ Zone cleaning – the selection of specific rooms or zones on the map (available for models with lidar).
  • πŸ”„ Modes of operation – switching between Quiet, Balanced, Turbo and Maximum power.
  • 🚫 No-go zones – designating areas that the robot should ignore (such as baby mats or food bowls).
  • πŸ”‹ Charging control – adjusting the battery level to start cleaning.

To set up a schedule, open the Mi Home app, select your robot vacuum cleaner, and go to the Schedule section, where you can create a few rules, like:

  • Cleaning on weekdays at 9:00 (when everyone left for work).
  • Wet cleaning on Saturdays at 12:00.
  • Quick cleaning of the kitchen daily at 18:00 before the arrival of the household.

⚠️ Note: If your Xiaomi robot vacuum cleaner does not save the card after turning it off, check the Saving the card settings in the device menu. In some firmware, this option is disabled by default to save energy.

For models with multi-room map support (for example, S7 MaxV) is available to clean rooms, so you can specify which rooms to clean at a particular time, for example, the bedroom is only in the morning, and the corridor is daily:

  1. Open the map in the Mi Home app.
  2. Click on the Edit icon (pencil).
  3. Set aside the necessary rooms and keep the area.
  4. In the schedule, select the created area instead of the β€œAll Square”.
πŸ“Š What model of Xiaomi robot vacuum cleaner you use?
Mi Robot Vacuum 1S
Mi Robot Vacuum-Mop P
Xiaomi Robot Vacuum-Mop 2 Pro
S7 MaxV
Another model

2. Advanced scenarios in Mi Home: automation by triggers

Few people know, but Mi Home has a built-in automation constructor that allows you to create chains of action based on triggers, for example, a robot can start cleaning when:

  • 🏠 You are leaving home (by geolocation of the smartphone).
  • 🌑️ Air dust levels are higher than normal (reported by Xiaomi Air Purifier or Mi Air Quality Monitor).
  • πŸ•’ It's been N hours since the last cleaning.
  • πŸ”‹ The battery charge of the robot reached 100%.

To create this scenario:

  1. In Mi Home go to the Profile section β†’ Smart scripts β†’ Add a script.
  2. Select If... and specify a trigger (e.g., Geolocation) β†’ Left home).
  3. In the To block, add the action Start cleaning for your robot vacuum cleaner.
  4. Save the script and turn it on.

More interesting examples:

  • πŸšͺ Cleaning after opening the front door.If you have a Xiaomi Smart Door Lock, you can set up the cleaning of the parish area 10 minutes after opening the door.
  • πŸ’§ Wet cleaning at high humidity. Use data from the Mi Temperature and Humidity Sensor: if the humidity is above 60%, the robot washes the floors.
  • πŸ• Cleaning after feeding your pet.If you have a Xiaomi Pet Feeder automatic feeder, launch the robot 30 minutes after feeding to remove the crumbled food.

⚠️ Attention: Geolocation scenarios put a lot of stress on your smartphone battery. If the robot is not working smoothly, check the energy saving settings for the Mi Home app (allow background work).

πŸ’‘

If your region does not have the Smart Scenarios feature in Mi Home, try changing the region to China in the app settings. β†’ Settings β†’ Region and select Mainland China. After changing region, you may need to re-add devices.

3.Working with API Xiaomi: How to get a token and control a robot HTTP-request

For those who are not able to get a home, there is an informal API Xiaomi. It can send direct commands to the robot through the HTTP-Integrate it with Home Assistant, Node-RED, or even write your own scripts in Python.

There are several ways to extract the token:

  1. Through the Mi Home app, install a modified version of Mi Home with token output. Log in and find your robot vacuum cleaner on the device list. The token will show up in the device information.
  2. Through MITM-proxies iOS/Android). Set up traffic interception via Fiddler or Charles Proxy. In Mi Home, perform any action with the robot (for example, start cleaning). In the proxy logs, find a request to api.io.mi.com - the token will be in the deviceId setting.

miio-cli

(for PCs).

npm install -g miio-cli


miio discover --handshake

The script will display a list of devices in your network with tokens.

After receiving the token, you can send commands to the robot through HTTP. Example of query to run cleaning in Python:

import requests



token = "YOUR_DEVICE_TOKEN" # Replace with your token




did = "YOUR_DEVICE_ID" # ID devices (can be found in Mi Home)




ip = "192.168.1.100" # Local IP robot





url = f"http://{ip}/miIO.info"




headers = {"Content-Type": "application/json"}




data = {




"id": 1,




"method": "miIO.info",




"params": []




}





response = requests.post(url, json=data, headers=headers)




print(response.json())




Starting the cleanup



url = f"http://{ip}/miIO.info"




data = {




"id": 2,




"method": "app_start",




"params": []




}





response = requests.post(url, json=data, headers=headers)

A full list of supported commands for Xiaomi robot vacuum cleaners can be found in the Home Assistant documentation.

  • app_start β€” clean up.
  • app_pause β€” lay off.
  • app_zoned_clean β€” Cleaning in the specified area (coordinates required).
  • app_goto_target β€” send the robot to a specific point on the map.

⚠️ Note: Xiaomi device tokens may change after updating the firmware or resetting settings. If the commands stop working, repeat the token extraction procedure.

What happens if someone recognizes your device token?
If the token falls into the wrong hands, an attacker will be able to control your robot vacuum cleaner through a local network (for example, run cleaning at night or send it to restricted areas). To protect yourself: 1. Do not publish the token in open repositories (for example, on GitHub). 2. Use a local area network instead of a cloud (send commands to the cloud) IP 3. Change the token periodically by resetting the robot settings in Mi Home (Device Settings) β†’ General. β†’ Reset).

Integration with Home Assistant: Full control of the robot

Home Assistant is an open platform for smart homes that allows you to combine devices from different manufacturers into a single system.

  • πŸ“Š Visualize a real-time cleaning map.
  • πŸ€– Create complex automations with data from other sensors.
  • πŸ“± Control the robot through voice assistants (Alice, Google Assistant, Siri).
  • πŸ”„ Synchronize cleaning with other devices (for example, turn off the robot when the vacuum cleaner is turned on).

To connect the Xiaomi robot vacuum cleaner to the Home Assistant:

  1. Install Home Assistant on Raspberry Pi, NAS or PC.
  2. In the configuration file configuration.yaml add integration xiaomi_miio: vacuum: - platform: xiaomi_miio host: 192.168.1.100 # IP token: YOUR_DEVICE_TOKEN
  3. Reboot Home Assistant.
  4. There will be a new entity in the interface vacuum.xiaomi_vacuum, which can be controlled through panels or automation.

An example of automation in Home Assistant that starts cleaning when everyone is gone and the humidity is above 50%:

automation:


- alias: "Cleaning in the absence of a house and high humidity"




trigger:




- platform: state




entity_id: group.family




to: "not_home"




for: "00:30:00" # 30 minutes delay




condition:




- condition: numeric_state




entity_id: sensor.humidity




above: 50




action:




- service: vacuum.start




entity_id: vacuum.xiaomi_vacuum




- service: notify.telegram




data:




message: "The robot has started cleaning: humidity {{ states('sensor.humidity') }}%."

Important: Xiaomi’s firmware robot vacuum cleaners after 2023 may require additional cloud authentication, in which case the Home Assistant integration will require a component. miio2 cloud-token.

Get a device token|Install Home Assistant on Raspberry Pi/NAS|Add integration xiaomi_miio in configuration.yaml|Check the connection in the Developer Tools menu β†’ States|Create test automation-->

5. Alternative firmware: Valetudo and open features

If you don't like the limitations of Xiaomi's standard firmware, you can install alternative software like Valetudo, an open source project that provides:

  • 🌐 Local management without depending on the cloud Xiaomi.
  • πŸ—ΊοΈ Advanced mapping tools (zones editing, manual control).
  • πŸ”§ Support for custom scripts in JavaScript.
  • πŸ“‘ Integration with MQTT smart-home.

Valetudo supports the following Xiaomi robot vacuum cleaner models:

ModelValetudo supportWhether rooting is requiredFeatures
Mi Robot Vacuum 1Sβœ… Yes.βœ… Yes.Limited functionality due to weak iron
Mi Robot Vacuum-Mop Pβœ… Yes.βœ… Yes.Full support LDS-lidar
Xiaomi Robot Vacuum-Mop 2 Proβœ… Yes.❌ No (installation through) SSH)Support for multicards and automatic room recognition
S7 MaxVβœ… Yes.❌ No.Support 3D-cameras and improved navigation

The Valetudo installation process depends on the model, and most devices will require:

  1. Get root access to the robot (for example, through a vulnerability in the firmware or a special script).
  2. Connect to the robot on SSH (usually at root@192.168.1.100, password blank 1234567890).
  3. Launch Valetudo Installer: wget -O - https://raw.githubusercontent.com/Hypfer/Valetudo/master/scripts/install.sh | bash
  4. After installation, the Valetudo web interface will be available at the address http://[IP_robot]:80.

In the Valetudo interface, you can:

  • πŸ–₯️ Control the robot via a web browser (including manual control from a joystick).
  • πŸ“ Edit the map, add virtual walls and cleaning areas.
  • πŸ“Š Check the cleaning statistics and errors.
  • πŸ”§ Configure user commands through JavaScript.

⚠️ Warning: Installing alternative firmware may result in loss of warranty and unstable operation of the robot. Before firmware, back up the original firmware via the dd if command=/dev/mtdblock0 of=/tmp/full_backup.bin.

πŸ’‘

Valetudo is the only way to gain full control of Xiaomi’s robot vacuum cleaner without depending on cloud servers. SSH, rooting, backup).

6. Programming through third-party applications: AlternativeApp and others

If you work with API And it seems too complicated with firmware, you can use third-party applications that extend the functionality of Mi Home:

  • πŸ“± AlternativeApp for Xiaomi Vacuum (Android) – allows you to customize your schedule to the minute, create complex cleaning areas and operate a robot without the Internet. 1/1S, Mi Robot Vacuum-Mop P, S5/S6. Requires a device token (extracted in the same way as for the device) API).
  • 🌍 Vacuum Map Viewer - displays a real-time map of cleaning with manual control. Works through the Xiaomi cloud (token needed). Supports export of the card in.svg format.
  • πŸ€– Robot Vacuum Controller (iOS) is an alternative to Mi Home with advanced zone and schedule settings. There is a "Follow Me" feature (the robot follows you around the house). Supports voice control via Siri.

Example of AlternativeApp configuration:

  1. Download. APK from GitHub and install on Android.
  2. Add a robot vacuum cleaner by introducing it IP, token and Device ID.
  3. In the Advanced menu, configure Custom commands to create your own commands (for example, cleaning only around the perimeter. DND Mode - set "do not disturb" on schedule.

Advantages of third-party applications:

  • βœ… No dependency on Xiaomi servers (works locally).
  • βœ… More flexibility in setting up zones and schedules.
  • βœ… Support for older models that are no longer updated.

Disadvantages:

  • ❌ Manual adjustment (tokens) required, IP).
  • ❌ No official support (bugs are possible).

πŸ’‘

If the robot vacuum cleaner does not connect to AlternativeApp, make sure that there is no local request blocking on your network (for example, some routers block traffic between devices on the local network).

7. Comparison of programming capabilities on Xiaomi models

Not all Xiaomi robot vacuum cleaners support advanced features, and below is a comparison of popular models by customization capabilities:

ModelLDS-LidarValetudo supportAPI-teamZone cleaningMulticardIntegration with Home Assistant
Mi Robot Vacuum 1S❌ No.βœ… Yes (with rooting)Basic❌ No.❌ No.βœ… Yes.
Mi Robot Vacuum-Mop Pβœ… Yes.βœ… Yes.Extended.βœ… Yes.❌ No.βœ… Yes.
Xiaomi Robot Vacuum-Mop 2 Proβœ… Yes (precision)βœ… Yes.Complete.βœ… Yes.βœ… Yes, up to 3 cards)βœ… Yes.
S7 MaxVβœ… Yes. + 3D-cameraβœ… Yes.Complete. + cameraβœ… Yes.βœ… Yes, up to 4 cards)βœ… Yes.
Xiaomi Robot Vacuum-Mop 2 Ultraβœ… Yes (double lidar)❌ No (bye)Complete. + base-stationβœ… Yes.βœ… Yes, up to 5 cards)βœ… Yes.

If your model doesn't support the right features, consider upgrading. 1S Xiaomi Robot Vacuum-Mop 2 Pro will open access:

  • πŸ—ΊοΈ Exact map with several floors saved.
  • 🚿 Automatic change of modes (vacuum cleaner/mop).
  • πŸ”„ Integration with other smart home devices.

8. Frequent errors and their solution

When programming Xiaomi robot vacuum cleaners, users face typical problems.

  • πŸ”Œ The robot doesn't respond to API-Check that the teams IP-The robot's address has not changed (use static). IP Make sure the token is up-to-date (it can reset after the firmware update) and check that the robot and the device that sends the commands are on the same network.
  • πŸ—ΊοΈ The card is not saved after switching off. Enable the option Save the card in the robot settings in Mi Home. For models without lidar, the card is not saved fundamentally (they use a random cleaning algorithm).
  • πŸ”„ The robot doesn't return to base. Make sure the base is flat and not blocked by obstacles. Update the robot's firmware (older versions had navigation bugs). If the robot is stuck, use the command. app_charge through API, to force him to charge.
  • πŸ“± Mi Home doesn't see the robot. Reboot the robot (press the power button for 10 seconds). Reset the robot's settings to factory (Settings) β†’ General. β†’ Check that the robot is connected to a 2.4 GHz network (not 5 GHz).

If the robot produces a code error (e.g., Error 10 or Error 12), you can decrypt it in the Home Assistant documentation.

  • Error 3 - the robot is stuck.
  • Error 5 is a sidebrush problem.
  • Error 9 is a low battery charge.

⚠️ Note: If after Valetudo firmware the robot stopped turning on, check the integrity of the file system through the SSH. A common reason is a lack of space in the section /tmp. Solution: Connect to SSH and do df. -h, check out the vacant space.

FAQ: Answers to Frequent Questions

Can you program a Xiaomi robot vacuum cleaner without the internet?