Sharing common config packages among multiple HA instances

I have 3 instances of HA running in different houses. Most of config items are organized as packages. Some subset of the packages is common across all 3 instances, so I separated them out into a “common” packages folder. All three instances could then be hosted in a single common config repo, each instance using its own packages folder and hopefully getting the common part too.

Now, the problem is how to combine two folders, one with the instance-specific and one with the common packages, into one folder. Preferably, without copying of the contents.

I tried putting a symlink to the common folder inside each instance-specific package folder. No luck. HA does not follow the symlink to the common folder. What i had was:

# Files / folders:
packages/common:
   various_common.yaml

packages/site1:
   common -> ../common
   various.yaml

packages/site2:
   common -> ../common
   various2.yaml

# Config of site 1:
packages: !include_dir_named packages/site1

# Config of site 2:
packages: !include_dir_named packages/site2

OS follows such a symlink fine, but HA basically ignores it.

I also tried telling HA to read two folders this way:

packages: !include_dir_named packages/common
packages two: !include_dir_named packages/site1

Also, does not work.

For now, I just copy packages/common to packages/site1/common and declare packages: !include_dir_named packages/site1 but this is very ugly.

Can you think of any better method for combining multiple folders into one for HA packages? Or maybe you know how to ask HA to read packages from two different folders?

Actually, I’d love to achieve more: compose the whole config dir structure from the common and the site-specific source dirs containing not only packages but also custom_components, python_scripts, lovelace panel configs, www, appdaemon apps etc, but let us start with a simpler problem :wink:

packages: !include_dir_named packages

Reads every subfolder in packages.
Isn’t that what you need?

Not exactly, since the “common” packages cannot be just a subfolder since they have to be shared across multiple configs, unless I am OK with copying the common packages around or using sub-repo technology which I am not. Hence the thoughts about symlink as a sub-folder but HA does not like following symlinks here.

I must have confused you with the statement of the problem. I have made it a little clearer in the OP, see the revised first paragraph in OP.

Oh, maybe what i need to solve all my config composition needs is a unionfs. Applied to just the goal of merging packages folders, it could look like:

homeassistant_config_common/
   packages/
      common_packages.yaml

homeassistant_config_for_site1/
   configuration.yaml
   packages/
      foo1.yaml

homeassistant_config_for_site2/
   configuration.yaml
   packages/
      foo2.yaml

Then unionfs applied to homeassistant_config_common and homeassistant_config_for_site1 would look like:

union_config_for_site1/
   configuration.yaml
   packages/
      foo1.yaml
      common_packages.yaml

And obviously this approach can combine all folders, not just packages. Home run!

I am not sure if unionfs is actually a realistic idea. Do you have any thoughts?

Is there a good pattern for this? It seems like the following DOES NOT recursively load yaml in subdirs:

homeassistant:
  packages: !include_dir_named packages

If the directory structure is:

/config
  |-- packages
  |      |-- folder1
  |      |-- folder2 (symlink back to /config/folder2)

In this case only yaml files in packages are loaded (and none from the subdirs). Various references seem to indicate include_dir_named is recursive, but it does not appear to be working.

Ideally I’d like to see something like:

homeassistant:
  packages:
     !include_dir_named shared/packages
     !include_dir_named packages