Xiaomiβs smart scripts turn disparate devices into a single ecosystem that can automate routine tasks, from turning on lights on a schedule to complex chains of reactions to changing weather or your location. However, many users face the challenge of where to find ready-made scenarios, how to adapt them to their needs or create them from scratch? The official Mi Home app offers basic functionality, but not all the features are obvious there.
In this article, weβll look at 5 proven sources of smart scripts for Xiaomi, from hidden partitions in branded apps to third-party platforms and enthusiast communities, how to find ready-made solutions for popular tasks (such as imitation of presence or automatic ventilation), where to download custom templates, and how to safely test scenarios before implementation.
1. Official Mi Home app: hidden sections and ready-made templates
To start with, the most obvious is the Mi Home app (renamed Xiaomi Home in some regions), which has a built-in script library, but it's often overlooked.
- Open the application and go to the Profile tab β Smart home. β Automation.
- Press. + Add β Script.
- At the top of the screen, select the Template tab (it is easy to skip it, as the Empty script opens by default).
Here you'll find pre-configured scenarios for popular devices: Yeelight lamps, Mi Robot robot vacuum cleaners, motion sensors, etc. For example, the Night Mode pattern automatically turns off all the lamps and turns on the night light when you activate Do Not Disturb mode on your smartphone.
β οΈ Note: In the Russian and European versions of Mi Home, the number of templates may differ from the Chinese version. AI Speaker is only available to Chinese users.
If standard templates aren't enough, try combining devices manually, for example, you can create a script that:
- π‘οΈ Xiaomi Smartmi air humidifier turns on when Aqara sensor captures humidity below 40%.
- πͺ Sends a notification to your phone if the Mijia door sensor is triggered in your absence.
- βοΈ Closes the curtains of the Mi Smart Curtain when a certain light is reached (data from the Mi Light Sensor sensor).
For advanced users, Mi Home has a hidden Lab feature (not available in all regions) to activate it:
- Go to Profile. β Settings β Laboratory.
- Enable the option Developer Mode.
- Return to Automation and an additional tab will appear Advanced Scenarios with Extended Triggers (e.g. Weather Change or Geolocation).
2.The Mi Home app (Chinese version): advanced features
The Chinese version of Mi Home (available on the official website) offers 2-3 times more script templates than the global versions.
- π΅ Automatically turn on music on the Mi AI Speaker when you return home.
- π³ Notification of the readiness of the dish in the multicooker Mi Smart Rice Cooker.
- πΏ Control of water consumption through the Mi Water Meter.
To use the Chinese version:
- Download. APK-File from app.mi.com (select the version for the ).
- Install the application (permission to install from unknown sources may be required).
- Register a new account with a Chinese phone number (or use virtual number services).
β οΈ Note: Devices linked to a Chinese account will not appear in the global version of Mi Home, and some devices (such as Mi Robot Vacuum Mop 2 Pro) in Chinese firmware support features not available in international versions.
The Chinese version has a unique section (Smart Scenes) where you can find multi-stage scripts.
Trigger: The motion sensor in the hallway is triggered after 20:00
Condition: No one is home (by geolocation of smartphones)
Action:
1. Turn on the light in the hallway (Fury 50%)
2. Send a notification to the phone with a photo from the camera Mi Home Security Camera
3. If the movement has not stopped within 5 minutes, turn on the sirenFor convenience, you can use a real-time translator (e.g. Google Translate with overlaying through the camera), but be aware that some technical terms are not translated correctly.
π‘
If you already have devices linked to a global account, you can migrate them to the Chinese version through Device Migration in your profile settings, but this process is irreversible!
3. Home Assistant: Unlimited Script Options
If you donβt have enough of Mi Home, Home Assistant (HA) β It's an open platform that allows you to create scenarios of any complexity:
- π Integration of devices from different brands (not only Xiaomi).
- π Visual Automation Editor (Node-RED).
- π οΈ Support for Python scripts and YAML.
To connect Xiaomi devices to Home Assistant:
- Install Home Assistant on the right platform (Raspberry Pi, NAS, or even an old PC).
- Add Xiaomi Miio integration through Settings β Devices and Services β Add integration.
- Enter your Mi Home account token (it can be obtained via miot-spec.org).
Examples of scenarios that can be implemented in Home Assistant:
| Trigger. | Conditions | Action. | Example of devices |
|---|---|---|---|
| The window opening sensor is activated. | Temperature outside < 10Β°C | Send a notification: βClose the window to avoid freezing!β | Aqara Door Sensor, Mi Temperature Sensor |
| Level. COβ > 1000 ppm | Someone at home (geolocation) | Enable the supply ventilation and send a warning | Mi Air Quality Monitor, Smartmi Fan |
| Robot vacuum cleaner completes cleaning | Time between 20:00 and 22:00 | Turn on the lights in the corridor for 10 minutes | Mi Robot Vacuum, Yeelight |
For those who do not want to understand YAML, Home Assistant has a visual automation editor:
- Go to Settings. β Automation and scenes.
- Click Create Automation and select Visual Editor.
- Drag blocks of triggers, conditions, and actions (like a constructor).
β οΈ Note: When using Home Assistant, Xiaomi devices can consume more power, as the platform polls them more often than the native app. To save battery on sensors, set up the poll interval in the configuration file.
Install Home Assistant on Raspberry Pi 4 or NAS|Get Mi Home Token via miot-spec.org|Add integration Xiaomi Miio|Set up geolocation through the Home Assistant Companion app|Create a backup of the configuration-->
4.Communities and forums: where to download ready-made scenarios
If you don't want to reinvent the wheel, you can use the scripts from other users.
Official Xiaomi (Mi Community) Forum
On the c.mi.com forum, there is a Smart Home section where users share their settings.
- π Presence Scenario (Accidentally Turning on Lights and TV in Your Absence).
- π Automatic opening of the garage door when you enter the house (using geolocation and Mi Smart Door Lock).
- π± Auto-watering plants according to the soil moisture sensor.
To find relevant topics, use a keyword search:
- Smart scenario (for Chinese section)
- Mi Home automation.
- Home Assistant + Xiaomi.
GitHub: repositories with templates
There are dozens of repositories on GitHub with ready-made scripts for Xiaomi and Home Assistant.
- π com.xiaomi-miio β a collection of automations for Mi Home devices.
- π Home Assistant Official Documentation β Examples of Configurations.
- π xiaomi_vacuum_map_parser β Advanced scenarios for robot vacuum cleaners.
To use the template from GitHub:
- Download the file.yaml or.json.
- Import it to Home Assistant via Settings β Automation β Imports.
- Adapt device names (entity_id) your configuration.
Telegram chats and VKontakte groups
In Russian-speaking communities, localized scenarios are often shared.
- π Xiaomi Smart Home (Telegram).
- π Smart home Xiaomi (Vkontakte).
- π Home Assistant in Russian.
The advantage of chat rooms is that they can help you set up quickly, like asking for:
- π§ Help with the integration of Xiaomi and Google Assistant.
- π₯ Ready-made scenario for Mi Air Purifier control according to Mi Weather Station.
- π οΈ Tips for eliminating device connection errors.
β οΈ Warning: Before using someone else's scripts, check them on a test device. Some automations may contain errors (e.g., endless loops) that will overload the system.
How to check the security scenario?
5. Third-party platforms: IFTTT, Google Home, Apple HomeKit
If youβre not just using Xiaomi devices, you can connect them to other ecosystems through a new network. IFTTT or-app.
5.1. IFTTT (If This Then That)
IFTTT It allows you to create simple if-then scenarios, for example:
- π§ If an email with the theme βDeliveryβ came to the mail, turn on the Yeelight smart lamp in green.
- π If the Google Calendar has a Cleanup event, run the robot vacuum cleaner Mi Robot.
- π¦οΈ If weather forecaster predicts rain, close smart curtains Mi Smart Curtain.
To connect Xiaomi to IFTTT:
- Register at iftt.com.
- Activate Xiaomi Mi Home in My Services.
- Connect your Mi Home account.
- Create a new applet (Create) β If This Then That).
Limitations IFTTT:
- β Maximum 3 applets in the free version.
- β Delay of implementation up to 15 minutes.
- β No support for difficult conditions (only if - ifΒ»).
5.2 Google Home and Apple HomeKit
Xiaomi devices can be connected to Google Home or HomeKit via bridges (such as Home Assistant or HomeBridge).
- π£οΈ Manage devices with voice via Google Assistant or Siri.
- π Create scripts with other brands (e.g. Philips Hue) + Xiaomi).
- π± Use geolocation through Apple Home for automation.
To connect to HomeKit:
- Install HomeBridge on Raspberry Pi or NAS.
- Add the homebridge-mi-home plugin.
- Enter the token from Mi Home (similar to Home Assistant).
- Scan it. QR-code in the Apple Home app.
β οΈ Note: Not all Xiaomi devices are officially supported in HomeKit. for example, robot vacuum cleaners and some sensors may not work smoothly.
π‘
Third-party platforms (IFTTT, Google Home is easy to use for simple scripting, but has speed and flexibility limitations.
Advanced methods: API, scripts and firmware
If you need unique scenarios that are not in standard applications, you can use:
6.1. Mi Home Open API
Xiaomi offers open source API It's a device control tool:
- π Get data from sensors in real time.
- π§ Manage devices through HTTP-Query or Python script.
- π€ Integrate Xiaomi with other services (e.g. Telegram bots).
Example of Python script to enable Yeelight lamp:
from miio import ChuangmiPlug
plug = ChuangmiPlug(ip="192.168.1.100", token="YOUR_TOKEN")
plug.on # Turn on the lampTo get a token for API:
- Install the Mi Home Token Extractor app.
- Sign in to your Mi Home account.
- Copy the device token from the application log.
Castom firmware for devices
Some Xiaomi devices (such as robot vacuum cleaners or smart sockets) can be flashed with alternative software for advanced features.
- π€ Valetudo β firmware for robot vacuum cleaners (removes cloud dependency).
- β‘ OpenMiHome β an open protocol for interacting with devices.
Warning:
β οΈ Attention: Custom firmware is warranty-free and can cause permanent damage to the device!
6.3 Telegram bots for management
You can create your own Telegram-bot that will manage Xiaomi devices through the API. Example of teams:
- /light_on β light up.
- /status β temperature and humidity.
- /vacum_start β vacuum-drive.
This will require:
- Create a bot through @BotFather.
- Write a script in Python using the python-telegram-bot and miio libraries.
- Run a script on a server or Raspberry Pi.
Example of code for Telegram bot
7.How to test scenarios before implementation
Before you start a battle scenario, you have to test it, and here's a checklist to check it out.
Check the logic of the triggers (for example, the motion sensor is triggered?)|Ensure that conditions are met (e.g. geolocation works)|Testing actions on one device|Check the script at different times of the day|Set up error notifications-->
Testing tools:
- π Home Assistant Logs: Go to Settings β System system β Logs to see mistakes.
- π Mi Home Debug Mode: Enable the app settings (About the program) β Press 5 times on the version).
- π οΈ Postman: For testing API-device-question.
Examples of common mistakes and their solutions:
| Mistake. | Possible cause | Decision |
|---|---|---|
| Script not running | Incorrect trigger (for example, sensor is not on the network) | Check the device connection in Mi Home |
| Delay in implementation > 1 minute. | Xiaomi's cloud problems | Use local management (Home Assistant) |
| The device does not respond to the command | Outdated firmware | Update the device in Mi Home |
For complex scenarios, it is recommended to use the simulation mode in Home Assistant:
- Create a script in Settings β Automation.
- Enable the option Testing Mode.
- Run the script manually and check the logs.