Hey everyone! I’ve been diving into home automation lately, and I thought I’d share my experience with setting up a PIR sensor to control my room lights. It’s been a fun project, and I hope this helps others who might be tackling something similar.First off, I wanted to create a system where the lights turn on when motion is detected and stay on as long as there’s movement. The challenge was figuring out how to keep the lights on continuously and then turn them off after a period of no motion. I remember seeing some solutions involving timers, but I wasn’t entirely sure how to integrate them into my setup.I started with a PIR sensor connected to an ESP8266-01 running Tasmota. The sensor was wired to GPIO14, and I noticed that every time motion was detected, the sensor would send a signal to my MQTT broker. This was great, but I needed a way to translate those signals into meaningful actions for my lights.After some research, I realized that using an automation rule to trigger the light when motion was detected was the way to go. But the tricky part was keeping the light on. I discovered that by setting a timer component, I could ensure the light stayed on for a set period after the last motion. This way, the lights wouldn’t turn off immediately if I paused for a moment, which is perfect for my needs.Here’s a quick breakdown of how I set it up:1. PIR Sensor Configuration: I made sure the PIR was correctly connected and publishing to my MQTT broker. Tasmota made this straightforward with its built-in MQTT support.2. Automation Rule: I created a rule in my automation system (Home Assistant in my case) that triggers when the PIR sensor detects motion. This rule turns on the light and starts a timer.3. Timer Integration: The timer is set to 5 minutes. If motion is detected again before the timer expires, the timer resets. If not, the timer completes, and the light turns off.4. Testing and Adjustments: I tested the setup extensively, adjusting the timer duration to suit my lifestyle. It’s important to find the right balance so the lights don’t turn off too soon or stay on unnecessarily.One thing I learned is the importance of logging and monitoring. By checking the MQTT messages and automation logs, I could troubleshoot any issues quickly. For example, I initially had some hiccups with the timer not resetting correctly, but adjusting the automation logic fixed that.I’d love to hear how others have approached similar projects. Have you used a different method for motion-activated lights? What challenges did you face, and how did you overcome them? Let’s share our experiences and tips below!Happy automating! ![]()