Light Group configuration error

Hello all, I need some help! On the file
config/groups.yaml

which was previously empty, I have set up this as a way to create a group from three lights
here is my code:

light:
  - platform: group
    name: Downtown
    entities:
      - light.bedroom1_level_light_color_on_off
      - light.bedroom2_level_light_color_on_off
      - light.bedroom3_level_light_color_on_off

but when I go to the Configuration validation button in Server control I get this message:

Invalid config for [group]: value should be a string for dictionary value @ data['group']['light']['entities']. Got None. (See /config/configuration.yaml, line 8).

what am I missing here?

It doesn’t belong in the groups.yaml file.

It belongs in the configuration.yaml file or whatever file you are using to store all your light configurations.

1 Like

I just went about setting this up myself this morning! I put all of my light groups into a dedicated “light groups” file. Below is an example for my bedroom lights.

light-groups.yaml

- platform: group
  name: Bedroom Lights
  entities:
    - light.bedroom_bed
    - light.bedroom_floor_1
    - light.bedroom_floor_2
    - light.bedroom_wall

Then, in my configuration file, I include it as shown below.

configuration.yaml

light groups: !include light-groups.yaml

This has been working well for me! The light group will show up as an entity that you can control through scripts with the light.turn_on/etc. service.

1 Like

It shouldn’t be.

It needs to be under the light: entry in your configuration. No such thing as light groups:

I suspect home assistant is ignoring everything after the space. Spaces are not allowed in keys.

Check your log for errors.

See: Group - Home Assistant

It might be a variation of this technique:

automation manual: !include_dir_merge_list automations/

That’s how I separate the automations I create manually from the ones created via the Automation Editor. Notice the space between the two words. The first word matches a domain (automation) and the second one is user’s choice. Although I have never tried that technique with anything else, it probably works for other domains.

Although in this case, the problem is simply the data is in the wrong file. It doesn’t necessarily need its own file, just needs to go wherever all existing light entities are defined.

1 Like

It’s perfectly valid to use something like:

light: 
- platform: whatever
...
light aperson:
- platform: on_fire
...
light keepwarm:
- platform: forever
...

That’s a method I use for splitting up the UI automations (of which I have none), and my own manually created ones.

1 Like

Who do I listen to? :slight_smile: you or @tom_l ?

I copied that syntax exactly from the Home Assistant documentation for separating the configuration file into multiple configuration files. Here’s the code snippet from that document:

light:
- platform: group
  name: Bedside Lights
  entities:
    - light.left_bedside_light
    - light.right_bedside_light

# define more light groups in a separate file
light groups: !include light-groups.yaml

# define some light switch mappings in a different file
light switches: !include light-switches.yaml

Just restarted and no errors in the logs.

1 Like

Tom is misunderstanding yaml fields and how they work. It’s 100% valid to have 2 light sections if you add a tag to the field:

light: 
  ....

light mysuperlightsection:
         ^
        tag
  ...

EDIT: I should clarify that this method doesn’t work for every section. Some sections in the configuration are “special”. However 95% of them will work with this method. Only one off the top of my head that doesn’t work with this method is scripts.

2 Likes

@123, can you expand on what the second word accomplishes? If I had to guess, you’re not allowed to have multiple “automation” entries. By adding the second word, you’re telling Home Assistant that this is an “automation” type, but not the same as the previous one you’ve done. The second word acts almost like a comment.

Is this reasonably accurate?

1 Like

That’s all it does, and it’s not a comment it’s a unique identifier. You cannot have 2 of the same unique identifiers.

This will result in you only getting the second blah, and the first blah is ‘missing’. Because the second one will overwrite the first.

automation:
automation blah:
automation blah:  # OVERWRITES THE PREVIOUS BLAH
3 Likes

petro has already explained that the second word is an identifier that serves to distinguish one key from another.

BTW, the post you marked as Solution doesn’t explain why you encountered the problem. In fact, it proposes a solution that is designed to serve an entirely different purpose (organizing your system’s configuration by splitting it into separate files).

For the third time, the reason why you got the “Invalid config” message was because you put the light group configuration into the wrong file.

Light Group is the name of the integration but the entities it creates are members of the light domain. Look at the first line in your configuration and you’ll see it contains the word light: . That’s the domain for everything that follows it and you put it all into a file designed to hold groups (group is a different domain).

The easiest fix was to simply move it wherever you currently define light entities which may very well be configuration.yaml. Moving all light entities them to a separate file is completely optional and not mandatory to solve the core problem.

1 Like

TIL