Streamlining Smart Lighting with Motion Sensors

I’ve been diving into the world of smart lighting lately, and I have to say, it’s been a fascinating journey! One of the main goals I set out to achieve was automating my home’s lighting system to turn on when I open the front door, especially during the evenings. I wanted this to happen seamlessly without any manual intervention, so I decided to use a Xiaomi Gateway paired with a window/door sensor and a motion sensor.

Initially, I thought the setup would be straightforward. I configured the sensor to trigger a light when the door opens, but I quickly realized that this wasn’t enough. I wanted the lights to stay on only if it was dark outside and to avoid triggering the lights if I just opened and closed the door within a short period. That’s when I started exploring more advanced automation rules.

After some research, I came across a YAML configuration that allowed me to set conditions based on the light level and the time since the last activation. However, I ran into an issue where the automation wouldn’t trigger after adding the time condition. It turned out that using the same sensor as both the trigger and the condition was causing the problem.

I reached out to the community for help, and someone suggested using a different sensor for the time condition or adjusting the logic to avoid conflicts. After a bit of tweaking, I managed to get everything working smoothly! Now, the lights only come on when it’s dark, and they stay on for a set period unless motion is detected, in which case they stay on longer.

This experience taught me the importance of understanding how different components interact in a smart home setup. It also highlighted the value of the community in troubleshooting and finding creative solutions. If anyone else is working on similar automations, I’d be happy to share more details or tips! :rocket: