As my number of automations are growing and the number of lines in automations.yaml are getting out of hand I started to look for a way to get more control of my automations. My conclusion was that I wanted to divide the automations.yaml into multiple files, or rather one file per automation. This way it is much easier to locate and edit a specific automation.
This is how I did it.
First I created a folder named automation in my \config directory and then in my configuration.yaml I added the following line of code.
After reboot I added my first automation in the config\automation folder. More specifically in the file lights_off_1930.yaml. Of course any filename can be used but I like a filename that describes the function.
Note: It is important that the - id: '<number>' is removed from the automation if it is present. If automations were created using the hass.io web interface the id is created to support that method. When implementing automations as described above the id must be removed.
Recommended: For more information on automations please refer to my previous post.
Recommended: One way to confirm that the automations has been added properly to hass.io is to use states.
Please let me know in the comments field if you have any questions or comments.
Figure 1. Divide and conquer your automations by using one file per automation. |
This is how I did it.
First I created a folder named automation in my \config directory and then in my configuration.yaml I added the following line of code.
automation: !include_dir_list automation
At this point it was good to run Configuration Validation to see that everything was correct. Since my code passed the validation I rebooted hass.io for the changes to take effect.After reboot I added my first automation in the config\automation folder. More specifically in the file lights_off_1930.yaml. Of course any filename can be used but I like a filename that describes the function.
alias: lights off 1930
trigger:
- at: '19:30'
platform: time
action:
- data:
entity_id: light.ted_fonster
service: light.turn_off
- data:
entity_id: light.ted_byra
service: light.turn_off
At 19:30 this automation turns off two light sources.Note: It is important that the - id: '<number>' is removed from the automation if it is present. If automations were created using the hass.io web interface the id is created to support that method. When implementing automations as described above the id must be removed.
Recommended: For more information on automations please refer to my previous post.
Recommended: One way to confirm that the automations has been added properly to hass.io is to use states.
Please let me know in the comments field if you have any questions or comments.
Comments
Post a Comment