
* Update Packages folder - simplify Replacement/simplification of point I was trying to make in #26320. Not sure what happend to that one, I might have cocked up something so it got stuck;) have tried to simplify; - removed the option for !include_dir_merge_named from origninal doc, so now this is all about !include_dir_named - added info on this way of including keep indentation "as if written in configuration.yaml" The purpose of this PR is to be able to refer to documentation when urging people to use "packages-folders with the indentation of configuration.yaml" Currently I've seen several examples where they have read the documentation and set up with !include_dir_merge_named and having to keep up with different indentation than most examples that can be found in communities etc. * Update source/_docs/configuration/packages.markdown Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> * Update source/_docs/configuration/packages.markdown Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> * Update source/_docs/configuration/packages.markdown Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> * Update source/_docs/configuration/packages.markdown Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com> * Update packages.markdown added just a ' :) --------- Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
3.7 KiB
title | description |
---|---|
Packages | Describes all there is to know about configuration packages in Home Assistant. |
Packages in Home Assistant provide a way to bundle different integration's configuration together. With packages we have a way to include different integrations, or different configuration parts using any of the !include
directives introduced in splitting the configuration.
Packages are configured under the core homeassistant/packages
in the configuration and take the format of a package name (no spaces, all lower case) followed by a dictionary with the package configuration. For example, package pack_1
would be created as:
homeassistant:
...
packages:
pack_1:
...package configuration here...
The package configuration can include: switch
, light
, automation
, groups
, or most other Home Assistant integrations including hardware platforms.
It can be specified inline or in a separate YAML file using !include
.
Inline example, main configuration.yaml
:
homeassistant:
...
packages:
pack_1:
switch:
- platform: rest
...
light:
- platform: rpi
...
Include example, main configuration.yaml
:
homeassistant:
...
packages:
pack_1: !include my_package.yaml
The file my_package.yaml
contains the "top-level" configuration:
switch:
- platform: rest
...
light:
- platform: rpi
...
There are some rules for packages that will be merged:
-
Platform based integrations (
light
,switch
, etc) can always be merged. -
Integrations where entities are identified by a key that will represent the entity_id (
{key: config}
) need to have unique 'keys' between packages and the main configuration file.For example if we have the following in the main configuration. You are not allowed to re-use "my_input" again for
input_boolean
in a package:input_boolean: my_input:
-
Any integration that is not a platform [1], or dictionaries with Entity ID keys [2] can only be merged if its keys, except those for lists, are solely defined once.
Create a packages folder
One way to organize packages is to create a folder named "packages" in your Home Assistant configuration directory. In the packages directory, you can store any number of packages in a YAML file. This entry in your configuration.yaml
will load all YAML-files in this packages folder and its subfolders:
homeassistant:
packages: !include_dir_named packages
The benefit of this approach is to pull all configurations required to integrate a system into one file—rather than keeping them spread across several files.
You can use other !include
methods for packages; for example !include_dir_merge_named
. However, unlike !include_dir_merge_named
, the !include_dir_named
method uses the same indentation as the 'configuration.yaml'. This means that you can copy and paste elements from the config file. With !include_dir_named
, the file name is used as the package name. File names must be unique.
With the !include_dir_merge_named
method, the package name has to be included in the file. The configuration below then needs to be indented accordingly. This means you cannot directly copy and paste from the configuration file.
Customizing entities with packages
It is possible to customize entities within packages. Just create your customization entries under:
homeassistant:
customize: