Automation to turn on and off device based on fixed time

Hi,
i’m planning to create automation to turn on and off plug based on fixed time. I want to turn plug on 06:00 am and turn it off at 08:00 am so it will run 2 hours (so basically off → on → off). Can or should I do this using one automation or two (one to turn plug on and another turn it off).

Two automations is better.
If you use one and a delay in between then a restart will make the off not work.

I would even say that instead of fixed times make sure the time is “if time is past 08:00” then turn off.
Since a fixed time automation also could fail if the restart is 07:59:59

With two automations that doesn’t necessarily mean two automations.
You could have one automation with two triggers and trigger IDs that you use in the action.

1 Like

The best practice is to use 2 automations which trigger at your on and off times. This will mean that if there is an inadvertent restart of HA during your 2 hours it will still turn off automatically.

1 Like

This is what I would do. Keeps it nice and tidy. I’d also use input_datetime entities for the triggers so the times can be altered from Lovelace nice and easily.

Any help for a newbie? I don’t understand code, and when I’ve tried researching how to do this I keep getting code blocks and people talking in the thread who seem to understand what they’re talking about - but I don’t

Is there a newbies guide to scheduling simple On & Off schedules for a garden light? I am thoroughly confused. On my home assistant dashboard I have a card with the on/off toggle as an “Entity” but have no idea what to do now

Thank you!

Start here: