YAML directory include gone?

I just discovered a strange problem and I’m not sure why or when it happened.

My configuration was as follows:

  • configuration.yaml → had automation: !include automations.yaml
  • automations.yaml → had !include_dir_merge_list automations_yaml plus a couple random test automations
  • lots of separate YAML files with organized automations

For some unknown reason, it looks like everything was unexplicably merged into automations.yaml without my consent or knowledge so it now ignores the directory of YAML.

Anyone seen this before?

automations.yaml is automatically managed by UI. You’re not supposed to put additional things there.

1 Like

Use a separate automations.yaml for your non-ui stuff such as automations_coded.yaml or something

1 Like

Try

automation: !include automations.yaml
automation mine: !include_dir_merge_list automations_yaml/
1 Like

Interesting. This seemed fine for a few years, is that a new change I missed?

It looks like that works but I’m a little confused why. How is automation mine: not a syntax error? I thought the keyword had to be automation:?

Are there any other files that are “gotyas” now? groups, sensors, binary_sensors other includes?

Here’s what I presently have after moving that include from the automations.yaml into the configuuration.yaml with the extra “mine” word:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Some userful files to add for organization
binary_sensor: !include binary_sensors.yaml
sensor: !include sensors.yaml
automation mine: !include_dir_merge_list automations_yaml

# This allows for combined groups in one file
# with sections for group, automation, script, scene, sensor, etc
homeassistant:
  packages: !include_dir_named packages_yaml

My ultimate plan is to finish migrating everything to packages YAML but that takes time and its working now…and when I do that migration I will want to improve the maintainability rather than just throwing the automation: prefix in the files and have it better grouped/organized similar to software development class files and encapsulation of functionality

here is the documentation for that particular case:

It also works for the script and scene !includes as well. I’m pretty sure that will work the same with any top level key.

but it’s specifically given in an example for automations because the biggest reason that it’s used for automations etc is because those are the big ones that can be created via the UI or yaml depending on the location where the code is stored.

you can manually edit the yaml of those default !includes as well but the downside is that as soon as it’s saved it will reformat the yaml to the standard format that the UI uses in the background. And it removes all comments too. that is a big downside for many advanced users.

Ah ok, I wasn’t aware that’s where the UI saved it.

And yeah - removing of comments has been a major complaint I’ve had as stuff has been migrated from YAML to UI…for example I had a bunch of PING sensors with verbose comments split up by functionality in different YAML files. The migration of PING sensors to UI eliminated a way to have them neatly grouped and having comments. I ended up rewriting them all as command line sensors to work around that but wasn’t happy with that change.

I’m a software engineer (Java/C++ mainly) so as much as I hate Python/YAML whitespace-matters syntax the “code” is much more intuitive and friendly to me than struggling to connect the dots with a GUI and mouse clicks.

1 Like