How to use !include correctly?

I am VERY new to HA but not new to code. I was happily about to set up my own helpers in YAML as I don’t see a clear way to set up a “mixed type” from the UI. And I come from the frontend dev world and live in a clean well ordered tree structure. I wanted to set up my groups and scripts like so:

/config
├─ configuration.yaml
├─ groups/
│   └─ rooms.yaml
├─ scripts/
│   └─ room_toggle.yaml

configuration.file:

default_config:

group: !include groups/rooms.yaml

...

In the rooms.yaml file I have tried a few set ups. setup 1:

office:
  name: Office
  entities:
    - light.office_floor_lamp

Set 2:

name: Office
entities:
  - light.office_floor_lamp

I have made sure that I’m not going mad and the file is in the correct location:

/homeassistant/config/groups/rooms.yaml

Understanding that Apple is odd about the pathing’ so the use of “!include” is resolving that, why is it that I constantly get thrown this error?

Error loading /config/configuration.yaml:   
in "/config/configuration.yaml", line 23, column 8: 
Unable to read file /config/groups/rooms.yaml

Thanks for any advice in advance.

What does this have to do with Apple?

Change this:

To:
group: !include_dir_named groups/

Then use your setup 1 in groups/rooms.yaml

office:
  name: Office
  entities:
    - light.office_floor_lamp

See here for more:

However…

There is no mixed group helper except for the old legacy groups (YAML only) and you really should not be using legacy groups if you can help it. Have a look at packages instead.

2 Likes

In addition to Tom’s comments above, consider using Labels to “group” entities from different domains instead of the legacy groups. Labels are already target-able in actions, have a host of template functions, and their utility is sure to expand as the new “purpose-specific triggers and conditions” are built out.

5 Likes

Appreciate that @tom_l, literally an hour after I posted this saw where I was I was going wrong with the path, changed it and it was a me issue not Apple hating us, so I applogise to Apple. But the:

!include_dir_named

… this was new to me and will update my code to use that.

As for the mixed groups I didn’t realize that’s what I was actually doing but its kinda obvious when you look at it! So I’ll look over the packages and reconfigure.

Sweet! I will make sure to add this in as well. Appreciate your help boss :slight_smile: