How to set up Xiaomi’s door opening sensor: from installation to automation

Xiaomi’s door-opening sensors are among the most popular smart home devices because of their simplicity, reliability and low price; they allow you to monitor the condition of doors, windows, cabinets and even household appliances by sending notifications to your smartphone when you open them, but many users have difficulty connecting first: the device is not detected in the application, the signal disappears, or the automation is not working properly.

In this article, we will look at all the steps of sensor setup, from the physical installation to creating complex scenarios in the Mi Home or Apple HomeKit (if you use an Aqara gateway), focusing on typical errors, such as when the sensor stops responding to a magnet after 2-3 months of use due to improper positioning, and learn how to extend the battery life and integrate the device with other ecosystems, such as Google Assistant or Yandex Alice.

What models of door opening sensors Xiaomi releases

Xiaomi and its sub-brand Aqara offer several sensor modifications that look similar but have key differences in functionality and compatibility.

  • πŸ”Ή Mi Door/Window Sensor 2 β€” base model with Zigbee support, works only through the Xiaomi Gateway (not compatible with Matter).
  • πŸ”Ή Aqara Door and Window Sensor (E1) β€” Improved version with extended range (up to 150 m in open space) and support for Apple HomeKit through the gateway Aqara Hub M2.
  • πŸ”Ή Aqara Door and Window Sensor P2 β€” premium model with moisture protection (IP54), Suitable for street gates or baths. Works with Matter through the Aqara Hub gateway M3.
  • πŸ”Ή Mi Smart Door and Window Sensor (Bluetooth) – a rare model, connects directly to the smartphone via Bluetooth (without a gateway), but with limited functionality.

Importantly, most Xiaomi sensors require a gateway to work in the smart home ecosystem. The exception is the Bluetooth model, but it doesn't have the ability to create automation with other devices. If you don't already have a gateway, consider buying the Aqara Hub M2, which supports up to 128 devices and is compatible with HomeKit.

πŸ“Š What kind of door opening sensor do you have?
Mi Door/Window Sensor 2
Aqara E1
Aqara P2
Other (write in the comments)
I haven't bought it yet.

Preparation for installation: what will be needed

Before you start setting up, make sure you have everything you need:

  • πŸ“± Smartphone with Mi Home app installed (for Android/iOS) Aqara Home (if you use Aqara devices).
  • πŸ”Œ Xiaomi Gateway or Aqara Hub (for most sensor models).
  • πŸ”‹ Battery CR2032 (It usually comes with a set, but it is better to have a spare).
  • πŸ“ Roulette or ruler for precise positioning of the magnet.
  • 🧲 Alcohol wipes to clean the surface before sticking.

Critical: the sensor and magnet must be installed at a distance of no more than 20 mm from each other, if the gap exceeds this value, the device will work unstable or not respond at all to opening, and avoid mounting on metal surfaces - this can distort the signal.

Make sure the gateway is connected to the network and works | Check the battery charge in the sensor | Clean the surface of dust and grease | Prepare a smartphone with the installed application-->

Step-by-step instructions for connecting the sensor in Mi Home

The process of adding a sensor to the Xiaomi ecosystem takes no more than a few years. 5 So if you follow a very clear algorithm, let's look at the Mi connection. Door/Window Sensor 2:

  1. Open the Mi Home app and go to Devices β†’ Add Device (+).

Name the device.

(e.g., "Kitchen Window" or "Girl Door") and select a room for it.

Once connected successfully, the sensor will appear in the main menu of the app, and you can now configure notifications and automation.

What to do if the sensor is not connected?
If the device is not detected in Mi Home, try the following steps: 1. Reset the gateway (turn off power for 10 seconds). 2. Reset the sensor - to do this, hold the button on it for 10-15 seconds until the indicator flashes 3 times. 3. Check the region in the application - if the wrong region is selected (for example, China instead of Europe), some devices may not be added. Change the region in the Mi Home profile. 4. Update the gateway firmware - outdated software often leads to pairing problems.

Set up notifications and automations

By default, the sensor just detects the opening/closing, but its real power is in automation.

  • πŸ”” Smartphone notifications when the door is open for longer than 5 minutes (useful for monitoring children or pets).
  • πŸ’‘ Automatic lighting when opening the door in the dark.
  • 🚨 Siren or flashing lamps if the door is open in your absence (Integration with Xiaomi Home Security).
  • 🌑️ Turning off the heater if the window is open for more than 10 minutes (energy savings).

To create automation in Mi Home:

  1. Go to the Automation section β†’ Create β†’ If....
  2. Select your sensor and condition (e.g., "Door open").
  3. Add an action (e.g., "Enable Yeelight lamp").
  4. Save the script and test it out.

For advanced users: If you have an Aqara Hub M2/M3 gateway, you can use the Aqara Home app to create more complex scenarios with delays and multiple conditions.

IF (Inlet door sensor = "Open")


I (Time between 22:00 and 6:00)




Then (Set on siren, send notification, turn on all lamps)

πŸ’‘

If you have multiple sensors, name them as specific as possible (e.g., "Balcony Door (floor 2)"), which will make it easier to set up automations and help you quickly navigate the list of devices.

Common Errors and How to Resolve Them

Even after successful setup, Xiaomi sensors sometimes fail, and here are the most common problems and solutions:

Problem.Possible causeDecision
Sensor not responding to openingThe magnet is set too far or at an angleCheck the gap (maximum 20mm) and align the position
Persistent false positivesVibrations or drafts shift the magnetInstall the sensor on a hard surface or use double-sided 3M Scotch
Battery discharged in 1-2 monthsThe sensor is in the bad signal zone, constantly looking for a gateway.Move the gateway closer or add a signal repeater (e.g. Aqara Range Extender)
Sensor shuts off the network.Interference from other Zigbee devices (e.g. Wi-Fi router on channel 11)Change the Zigbee channel in the gateway settings (optimum 15, 20 or 25)

An important caveat: if the sensor stopped working after updating the gateway firmware, try rolling back the software version or resetting the gateway to factory settings. Sometimes new firmware contains bugs that affect compatibility with older devices.

πŸ’‘

If the sensor starts to glitches after replacing the battery, check the polarity – an incorrect installation can cause a reset.

Integration with other ecosystems (HomeKit, Google Assistant, Alice)

Xiaomi/Aqara sensors can be connected not only to the native app, but also to other smart home platforms.

1. Connection to Apple HomeKit

This requires an Aqara Hub M2 or M3 gateway:

  1. Open the Aqara Home app and go to Settings β†’ HomeKit.
  2. Click "Add to HomeKit" and scan. QR-lock-body.
  3. All connected sensors will automatically appear in the app Home (iOS).

2. Sync with Google Assistant

Use the Mi Home app:

  1. Go to Profile β†’ Settings β†’ Voice Assistant.
  2. Select Google Assistant and log in.
  3. Allow access to devices – after that, the sensors will be available in Google Home.

3.Management through Yandex Alice

This will require a gateway Xiaomi Gateway 3 or Aqara Hub M2:

  1. In Mi Home go to Settings β†’ Yandex.
  2. Sign in through your Yandex ID account.
  3. Tell Alice, "Find my devices," the sensors will appear on the list.

Limitation: In Yandex Smart Home, the opening sensors are displayed as β€œsensors”, and their state can only be checked by voice (for example, β€œAlice, is the door open?”). Automation through Alice can not be configured – use Mi Home.

How to extend the life of the sensor

The average life of the CR2032 battery in the Xiaomi sensor is 1-2 years, but if used correctly, it can be extended to 3-4 years.

  • πŸ“Ά Optimize the location of the gateway – if the signal is weak, the sensor spends more energy on data transmission.
  • ⏳ Reduce the frequency of the survey – in the sensor settings in Mi Home, you can set the interval for sending data (for example, once every 5 minutes instead of constant monitoring).
  • πŸ”‹ Use high-quality batteries – cheap analogues often discharge 2-3 times faster. CR2032 or Duracell.
  • 🧲 Avoid extreme temperatures – in the cold below -10Β°C or heat higher +50Β°C battery goes down faster.

Useful life hack: if the sensor starts to give false positives, don't be in a hurry to change it. Often the problem is solved by reinstalling the magnet - over time it can shift due to vibrations or deformation of the door. Check the gap with a sheet of paper: if it passes between the sensor and the magnet, then the distance is too large.

πŸ’‘

If the sensor is no longer responsive to the magnet, try retraining it: unplug the magnet, hold it to the sensor at a distance of 1-2 mm and hold it for 10 seconds.

FAQ: Frequent questions about Xiaomi's opening sensors

Can I use the sensor without a gateway?
Only the Mi Smart Door and Window Sensor (Bluetooth) model works without a gateway, but its functionality is limited - it can only send notifications to a smartphone within a radius of 10-15 m.
How to reset the sensor to factory settings?
Hold the button on the sensor for 10-15 seconds until the indicator blinks 3 times. After that, the device will be ready to reconnect.
Why does the sensor show β€œOffline” in the app?
The reasons can be different: the gateway is disconnected from the network or overloaded (reset it); the sensor is too far from the gateway (maximum 10-15 m indoors); the battery is dead (replace it even if the indicator does not flash); interference from other devices (try changing the Zigbee channel in the gateway settings).
Can I use a sensor on a metal door?
Yes, but with reservations: metal can shield the Zigbee signal, so the gateway should be as close as possible. Also avoid mounting the sensor directly on the metal surface - use a plastic pad or double-sided tape.
How to check the signal level between the sensor and the gateway?
In the Mi Home app, go to the sensor settings and find Signal Level (or LQI) setting. The optimal value is above 100. If it is below 50, move the gateway closer or add a repeater.