How to Set Up Xiaomi Smart Scenarios: From Simple Rules to Complex Automation

What are Xiaomi Smart Scenarios and Why You Need Them

Xiaomi’s ecosystem offers not just individual smart devices, but a full-fledged automation system where light bulbs, outlets, sensors, and even robot vacuum cleaners can interact according to predetermined rules. Smart scenarios are the heart of such a system: they allow you to link the actions of several gadgets into a single chain that triggers (time, event, command).

Imagine you go home in the evening, and when you open the front door (Mi Door/Window Sensor 2 activates), you automatically turn on the warm light in the hallway (Yeelight LED), start the air purifier (Mi Air Purifier), and the smart speaker (Mi Smart Speaker) voices a greeting. Or another example: if the motion sensor (Mi Motion Sensor) detects activity at night, bright lights are turned on and a notification is sent to the smartphone.

In 2026, Xiaomi offers two main ways to customize automation:

  • πŸ“± The Mi Home app is a simple interface for basic scripting (suitable for beginners).
  • πŸ–₯️ Home Assistant is an advanced platform with script support and integration of other brands.
  • 🌐 Cloud services (e.g. Yandex Alice or Google Assistant) for voice control.

In this article, we will discuss both options – from creating the first scenario in Mi Home to configuring complex rules in Home Assistant, including typical errors and ways to get around them.

πŸ“Š What kind of smart home ecosystem do you use?
Only Xiaomi.
Xiaomi + Other Brands
Other brand (Aqara, Tuya, etc.)
I'm not using it yet.

Device Preparation: What You Need to Create Scenarios

Before you set up automation, make sure your ecosystem is ready for it.

  1. Smart Hub: Most scenarios require a gateway (Xiaomi Mi Smart Home Hub, Aqara Hub, or Mi Gateway 3) without which devices will not be able to communicate locally (except for devices with Zigbee 3.0 or Matter support).
  2. Update Software: Check the firmware version of the hub and devices in the Mi Home app. Outdated versions may not support new triggers.
  3. Stable connection: The hub must be connected to a 2.4 GHz network (not all devices run on 5 GHz).

Also consider the Zigbee protocol feature in Xiaomi’s ecosystem: if you have more than 30 devices, you may need a second hub to work smoothly, otherwise you may have script delays (up to 2-3 seconds).

The deviceNeed a hub?Supported triggers
Yeelight LED❌ No (Wi-Fi)On/off, change in brightness, color temperature
Mi Door/Window Sensor 2βœ… Yes (Zigbee)Opening/closing, vibration
Mi Smart Plug❌ No (Wi-Fi)On/off, energy consumption
Mi Motion Sensorβœ… Yes (Zigbee)Movement, lighting, temperature

⚠️ Warning: If you use Aqara devices (such as water or smoke sensors), they should be tied to the Aqara hub, not Xiaomi. Otherwise, they won't show up in the trigger list for scripts.

Creating the first scenario in Mi Home: step-by-step instructions

Let's start with the simplest one: automation through the official Mi Home app, which is suitable for basic tasks, such as turning on the lights on a schedule or when the sensor is triggered.

Step 1. Open the Automation section:

  • πŸ“± Launch the Mi Home app and select Profile β†’ Automation tab.
  • πŸ”„ If a partition is missing, update the app to the latest version (the minimum supported is 6.5.400).

Step 2. Select the type of scenario:

  • ⏰ Scheduled – actions are performed at a specified time (e.g., turn off all outlets at 23:00).
  • πŸ”„ By event, a reaction to a trigger (movement, door opening, temperature change).
  • πŸ“± On command – run the script by voice or via a widget on a smartphone.

Update the hub's firmware and devices |

Check the connection to the 2.4 GHz network |

Make sure that the devices are added to one "Homespace" |

Turn it off. VPN (It can block access to Xiaomi servers)-->

Step 3: Set up the trigger and action:

Let’s take an example: β€œSwitch on the light in the corridor when the front door is opened.”

  1. Select the β†’ Door/Window Sensor.
  2. Specify a specific sensor (e.g. Mi Door/Window Sensor 2: Front door).
  3. Select event: Open.
  4. Add action: Smart lamp β†’ Turn on β†’ Brightness 70%.

⚠️ Warning: You can't create a script with a delay between actions (e.g., "turn on the light 5 seconds after opening the door").

πŸ’‘

If the scenario doesn't work, check the geofence in the app settings. Sometimes Mi Home blocks automation if your smartphone is out of the home zone.

Advanced Scenarios: Using Home Assistant

If Mi Home isn’t enough (e.g., delays, conditions, or integration with other brands’ devices), use Home Assistant.This is an open platform that supports YAML- scripts, a visual editor, and on-premises management without the cloud.

Step 1. Install Home Assistant:

  • πŸ–₯️ The easiest way is to use a pre-made build for the Raspberry Pi or install it through Docker.
  • πŸ”Œ Connect Xiaomi Gateway 3 to Home Assistant through Xiaomi Miio integration (device token required).

Step 2: Create automation.

Example of a delay and condition scenario:

alias: "Night mode while driving"


trigger:




- platform: state




entity_id: binary_sensor.motion_sensor_158d0001234567




to: "on"




condition:




- condition: time




after: "22:00:00"




before: "06:00:00"




action:




- delay: "00:00:05" # Delay 5 seconds




- service: light.turn_on




target:




entity_id: light.yeelight_ceiling_1




data:




brightness: 255




color_temp: 370

This scenario includes a full-blind ceiling light with a warm color temperature (370 mired = ~2700K), but only if the movement is recorded after 22:00.

Problem.Solution in Home Assistant
The script works many times over.Add for: to the trigger (e.g., for: "00:00:30" - ignore 30 seconds of re-actions)
Devices not detected.Check the token in configuration.yaml or reboot the hub
Delays in implementationTurn off cloud sync in Miio integration settings
How to get a Xiaomi token for Home Assistant?
1. Install the Mi Home app on Android. 2. Download Packet Capture and start recording traffic. 3. Sign in to Mi Home β€” find the string with token=. 4 in the logs. Copy the token and paste into configuration.yaml: xiaomi_miio: username: YOUR_MI_ACCOUNT password: YOUR_PASSWORD token: YOUR_TOKEN_HERE ⚠️ Token is valid until the password change in your Xiaomi account!

Common Mistakes and How to Avoid Them

Even in simple scenarios, users are faced with problems. Here are the TOP-5 errors and their solutions:

  • πŸ”Œ The device does not respond to the scenario: Check if it is added to the same Homespace in Mi Home. Make sure the hub is connected to the power (the indicator should burn blue, not red).
  • ⏱️ Delays: Delays are inevitable in Mi Home (Xiaomi servers in China). Use Home Assistant for critical tasks. If you use Zigbee, reduce the number of devices on one hub (optimally, to 20).
  • πŸ“΅ The script only works with an open application: In your smartphone settings, turn off battery optimization for Mi Home. For Android: add the app to exceptions in Settings β†’ Battery β†’ Optimization.

Critical error: If scripts stopped working after the hub update, reset it to factory settings (hold the 10 seconds button) and add the devices again. In 2023, Xiaomi changed the encryption protocol for Zigbee, and older devices may lose communication.

⚠️ Warning: If you use Mi Home on iOS, some automation features may not be available due to Apple's limitations. For example, it is impossible to create a geolocation script (only on Android).

Integration with voice assistants (Alice, Google, Siri)

Smart scripts can be run by voice through Yandex Alice, Google Assistant or Siri, and you need to link your Xiaomi account to the corresponding service.

Step 1. Connect Xiaomi to Alice:

  1. Open the Yandex app and go to Devices β†’ Add Device β†’ Xiaomi.
  2. Sign in to your Mi Home account (use the same region as the main app!).
  3. Once you sync, the devices will appear in the list. Now you can create voice commands.

Examples of voice commands:

  • πŸ—£οΈ "Alice, turn on the movie mode" - runs the script with dimmed lights and the TV on.
  • πŸ—£οΈ OK Google, I'm leaving, turns off all the outlets and activates the burglar mode.

Limitations:

  • ❌ Alice does not support devices connected via Home Assistant (native Mi Home only).
  • ❌ Google Assistant may not recognize Cyrillic device names (rename them Latin).

πŸ’‘

For stable voice commands, disable two-factor authorization in your Xiaomi account – it can block access for third-party services.

Examples of ready-made scenarios for different tasks

You can take inspiration from these off-the-shelf solutions. You can adapt them to your devices.

  • πŸŒ… "Die Dawn": Trigger: Time β†’ 06:30 Action: Turn Yeelight on 1% brightness with temperature 2000K. Gradually (in 20 minutes) increase the brightness to 70%. At 07:00 start the coffee maker (Mi Smart Kettle).

"Security mode"

  • Trigger: Geolocation β†’ Everyone left the house.
  • Action: Turn off all sockets. Activate the motion sensors. Send a notification: "House is empty. Security is on."

Climate Control.

  • Trigger: Temperature sensor β†’ Below 20Β°C.
  • Action: Turn on the heater (Mi Smart Heater), if the temperature is above 25 Β° C, turn on the air purifier.

For complex chains (e.g., if...then..) use Home Assistant or Node-RED, a visual automation editor.

FAQ: Frequent questions about Xiaomi smart scenarios

Can you create a script without a hub?
Yes, but with limitations. Wi-Fi devices (such as Mi Smart Plug or Yeelight) can communicate with each other via the Xiaomi cloud, but: Delays will be longer (up to 5-10 seconds). Zigbee sensors cannot be used (they require a hub). When you turn off the Internet, scenarios will not work. A hub (Mi Gateway 3 or Aqara Hub) is still recommended for stable operation.
Why does the script work twice?
This is a typical problem with the use of motion sensors (Mi Motion Sensor), the reason is that the device sends a signal when it detects movement and when it stops. Solutions: In Mi Home: no fix (app restriction). In Home Assistant: add the condition for: "00:00:30" to the trigger to ignore repeated triggers for 30 seconds.
How to transfer scripts to a new phone?
The scripts are stored in the Xiaomi cloud, so when you change your phone, you just need to install Mi Home and log in to the same account. Connect to the same Homespace. Update the list of devices (you may need to reboot the hub). If the scripts don't appear, check the account region - it should match the region when you create automation.
Can I use devices from other brands (Aqara, Tuya) in Xiaomi scenarios?
Partially. In Mi Home, you can only add Xiaomi-compatible Aqara devices (e.g. water or smoke sensors). To do this, select Add Device β†’ Aqara in the Mi Home app. Follow the instructions (click the button on the device to pair). Tuya or other brands can only be integrated through Home Assistant (e.g., through Tuya Integration or Zigbee2MQTT plugins).
How do you debug a broken script?
Diagnostic order: Check the devices: make sure they are online (Mi Home should have a green indicator next to the name). Test Step-by-step: Does the trigger work? (e.g., does the door open, is the movement recorded). Is the action manually performed? (try to turn on the lamp through the application). View the logs: Home Assistant: Settings β†’ Logs. Mi Home: no logs, but you can turn on script notifications in the automation settings. Recreate the scenario: sometimes helps remove and recreate with the same parameters. If the problem remains with homeassist, contact the home assistant with the homelog.