Using Packages demands a Platform Key

This is how packages are created when not using includes

#configuration.yaml
homeassistant: 
  packages: 
    name_package_1:
      automation: []
      script: {}
      template: []
    name_package_2:
      automation: []
      script: {}
      template: []
    name_package_3:
      automation: []
      script: {}
      template: []

Option 1

homeassistant:
  packages: !include_dir_merge_named packages_folder/

When you include packages like this, each file contains one or more dictionaries with the package contents. So you could put multiple packages in one file if you want.

# packages_folder/file1.yaml
name_package_1:
  automation: []
  script: {}
  template: []
name_package_2:
  automation: []
  script: {}
  template: []
# packages_folder/file2.yaml
name_package_3:
  automation: []
  script: {}
  template: []

Option 2

homeassistant:
  packages: !include_dir_named packages_folder/

When you include packages like this, each file contains the contents of only one package, and the package name is taken from the filename

# packages_folder/name_package_1.yaml
automation: []
script: {}
template: []
# packages_folder/name_package_2.yaml
automation: []
script: {}
template: []
# packages_folder/name_package_3.yaml
automation: []
script: {}
template: []

Both options above result in the config without the includes

Also see:

2 Likes

Well, huh.

I’ve been using packages for years and never realized there were two different config options.

Learn something new every day.

Thanks guys.

1 Like

Thank you TheFes, and other contributors.
I have been using packages for a couple of weeks, not easy, but now I am learning fast.
I am still confused about best practice!!
I think there is a THIRD option which is what I have stumbled into using…
The include statement syntax is: “packages: !include_dir_merge_named packages_folder” and this usage requires the name-package-x to be the first statement in the package YAML file.
What is the guidance for choosing between Option 2 and Option 3?
The documentation referred to, discusses FOUR options for the syntax of the include statement - this confuses me even more!

That’s option 1 described in my post above.

The other two included mentioned in the documentation are for lists, not for mappings/dictionaries. There are also two options there.

There is not really a best option, it depends on personal preference and also on the situation.

dont this was mentioned yet, but the. using the

homeassistant:
  packages: !include_dir_named packages

option in your configuration.yaml, you can drop (package) files, but Also folder in there. those nested folders can contain yet more (package) files, so you have an even more fine-grained organization of your packages:

as ‘personal confession’ : I’ve always found this method to be most straightforward an therefor easiest, because you can (need to) maintain the exact same platform hierarchy inside those (package) files as they are described in the documentation (as if you would configure everything in the configuration.yaml)

As I read it, your option 1 uses “include_dir_merge_list” whereas the THIRD option I refer to uses “include_dir_merge_named”.

Sorry, I messed up, option 1 should have been !include_dir_merge_named. I fixed that now.
!include_dir_merge_list is for lists/arrays