Splitting automation file

I tried to splitting my automation file, and it won’t execute.
The configuration doesn’t give any errors, it’s valid.
I tested it out with a notify action. When it’s just on the automation.yaml file, it will be executed. (so not splitted)
When It is splitted in automation/notify.yaml it won’t be executed. (splitted)
In config it is:
automation: !include_dir_merge_named automation

I think it should be dir_merge_list for automations.

Thanks, that was it…

On my scripts I used:
script: !include_dir_merge_named scripts

So yes, there is a difference between include dir merge named en include dir merge list.

Now it is:
automation: !include_dir_merge_list automation

1 Like

So, you have a main automation.yaml and then sub automation.yaml files? Does the last line go in the configuration.yaml or in the main automation.yaml? My file is huge and I really need to split it and the configuration.yaml files.

In your configuration.yaml

automation: !include dir_merge_list automation/

Then in the same directory as your configuration.yaml put a directory called automation.

Inside put a file for each automation, but without the word automation and without the leading hyphen

alias: some automation
trigger:
  platform: state 
  entity_id: light.sample 
  to: on
action:
  service: notify.notify
  data:
    message: "light is on!" 
1 Like

I suggest using packages

So, does this mean that I can create a file for notifies, trackers, lights and switches and they all get read in?

what do you mean by packages?

create a folder named: automation
Inside the folder you can have several yaml files. Eg; notify.yaml, profiles.yaml, etc…
Hass will merge the content of all the files to 1 into his library, so it will execute those, no matter in which file it is located. That is what inlcude dir merge list will do…

Yeah basically, and then packages goes one step further and integrates more than one component to create a device or a logical group.

My setup is now package based, but most people just use includes.

Check out the examples of in the cookbook (mine is in there too) :+1:

1 Like

Finally I managed to splitt the automations into files. And did not need to remove the leading hyphen (- alias: Smoke Sensor ).
I am on Home Assistant 0.60.1. and Raspberry Pi 3.

Be aware that you have to pull the power cord and do a total restart When I just restarted using "Hassio-Restart Home-Assistant ", I got all sort of error messages.

If you use include dir merge list, you don’t need to remove the hyphen, if you use merge named, you need to remove the hyphen, eg with scripts…

Also once you can split your files, its easy and organised…
So you can use eg:

automation: !include_dir_merge_list automation
script: !include_dir_merge_named scripts
sensor: !include_dir_merge_list sensors
etc…

spliting de automation then thye dont shows on GUI automations
at least last time i did that they dont show
why dont they fix that and make this possibility available sense everyone like to have all automations organized 1 by 1 :frowning:

1 Like

I noticed that when done with packages… the scripts don’t show on the script list or automation list, is that right? I only have one pkg for now.

Yes, that’s right. If you’re using packages you’re leaving the UI editors behind :+1: