Help getting started with automation scripts

Hello everybody,

I’m very new to Home Assitant - coming from Domoticz.
I used to configure all my automation on Domoticz using blocky wich was very easy and user-friendy and i’m having a hard time to understand how to migrate my automations.

I did have read the doc on automation but still do not understand how to reach my goal :frowning:

If my understanding is good, i’ll have to deal with scritps: every automation that i want will be placed in a file called script.yaml.

What i’m trying to get is something like this but i dont understand how to deal with the if / or / else.
What this exemple would looks like transposed in yaml?

Sorry if it may sounds idiot :slight_smile:

Looking forward for your help!

Regards - JS

No this is not true. Scripts and automations are different.

Automations - triggered by something, (with optional conditions), they then perform a list of actions.

Scripts - perform a list of actions (with optional conditions). No trigger for scripts. They can be called manually or as an action (service) from an automation.

There is also now a device oriented graphical automation editor. Select one of your devices from the Configuration / Devices menu, then:

Thanks for your clarifications about the differences between the automations and script

So, in order to achieve what i want, i need a combination of both.
Every automation that i create should call a different script.

What would the script looks like with the example in the first post?

1 Like

Automations contain a list of actions. No need for a script, unless you are repeating the same list of actions in different automations. Then you could use a script to reduce duplication.

automation:
- alias: automation1
  trigger:
  - platform: some_platform
  conditon: [] # optional
   action:
   - service: blah
   - service: blah
   - service: blah

- alias: automation2
  trigger:
  - platform: some_platform
  condition: [] # optional
   action:
   - service: blah
   - service: blah
   - service: blah
   - service:  something_else

or

automation:
- alias: automation1
  trigger:
    platform: some_platform
  condition: [] # optional
  action:
  - script.blah

automation:
- alias: automation2
  trigger:
    platform: some_platform
  condition: [] # optional
  action:
  - script.blah
  - service: something_else

script:
  sequence:
  - service: blah
  - service: blah
  - service: blah

Thanks for your answer, but i still dont get how it works as “blah” is a bit generic :slight_smile: and, for exemple, how the condition for time is set in your demonstration?

It looks very clear for you but for me it still looks like black magic xD

Well I was trying not to confuse you with all the services available. Read the docs for the services you want to call, for example to switch a light on:

action:
  - service: light.turn_on
    entity_id: light.your_light

Time condition: https://www.home-assistant.io/docs/scripts/conditions/#time-condition

Thanks for your time and help!

Really appreciate

You will also find this useful for the types of automation triggers available: