How to Set Up Nighttime Lighting Automation

Hey everyone, I’m trying to set up an automation for my lights so they turn on when I come home in the evening. I work for a telecom company and sometimes get called out in the middle of the night, so having the lights automatically come on would be super helpful. Here’s what I’m aiming for:

  1. Lights On When I’m Nearby: I want lights 1, 2, 3, 4, and 5 to turn on when I’m near my home.
  2. Time Constraints: This should only happen between 30 minutes before sunset and 10 minutes after sunrise.
  3. No Duplicates: Only the lights that are off should turn on, so if some are already on, they stay as they are.
  4. Lights Off After 10 Minutes: After 10 minutes, the lights that were turned on should turn off, but only those that were part of the initial automation. This way, if someone else is still up, their lights won’t be affected.

I’ve tried setting this up using RM4, but I’m struggling with a couple of things. First, I can’t figure out how to check if a light is already on before turning it on. Second, I’m not sure how to create a 10-minute timer for turning the lights off. Does anyone have any tips or resources for RM4 documentation or examples? I’d really appreciate the help!

Also, I’m curious if others have similar setups and how they handle the timing and light state checks. Any advice would be great!