Automation: on sunset, off specific time

Hi,
How can I make a single automation, for lights turning on at sunset, and let these lights go off on a specific time, example 23.00?
Thanks.

That’s 2 automations. One for on and one for off. These types of automations are HEAVILY documented in the automation section, cookbooks, and these forums.

to learn the basics, and the sidebar contains all the sections for automations.

Ok Thanks.
But I’m looking to put this in a single automation, if that’s possible.

not possible. Well it is possible, but it’s overly complicated to do so.

1 Like

You could do it with an appropriate wait_template (see here), but as Petro said, it’s overly complicated. Two automations is cleaner and simpler. Oh, and means that if you restart Home Assistant after the light turns on, but before the off time, it’ll still turn off :wink:

Though if you do restart between, the lights will not have had any triggers. I get round this by running a check at startup, but I’m migrating to binary sensors and running from them instead.
Or if you manually restart… You should be aware of the things you might want to manually switch as a consequence