Xiaomi Motion Sensor Automation Tips and Tricks

I recently set up my Xiaomi motion sensor alongside a Yeelight LED strip, and I wanted to share some tips and tricks I learned along the way. While my initial setup worked, I faced a few challenges that I thought others might relate to or find helpful!

The Setup

I configured my automation to turn on the LED strip when motion is detected and turn it off after a minute of inactivity. Here’s the basic code I used:

yaml

  • id: strip_motion_on
    alias: Turn on strip movement
    trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_xxx
    to: ‘on’
    action:
    service: homeassistant.turn_on
    entity_id: light.yeelight_strip_xxx

  • id: strip_motion_off
    alias: Turn off strip movement
    trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_xxx
    to: ‘off’
    for: minutes: 1
    action:
    service: homeassistant.turn_off
    entity_id: light.yeelight_strip_xxx

Challenges and Solutions

  1. Timeframe Automation
    I wanted the automation to only work during specific times, like at night. After some research, I discovered that using time_conditions in the trigger was the key. This way, the strip only activates after sunset and turns off by sunrise!

  2. Alexa Integration
    While I could manually turn on the strip via Alexa, it would still turn off after the set timeframe. To fix this, I added a condition to check if the strip was manually turned on. If so, the automation respects that state and doesn’t override it!

  3. Motion Detection Delay
    The strip sometimes turned off even when motion was still detected. I realized this was due to the sensor’s sensitivity settings. Adjusting the delay and sensitivity in the Xiaomi app made a huge difference!

Personal Experience

It’s been such a game-changer for my home’s ambiance. The strip adds a warm glow in the evenings, and I love how it automatically adjusts based on my movements. Plus, integrating it with Alexa means I can still manually control it if needed!

Final Thoughts

If you’re looking to enhance your home’s lighting with motion sensors, I highly recommend experimenting with different automation rules. It’s a fantastic way to save energy while maintaining comfort. Happy automating! :rocket: