Automation for Turning lights on or off depending on conditions

Good afternoon/evening,

I am working on my configuration for turning on/off some lights either at sunrise/sunset (minus 00:30:00 offset) but I want to have it so that if it is still light out in the evening before a certain time, or light out in the morning before a certain time that the lights will be on.

Ex. I have stairwell lights and under counter lights come on at 5:00 in the morning, and go off at sunrise with a 30 minute offset, and then have the lights come on again in the evening at sunset with a -30 minute offset, and have the undercounter lights go off at either 9:30 on weekdays and 10:30 on weekends, and the stairwell lights go off at 10:30.

How could I add in so that if it is still light out up till 7:00 in the morning, and still light out at 8:30 at night that the lights will go off and come on at those times, until it gets darker later in the morning and earlier in the evening?

I tried using “Or” , but that did not seem to work.

The turn on and off at sunrise/sunset have been working nice, just wanted to add in a time to turn off/back on if its still light out.

Thanks for all your help

Um… presumably you have a light sensor?

How about two automations? One turns the lights on in the morning when the light reaches an acceptable level, and another turns them on at sunrise. If the lights are already on, turning them on again won’t make any difference. Two more in the evening.

Or to be really sophisticated, one automation with two triggers. :grinning_face_with_smiling_eyes:

Not right now, that is one thing that I do want to add

Sorry - just done an edit of my last reply… :grinning_face_with_smiling_eyes:

Use the sun sensor and the attributes of dusk/dawn, or use the elevation of the sun to determine lights on/off. I do the latter combined with a weather condition sensor that says if it is not sunny, offset 30 minutes accordingly.