Light groups out of configuration.yaml

Is it possible to define light groups in groups.yaml? Or in any other file which doesn’t require HASS restart?

What are the differences between an light group and a group to make the first worth the attention?

with regards

1 Like

Yes. In your configuration.yaml, add group: !include groups.yaml (you’ll need to create groups.yaml first). Then, restart HA. After that, you’ll be able to reload groups without a restart. However, I think that if you have group: defined in your configuration.yaml, you don’t need to restart to load changes made to groups.

Light groups only allow for lights and offer features like dimming and color control whereas a generic group allows for anything to be grouped together. So, if you have 3 switches in a room and you want to control them all at the same time, or if you want to turn off an entire room using one group, you could add all the entities in that room to a group and control all of them at the same time.

room_switches:
  name: Room Switches
  entities:
    - switch.room_switch1
    - switch.room_switch2
    - switch.room_switch3
Office:
  name: Office
  entities:
    - switch.office_switch1
    - light.office_light1
    - light.office_light1

Yeah… but in HA documentation light group is defined in light domain, when other groups creates “group” domain.

From HA documentation:

# Example configuration.yaml entry
light:
  - platform: group
    name: Kitchen Lights
    entities:
      - light.kitchen_ceiling_lights
      - light.kitchen_under_cabinet_lights
      - light.kitchen_spot_lights
      - light.pendant_lights

group:

# Example configuration.yaml entry
group:
  kitchen:
    name: Kitchen
    entities:
      - switch.kitchen_pin_3
  climate:
    name: Climate
    entities:
      - sensor.bedroom_temp
      - sensor.porch_temp
  awesome_people:
    name: Awesome People
    entities:
      - device_tracker.dad_smith
      - device_tracker.mom_smith

I found no examples in documentation showing how to transfer those light groups to group.yaml. I know how to move common group. But I didn’t succeed with light group

anyone please?

Interested in this one too. I have created a lights.yaml file but can’t reload it without restarting HA.

Anyone have an answer on this one?

you (we) should be grateful that no programming is needed to create groups :wink:

1 Like

Following :upside_down_face:

Anyone figured this out yet?

Not sure what’s the question…

How to group lights in groups.yaml / lights.yaml?
groups.yaml:

  Dining:
    entities:
      - light.dinner1
      - light.dinner2
  Sofa:
    entities:
      - light.sofa1
      - light.sofa2

lights.yaml:

- platform: group
  name: Dining
  entities:
    - light.dinner1
    - light.dinner2
- platform: group
  name: Sofa
  entities:
    - light.sofa1
    - light.sofa2

Be aware when lights are grouped in the group domain you will not have a brightness slider (guess it is since version 0.116) but with lights.yaml I can use the ‘YAML configuration’ -> ‘reload groups, group entities, and notify services’ to get new groups recognized without restarting HASS.
Not sure if its the same with groups.yaml

It’s the name of integrations what might be misleading.
Groups are integration which allow to group entities in general.
Lights Group has nothing to do with groups integration (except of name). It creates a light which consists of other lights. The main difference is - as you already spotted - light group inherits light attributes from its members while general groups doesn’t.

Because light group is a light, it behaves like a light, it’s a member of light domain, it’s recognized by all sub-systems like a light and can be controlled by light service calls

Personally I found using light groups for lights more comfortable.

2 Likes

This is what I was struggeling with indeed, but this clears it up.

The problem I’m having now is that I have lights, switches and smart plugs (with a light plugged into it).
These are all lights, and I want them to all switch off when the house is empty. Of course I can group them separate and have 2 actions light.turn_off and switch.turn_off. Would it be possible to group these all in a entities group and turn them off in 1 action?

Nope. In an Automation you need two actions light.turn_off and switch.turn_off but I don’t see why this would be a problem.

I approached it the way: I made all smart switches which control lights to be declared as lights. For example all shelly relays, dimmers are configured as mqtt lights.

fair enough, that’s how I have it now and it’s working of course.

I’ve seen that you can change the entity to lights. But I didn’t knew if this would cause any problems. But reading your post it shouldn’t I guess.

I’m using it for year right now and found no any issues. But I have experience with Shelly devices integrated via mqtt (manual configuration) only. I don’t know how it is applicable for Shelly through native integration or for other integrations.