Automation vs Script

Hello all,

I’ve got some basic controls and sensors programmed up and it’s working great. I can turn things on and off from my smartphone or computer. I can observe door open/closed conditions. I even have remote access via a VPN but, I would like to set up a couple rules. Something like if/when/then.

I should also say that I have Hassio installed on my synology DS918 NAS. Working wonderfully and 100% stable thus far.

I’ve been poking at this for awhile now but I’m must be missing something fundamental. What is the difference between script and automation? I have a folder for each (automation.yaml and scripts.yaml).

I’ve tried to use the little tool in the “Configuration ->Script” page and it does seem to load line entries into the scripts.yaml document. I’ve also tried to hand configure the same into the automation.yaml document but nothing seems to work.

Should I be using one or the other or do they work together?

At this point, all I’m trying to do is have my light group to be turned off at 0500 in the morning. Nothing real fancy yet.



Scripts are called manually, either by clicking them on the front end or calling them in an automation.

Automation have a trigger which allow them to happen automatically.

Automation can call scripts as part of the action. This is useful if you have a complex action that you want to call in multiple automation. It saves entering the actions in each automation. Additionally if you need to update that action you update it once in the script and all of your automation would be automatically updated.

This is my understanding of scripts vs. automations and how I use them. I’m sure others will chime in.


If I have a sequence of events, especially with multiple or long delays, I’ll generally make them scripts.
Scripts can be stopped once started by calling the service script.turn_off

Once an automation has started, it can’t be stopped until it has run its course.
Calling the service automation.turn_off will only stop the auto from triggering. It wont stop an already running automation.

Also, scripts, like automatons, can have conditions.


OK, just so that I’m clear I would use scripts to say;

Script #1 - Turn on all outside front lights
Script #2 - Turn on all back yard lights
Script #3 - Turn on all inside lights

Automation #1 - At 8 PM run script #1
Automation #2 - When I come home after dark run script #3
Automation #3 - If motion detection triggered when I’m away run Script 1, Script 2 and Script 3

Is that effectively the intended interaction?

Also if that’s the case then, it seems the automation need to be done in the .yaml file while the scripts can be done in the user interface.

Thanks very much.

1 Like

For the instances you mentioned above I would use groups. Groups have the advantage of having a on and off control on the front end (like a switch) and are my preferred method for lights. They can also be called to turn off the same set of lights, something a script cannot do. Scripts are on or off, not both. (unless you got into some complex templating in which case the Group is still much easier)

In the automation you would call the outside front lights group to be turned on.

Automations can be done in the front end also, I have never used it though. I started with HA before the option was available and automation created in the front end are not easily readable to me if I need to troubleshoot.


Thank you very much for question an answer