Scene,Script or automation - What is the go to

Fort a light to come on at 5am and off 18hrs after how would you go about it?
I been messing with so many combinations and I get it to work but I feel I’m overlooking the obvious. Which is best way to get it done?

automation.

It’s the only way to trigger an action.

But the action can be a script necessary.

But since the action is very basic then it’s easiest to do it all in the automation instead of creating and calling a separate script.

Ok that was my thought atm. I wasn’t sure how HA treated the automations and scripts that if they are triggered to they keep running or now. I tried repeat in my automations but that doesn’t seem to be working. Should I be using loop? or once I run an automation it stays running until its stopped by default?

Automations will continue running until the actions complete or they reach a condition that is not true.

So in theory you could trigger the automation at 0500 and then give it a delay of 18 hours and then the automation would continue running and wait those 18 hours and turn off the light.

the issue you will have, especially with that long of a delay is if some thing happens while the automation is in the delay time (i.e. HA restarts) then the automation is stopped and the light action won’t happen.

since it is so long I would have one automation to turn on the light and also set an input_datetime to 18 hours later.

Then create another automation that turns off the light when the time of the input_datetime is reached.

That way there won’t be anything that will stop the light from being turned off at the right time.

Yes I agree. So for example:
One automation turns light on at 5am
another turns it off say 8pm.

Those automations would do that daily until stopped? or once they execute the light on do they stop?

yes. as soon as the trigger goes from false to true the automation begins to run. If the trigger occurs every day (as in the example you are using it would trigger at 5 am every day) then the automation runs every day.

It then checks the conditions for the automation and if true then the actions will be executed until the actions are complete or until another condition returns false (you can have additional conditions in the action section too).

I’m not sure I understand.

as explained above as long the trigger condition goes from false to true the automation executes. For the automation to re-trigger the trigger condition has to go back to false to get reset to trigger the next time.

Once the actions are complete the automation stops.

Until it is triggered again.

Thats kind of what I was asking but I didn’t word it well. You answered it, that once the automation triggers and the light actually goes on that automation is considered complete.

Thank you for your help. Much appreciated!

1 Like