I set up my first automation but I'm not sure about it

I have a Salus smart plug for my espresso machine. I want it to turn on at 4:30 AM and turn off at 10:30 AM. I created two triggers, one to turn on and one to turn off but I’m not sure

Should I create just one automation to run for 6 hours rather than two? I’m not quite sure how to do that but I could probably figure it out. Also if I have a toggle for the machine on the dashboard will that have an effect on the automation if I toggle it on and off outside of the running hours?

Thanks for any pointers.

No.

leave it so that you use two automations.

Automations are stopped when HA is restarted or automations are reloaded.

I never use a delay longer than 5 minutes. And even then if it’s something that is critical I take other steps to ensure a restart/reload doesn’t stop the action from running when needed.

1 Like

OK good, at least I’m heading in the right direction. It didn’t come on this morning but I think it was because I had both automations turned off (that slider switch on the left side). Anyway I’ll give it another go tonight.
Many thanks.

2 Likes
alias: example
trigger:
  - id: 'on'
    platform: time
    at: '04:30:00'
  - id: 'off'
    platform: time
    at: '10:30:00'
condition: []
action:
  - service: 'switch.turn_{{ trigger.id }}'
    target:
      entity_id: switch.espresso
1 Like

I have so much to learn. Pretty daunting as this is pretty simple yet I haven’t a clue.

I am having fun though.

1 Like

The automation contains two Time Triggers.

  1. The first one is given the name on (by setting its id option to on) and is set to trigger at 04:30 (representing when to turn on the switch).

  2. The second one is given the name off (by setting its id option to off) and is set to trigger at 10:30 (representing when to turn off the switch).

The automation’s action contains a single service call to control the switch. The service call can be either switch.turn_on or switch.turn_off.

A template is used to choose which one of the two service calls will be used. The template simply uses the id value of whichever one of the two triggers was responsible for triggering the automation.

For example, if the first trigger had triggered the automation, its id is on so the resulting service call will be service.turn_on.

You can use either two automations to keep it simple for now or you can use the example from Tara above that is more complex because it introduces the concept of “templates”.

either way will work but I usually suggest the easier method to new users until they get their footing and can then move to more advanced techniques.

Thanks all. It makes a little more sense now.

I read that it’s recommended to start with Blueprints and then, when comfortable, move on to Automations. Make sense? I haven’t looked at Blueprints at all.

Can you post a link to where you read that? I’d like to see the reasoning for that advice.

Largely because it’s the reverse order of what you must learn; automations can exist without blueprints but blueprints exist exclusively to generate automations.

I read it here. I kind of wondered about that.

I see. The advice is not to learn about creating blueprints first, but to use one that may already exist to produce the result you want.

There’s a library of blueprints here, Blueprints Exchange, containing submissions by community members to generate automations for common applications.

The issue with blueprints is that there are very specific and purpose built.

If you have custom requirements (extra trigger, less conditions, one different action instead of another) then they won’t work for you.

it’s better to start with basic automations and learn how to create those (and even creating them from the UI at first is OK but aim to graduate from the UI as you learn more yaml) then move on to templating and more advanced automations.

You can use blueprints as a quick interim measure if you find one that meets your exact situation but you are going to want to learn to write things yourself if you want to start doing the more advanced stuff that HA offers.

Thanks, I’ve looked through the exchange but didn’t see exactly what I was looking for so I used the UI for my first one.

Yes, using the UI is what I finally did for my first simple one and it worked! This is going to be fun.

Thanks for the advice.

1 Like