I want to run a automation until sun.sun is above_horizon
I want to automate some lights then sun.sun is below_horizon and i am away from home
I have a script that turn the lights off and on and some delays, so the only thing i need is keep running the script/automation until sun.sun become above_horizon.
I have something not too dissimilar. I’d suggest something slightly different. @petro’s suggestion is fine, but this might work a little better for you.
First, make the script run long enough to cover the whole time between sunset and sunrise, even if you include random delays.
Next, create an automation that starts the script when the sun is below the horizon AND you’re not home. (I assume you want it to start if you leave after sunset, yes?) This can be done with a template trigger.
Lastly, create another automation that stops the script when the sun goes above the horizon OR you come home.
If you like this idea, let me know if you need any concrete examples.
The expression becomes true when both conditions are met, and that’s when the automation triggers. If he leaves before sunset the expression will not be true yet, so it won’t trigger. But when the sun sets, if he’s still gone, the expression will become true and the automation will trigger.
EDIT: So then you ask, what happens if he comes back home, and then leaves again, all while the sun is still set? It will trigger again when he leaves, because once a template trigger fires it won’t fire again until the expression becomes False, and then True again.
I need to have the script running only then i am not_home and the sun.sun is below_horizon.
The issue i got now with @petro solution, is that the script is keep running, how can i stop it, lets say the scripts are half way done, and i come home, i want the script to stop, and not continue.