Smart Lighting Automation: Motion Sensor and Timer Integration

I’ve been experimenting with creating a more efficient lighting system in my home using smart devices. One of the challenges I’ve encountered is ensuring that lights turn off automatically after a period of no motion, especially in areas like the garage or hallway. While the ‘Motion and Mode Lighting’ app works well for detecting motion and turning lights on, it doesn’t handle the automatic shutdown as effectively as I’d like, especially if motion isn’t detected after the lights are initially turned on.I’ve tried setting up a simple automation where the lights turn on when a door opens and then turn off after a set period using a timer. However, this approach doesn’t account for motion detection, which is crucial for ensuring lights don’t stay on unnecessarily. I’ve heard that using RoutineManager (RM) might offer more flexibility in handling such scenarios, but I’m not entirely sure how to structure the logic to integrate both motion detection and a timer effectively.Has anyone successfully implemented a system where lights turn on when a door opens, stay on if motion is detected, and then turn off after a period of inactivity? I’d love to hear about your setups and any tips or tricks you’ve discovered while configuring similar automations. Additionally, if there are specific devices or integrations that work particularly well for this kind of setup, I’d appreciate any recommendations!