How to connect the Xiaomi motion sensor to the light bulb: 3 working ways

Automating lighting with motion sensors is one of the most popular scenarios in Xiaomi Smart Home. Imagine you walk into a hallway or bathroom, the lights turn on automatically, and after 30 seconds without moving, it turns off. No search for a switch in the dark, no forgotten burning lamps. But how do you put this into practice?

Xiaomi motion sensors (such as the Mi Motion Sensor or Aqara Motion Sensor) integrate perfectly with smart light bulbs of the same ecosystem β€” Yeelight, Mi LED Smart Bulb or Philips Hue (through the gateway). However, many users face problems: the lamp does not respond to movement, automation is triggered with a delay or is unstable. In this article, we will discuss three proven ways of connecting, from the simplest via Mi Home to advanced settings through Home Assistant.

It is important to understand that the choice of method depends on your hardware. If you already have a Xiaomi Gateway, the task is simplified. If not, you will either need to buy a gateway or use alternative platforms like Home Assistant. We will consider all options, including budget solutions without additional devices (with restrictions).

Method 1: Connect via Mi Home (the easiest)

This is a basic method that will work for most users, requiring minimal effort, but has limitations: it only works with Xiaomi/Aqara devices connected to the same gateway, and does not support complex scenarios (for example, different behaviors day and night).

First, make sure you have:

  • πŸ“± Smartphone with Mi Home app installed (version no lower than 6.0).
  • πŸ”„ Xiaomi Gateway (any model: v1, v2, v3 or Aqara Hub).
  • πŸ’‘ Smart light bulb compatible with Mi Home (e.g. Yeelight Color or Mi) LED Bulb Essential).
  • 🚢 Xiaomi Motion Sensor or Aqara Motion Sensor.

If you have everything, follow the instructions:

  1. Add devices to Mi Home. Open the app, go to Profile β†’ Settings β†’ Add the device and connect the gateway, light bulb and motion sensor sequentially. Make sure all devices are in the same room (Smart Home β†’ Rooms).
  2. Create automation. Go to Automation β†’ Create β†’ If..., select motion sensor and event Motion Detected. In the To... specify light bulb and action Enable.
  3. Set the switch off. Set the second automation: condition - no motion detected, action - turn off the light bulb. Set a delay (for example, 30 seconds) so that the lights do not turn off at the slightest pause in movement.

The motion sensor is located at an altitude of 1.5-2.5 m from the floor |

Light bulb and sensor connected to the same Wi-Fi network (2.4 GHz) |

The gateway is within a radius of 10 meters from the sensor|

Sensor settings have enabled "High Sensitivity" (if available)-->

This is a good way to do it for 80 percent of users, but it has a key disadvantage: automation only works when you have an active Internet connection (the data is going through the Xiaomi cloud), if Wi-Fi goes off, the light will stop responding to movement, and you can't customize different behaviors based on the time of day or the level of light.

πŸ’‘

If the light bulb flashes when the sensor is triggered, check the gateway settings: go to Devices β†’ Gateway β†’ Settings β†’ Nightlight Mode and turn off the β€œRespond to sensors” option.

Method 2: Using Aqara Home (for advanced scenarios)

Aqara Home (formerly Mi Home for Aqara devices) offers more flexible automation settings, including time of day and light levels, which is suitable if you have an Aqara sensor or light bulb, or if you want to create complex scenarios.

The advantages of Aqara Home over Mi Home:

  • πŸŒ“ Ability to schedule automation (e.g., turn on lights only from 18:00 to 7:00).
  • β˜€οΈ Integration with light sensors (the lamp will only be turned on in the dark).
  • ⚑ More stable local automation (without dependence on the cloud).

Step-by-step:

  1. Install the Aqara Home app and log in with the same account as you do on Mi Home.
  2. Go to Automation β†’ Add β†’ Customized.
  3. Select Motion Sensor β†’ Motion detected as a condition.
  4. Add additional conditions (optional): Time: 18:00 to 07:00. Illumination: Less than 50 lux (if you have a light sensor).

Turn on

Create a second automation to turn off the lights with a delay (for example, 1 minute).

The main difference from Mi Home is that it can combine conditions, for example, the lights will only turn on at night and only if the room is dark, which saves the life of the light bulb and makes automation more logical.

Xiaomi/Yeelight|Philips Hue|Aqara|Another (write in the comments)|Not yet using-->

Method 3: Connecting with Home Assistant (maximum flexibility)

If you want advanced scenarios (like graduating lights, integrating with other systems, or working without the cloud), the best choice is Home Assistant.This is an open smart home platform that supports Xiaomi devices via Zigbee protocol (if there is a gateway) or Wi-Fi (for Yeelight lamps).

The downside of this is the complexity of the setup.

  • πŸ–₯️ Home Assistant (Raspberry Pi, old PC or other) NAS).
  • πŸ”Œ Xiaomi Gateway with firmware for local management (or Zigbee2MQTT).
  • βš™οΈ Basic knowledge of working with YAML-configuration.

Instructions for setting:

  1. Install Home Assistant. Follow the official instructions. For beginners, we recommend the Home Assistant OS image for Raspberry Pi.
  2. Connect the Xiaomi gateway. Add the configuration.yaml file: xiaomi_aqara: gateways: - key: YOUR_GATEWAY_KEY The gateway key can be obtained through Mi Home (in the gateway settings, click About This Device and copy Password).
  3. For Yeelight, use the Yeelight: yeelight: devices integration: 192.168.1.100: # IP-address of the lamp name: "Corridor lamp"
  4. Create automation. Go to Settings. β†’ Automation β†’ Create and configure a motion sensor trigger: trigger: platform: state entity_id: binary_sensor.motion_sensor_158d000xxxxxx to: "on" action: service: light.turn_on target: entity_id: light.yeelight_color1
  5. Configure Delayed Shutdown: Start: Platform: State entity_id: binary_sensor.motion_sensor_158d000xxxxxx to: "off" for: minutes: 1 action: service: light.turn_off target: entity_id: light.yeelight_color1

Home Assistant allows you to do things that are not possible in Mi Home.

  • 🎭 Smooth lights on/off (via the transition parameter).
  • πŸ”„ Cyclic scenarios (e.g. flashing lights when alarms are triggered).
  • πŸ“Š Log events (you will see when and why the sensor went off).
How to get IP-lightbulb address?
Open the Yeelight or Mi Home app, go to the light bulb settings and find the Network section. Alternatively, use a network scanner (like Fing for Android/iOS) and look for a device called yeelink-light-*.

Critical feature: if you use the Xiaomi Gateway v3, you will need to flash it with an alternative firmware (for example, OpenMQTTGateway) for local management, otherwise the data will go to the cloud.

Device compatibility table

Not all motion sensors and light bulbs work together out of the box. Below is a table of compatibility of popular Xiaomi/Aqara devices with different connection methods:

The deviceMi HomeAqara HomeHome AssistantNotes
Xiaomi Motion Sensorβœ…βœ…βœ…Requires a Xiaomi Gateway.
Aqara Motion Sensor (P1)βŒβœ…βœ…It only works through the Aqara Hub.
Yeelight Colorβœ…βœ…βœ…It connects directly to Wi-Fi.
Mi LED Bulb Essentialβœ…βŒβœ…Aqara Home is not supported.
Philips HueβŒβŒβœ…Requires the Philips Hue Bridge Gateway.

If your device is not in the spreadsheet, check its compatibility on the Zigbee2MQTT site (for devices on Zigbee) or in the Home Assistant documentation.

Common Problems and Their Solutions

Even if you set it up properly, automation can work incorrectly.-5 problems and ways of eliminating them:

  1. Sensor not responsive to motion: Check the battery (Xiaomi sensors use CR2450). Make sure there are no barriers (walls, metal objects) between the sensor and the gateway. At Mi Home, go to the sensor settings and press Communication Check.
  2. The light bulb flashes or spontaneously turns on: Update the light bulb firmware via Mi Home or Yeelight. Turn off the Sound Sensor Response option in the gateway settings. Check the network connection: Yeelight light bulbs are sensitive to Wi-Fi interruptions.

Automation is running with a lot of delay.

  • If you are using Mi Home, the problem is cloud processing – go to Home Assistant.
  • Reduce the number of devices on a Zigbee network (optimally, no more than 20).
  • Reset the gateway (turn off power for 10 seconds).

πŸ’‘

If the motion sensor is falsely triggered (e.g., on pets), reduce the sensitivity in the settings or move it higher (to a height of 2.5 m).

⚠️ Note: If you are using the Xiaomi Gateway v3 With Aqara firmware, don't update it through Mi Home, it can block the device.

Optimal placement of the motion sensor

The location of the sensor depends on the accuracy of the alarm and the absence of false signals.

  • πŸ“ Height: 1.5-2.5 meters from the floor, at a lower altitude, the sensor will act on animals, at a higher altitude, it may not notice movement.
  • πŸ”„ Viewing angle: most Xiaomi sensors require direct view of the detection zone.
  • β˜€οΈ Lighting: Avoid direct sunlight – these can cause false positives (especially in PIR sensors).
  • πŸšͺ Coverage area: one sensor is effective for areas up to 6-8 m2. For large spaces, use multiple sensors.

Example of optimal location for a corridor:

  • The sensor is installed on the wall opposite the entrance, at a height of 2 meters.
  • The angle of inclination is 10-15Β° down to capture the legs of the passers-by.
  • If the corridor is long, add a second sensor at the opposite end.

πŸ’‘

To test the sensor coverage, use the Test mode in Mi Home (in the sensor settings). Walk around the room and watch the alarm.

FAQ: Frequent questions about connectivity

Can you connect Xiaomi motion sensor to a light bulb without a gateway?
No, Xiaomi/Aqara sensors require a gateway (Xiaomi Gateway or Aqara Hub) to work, except for Wi-Fi-enabled sensors (such as the Aqara FP2), but they are not directly compatible with light bulbs, and the alternative is to use platforms like the Home Assistant with a Zigbee adapter (such as the CC2531).
Why does the light bulb turn on with a delay of 2-3 seconds?
The delay is caused by cloud computing in Mi Home. Solutions: Go to Home Assistant with local management. Use Aqara Home, where some automation works locally. Reduce the number of devices on the Zigbee network (optimally, to 15-20).
How do you make the lights only turn on at night?
In Mi Home, this is not possible. In Aqara Home or Home Assistant, add condition: - condition: time after: "18:00:00" before: "07:00:00" You can also use a light sensor (for example, Aqara Light Sensor) with a light condition < 50 lux.
Motion sensor is activating on the cat. How do you fix this?
Ways to reduce false positives: Increase the sensor installation height to 2.5 m. Reduce sensitivity in settings (if available). Use sensors with a weight adjustment (e.g., Aqara FP1 ignores objects lighter than 10 kg). Move the sensor to a place where the animal is rarely seen.
Can I connect the Xiaomi sensor to the Philips Hue light bulb?
Yes, but only through Home Assistant or Apple HomeKit (if you have a HomePod or Apple TV). Mi Home or Aqara Home is not possible due to different protocols (Zigbee from Hue is not compatible with Xiaomi Gateway). Instructions for Home Assistant: Connect Philips Hue Bridge to Home Assistant via Philips Hue integration. Add Xiaomi gateway via Zigbee2MQTT or native integration. Create automation with a trigger from the motion sensor and action for the Hue light bulb.