Moving .yaml file into subfolder fails

I have moved light groups out of config/configuration.yaml into config/light_groups.yaml. This works.

However when I move the file into a subfolder (config/include/light_groups.yaml) it stops working.

light_groups.yaml

- platform: group
  name: 'KitchenLights'
  entities:
    - light.kitchen_ceiling_1
    - light.kitchen_ceiling_2

configuration.yaml

light groups: !include light_groups.yaml

this works when light_groups.yaml is in the config folder.

configuration.yaml

light groups: !include include/light_groups.yaml

this does not work when light_groups.yaml is in the config/include sub-folder. I have tried with and wthout a preceding ./

The error is:

expected a dictionary for dictionary value @ data['packages']['light_groups']

Any thoughts? I’ve been going round in circles for a couple of hours. The error isn’t particularly helpful but is maybe suggesting it cannot find the file?

Try this:

light groups: !include ../include/light_groups.yaml

Hi Tom. This gives me:

Error loading /config/configuration.yaml: in "/config/configuration.yaml", line 40, column 15: Unable to read file /config/../include/light_groups.yaml.

which is a different error and suggests that the original problem is not that it cannot find the file. In that case I don’t understand why would the same file work when in same folder but not in a subfolder?

What about this?

light groups: !include_dir_merge_named /include

Thanks Tom. I get the original error again:

expected a dictionary for dictionary value @ data['packages']['light_groups']

However I also intend to split out automations, scripts etc into files in that same folder so not sure that including the merging the directory contents into light groups would work anyway.

I use the following statement to include a subdirectory with light groups in it

light: !include_dir_list ../entities/lights

inside the …/entities/lights directory are multiple .yaml files. Each yaml file looks like the following:

---
# Light group: 
#
# Combines all lights in the x into a single entity.
#
# https://www.home-assistant.io/integrations/light.group/
#
platform: group
name: All Master Bedroom Lights
entities:
  - light.master_lamp_bulb
  - light.master_tall_lamp_bulb
  - light.master_ceiling_bulb_1
  - light.master_ceiling_bulb_2
  - light.master_ceiling_bulb_3

Hope this helps.

Groups aren’t a list like lights. You have to use:

!include_dir_named

I followed the method frenck used in splitting up his configuration and it works fine for me. Take a look at his github…

https://github.com/frenck/home-assistant-config/blob/bcdd855bd54f91400fa4634d3d5063bd22f17d18/config/integrations/light.yaml

and

https://github.com/frenck/home-assistant-config/blob/bcdd855bd54f91400fa4634d3d5063bd22f17d18/config/entities/lights/bathroom.yaml

Granted was a bit more complicated to setup, but I find it works well.

Now take a look at what he has for groups:

# Groups allow the user to combine multiple entities into one.
# This loads up my custom created groups
#
# https://www.home-assistant.io/integrations/group/
#
group: !include_dir_merge_named ../entities/groups
                        ^^^^

Groups are a dictionary. Lights are a list.

Thanks both. I’ll review the links.

I had followed this https://www.home-assistant.io/docs/configuration/splitting_configuration/#advanced-usage

However as well as the issues I am having here, it also rejected my yaml filenames with “-” in the filename (e.g. light-groups.yaml) and I had to replace with “_”. Not sure if that is a recent change to HA that it no longer accepts the dash. I was getting the error:

invalid slug light-groups (try light_groups) for dictionary value @ data['packages']

can you help me your suggested understand the use of ../ here?

my folder set up is:

/config/configuration.yaml
/config/include/light_groups.yaml
/config/include/automations.yaml
etc

So in configuration.yaml, use of ../ would suggest the parent of /config? So a structure such as:

/config/configuratin,yaml
/include/light_groups.yaml

Am I missing something?

So, the configuration I based mine on has subdirectories for different pieces of the config. Inside one of those subdirectories it uses the …/ to go up a directory and then down into another one.

You don’t need to use the …/ in your path, that is just the setup I have. I didn’t mean to confuse with the …/ in the paths, I was just trying to show how my config includes light groups and the format of the yaml. As tom_l pointed out that is probably an artifact of the structure I am using and you should follow his suggestion instead. I am certainly not an expert on any of this.

Got it. Thanks Christopher.

Maybe I’m missing something here but why does it have a reference to “packages” in that error?

I don’t see any reference to any packages in your code you posted.

Maybe the indentation is wrong somewhere else and it thinks you are trying to configure a package instead of a group?