I’m trying to turn on several lights when my porch motion sensor detects motion. I thought this IF condition meant if 30 minutes before sunset THEN DO. But for some reason the lights where not turning on. Sunset was at 7 PM, and this did not execute at 6:45 PM. What am I doing wrong?
The offset should be in “HH:MM:SS” format.
Are you trying to be specific to only the 30 minutes before sunset or do you want the condition to pass from 30 minutes before sunset onward?
As currently configured (excluding the offset issue which is causing it to fail) that condition should always pass…
before: sunset: Should pass from 00:00:00 until sunset.after: sunset: Should pass from sunset until 23:59:59. The offset is negative, so it has no real effect due to thebefore: sunset.
I’m trying for 30 minutes before sunset. So if sunset is at 7 PM, then the statement would trigger at 6:30 PM (Or later). Then trigger all night until sunrise.
-Thanks
Just to be clear, conditions do not trigger… they pass or fail. They are not checked until a triggering event has occurred. This difference is often confusing to new users and users coming to HA from other systems.
If you want the lights to turn on based on the event of the current time passing the threshold of 30 minutes before sunset, then you need to add a Sun trigger as well.
For the condition to pass from 30 minutes before sunset until midnight, the configuration should be as follows:
condition: sun
after: sunset
after_offset: "-00:30:00"
I got it, I had to add the before sunrise statement. So now this will trigger from 30 minutes before sunset, until sunrise.
-Thanks
condition: sun
before: sunrise
enabled: true
after: sunset
after_offset: "-00:30:00"
