I have Simple Automation rule that turns on my exterior lights at sunset and off at sunrise. The exterior lights are a Scene that includes garage and deck lights (100%) and porch light (25%). I use the following rule to turn the porch lights up to 100% if motion is detected. The idea is that the increase in light level will make the visitor aware that they've been noticed.
The issue is that if the rule is triggered at say sunrise+29 and then again at sunrise+31, the waits are canceled, the IF () THEN is false, and the porch lights aren't turned off.
Is there an elegant way to account for this (admittedly rare) occurrence?
In Rule 5.1, which I assume you're using, an easy way would be to enable the "Use required expression" option and put your Time between sunset-30 and sunrise+30 minutes condition there. You could then remove this IF THEN ... END-IF from around your rule actions.
A required expression prevents the rule from triggering, even when a trigger event happens, if the required expression is false. Since triggers cancel waits, this will avoid the problem you mention.
The only issue here is if you also use an away mode. I am not currently using away so I haven't had to worry about it. I think I would be OK with the light resetting to 25% when away as that isn't the normal case, but that's me. I'm actually using a custom app for my exterior lighting and motion control so it handles a lot of different things and has three triggers besides motion: sunset, sunrise, and midnight (lights dim from 50% to 1% at midnight).
It does work. About six months ago I got a TTS notification that my side gate had been opened about 1:30 am. The lights came on full but when I checked there was nobody on the property. When I looked at the cameras I could see a head behind the gate and when the gate opened about two inches the lights came on and the person ran off. It doesn't deter everybody but it does help.