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?
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?
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
# 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
^^^^
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']
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.