brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: packages group everything for one feature in a single Home Assistant YAML file

Yaml
~/tips/tip-home-assistant-packages-include-dir-named

packages: !include_dir_named packages

Puts the sensor, helper and automation for one feature in a single YAML package file.

A configuration split by type means the sensor, the automation and the helper for one gadget live in three files. Packages turn that around: one file per feature.

The docs show the setup in the main configuration.yaml:

homeassistant:
  packages: !include_dir_named packages

With !include_dir_named the file name becomes the package name, and the content of each file sits directly under that name, indented as it would be inside the packages: key. So packages/garden.yaml can hold the sensor, the helper and the automation for the garden together.

Merging has rules. Platform-based integrations such as light and switch can always be merged. For integrations keyed by entity ID, the keys must be unique between packages and the main configuration, so you cannot define the same input_boolean in two places. Other integrations merge only if each key, apart from list keys, is defined once.

Caveats from the docs: because the file name is the package name, names must be unique across all subfolders. Inside packages, platform entries must use the style where platforms are grouped under the integration name. And auth_providers has to stay in configuration.yaml, since it is processed before packages load.

Run the configuration check before you restart. A duplicate key between two packages is easy to make.

Further reading: Packages (Home Assistant documentation)

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Yaml tips yamllint -f parsable config.yaml yamllint -d relaxed docker-compose.yml iif(condition, if_true, if_false, if_none) Sensor is available Today_at() makes time-of-day checks in Home Assistant templates easy All Yaml tips (10) All topics

Link