Automating Lights with Motion Sensors: A Step-by-Step Guide

Hey everyone! I wanted to share my journey of setting up an automated lighting system using motion sensors. After spending hours researching and experimenting, I finally got everything working smoothly, and I’d love to walk you through the process. This setup not only enhances convenience but also adds a layer of security to my home.The goal was simple: turn lights on when motion is detected and turn them off after a short delay once motion stops. I chose Wyze motion sensors for their reliability and affordability, paired with Hue lights for their versatility. However, I quickly realized that the built-in automation blueprints were too limited for my needs. They couldn’t handle multiple sensors or complex light configurations, so I decided to take matters into my own hands.Here’s what I did:1. Understanding the Components: I started by listing all the motion sensors and lights I wanted to include. This helped me visualize the scope of the project and ensure I didn’t miss any devices.2. Setting Up Triggers: I used the state trigger for detecting motion and the no_motion trigger for turning lights off. This combination allowed me to handle both the activation and deactivation of lights seamlessly.3. Configuring the Automation: I structured the automation to check for motion across all sensors and then toggle the lights accordingly. Here’s a simplified version of the code I used:yamlalias: Motion Lights Automationdescription: Automatically turns lights on/off based on motion detectiontrigger: - platform: state entity_id: binary_sensor.motion_sensor_1 from: ‘off’ to: ‘on’ - platform: no_motion entity_id: binary_sensor.motion_sensor_1 for: 120 secondscondition: action: - service: homeassistant.turn_on target: entity_id: - light.living_room_lights - light.entryway_lights4. Testing and Fine-Tuning: I tested the automation with different scenarios to ensure it worked as expected. Adjusting the delay time was crucial to avoid lights turning off too quickly or staying on unnecessarily.5. Expanding the System: Once I had the basics working, I expanded the automation to include all four motion sensors in my home. This involved replicating the core logic for each sensor and ensuring they all communicated seamlessly.6. Monitoring and Maintenance: I set up a routine to monitor the system’s performance and make adjustments as needed. This proactive approach helped me catch and resolve any issues early on.Why This Matters: This automation has transformed my daily life. It provides peace of mind knowing that my home is secure, and it eliminates the hassle of manually managing lights. Plus, it’s a fantastic way to reduce energy consumption by ensuring lights are only on when needed.If you’re looking to implement a similar system, I highly recommend starting small, testing each component, and gradually scaling up. It’s a rewarding project that pays off in both convenience and efficiency. Let me know if you have any questions or need help setting up your own automation! :rocket: