Light group should not switch all lights

I have created a light group to be able to control these lights with a single switch:

light:
  - platform: group
    name: Kitchen lights
    entities:
      - light.kitchen_table
      - light.kitchen_sink
      - light.kitchen_led

I now have an additional (parent) light, which switches all three lights (children) on and off with a single click. Great!

However, what I do not want is that when I switch on an individual child, the parent switches on, switching on the other children as well. But that is what happens.

Is there a possibility to prevent this behaviour?

Expected behaviour is:
Turn on/off parent: all children switched on/off
Turn on/off child: only the child is switched on/off, nothing happens to the other children.

What you descrbe as the expected behaviour is how my system works.

1 Like

Yep same here.
Do you have any automations triggering when the group state changes to on.
When any of the children is switched on, the parents state will become on, but this won’t cause other children to be switched on.

@samnewman86 yes, that’s it. Marking this post as the solution, but credits to you :slight_smile:

I have the following automation:

alias: AUT_LIGHTS_KITCHEN_ON
description: Set brightness when switching on Kitchen lights.
trigger:
  - platform: state
    entity_id: light.kitchen_lights
    to: 'on'
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: 50
    target:
      entity_id: light.kitchen_table
  - service: light.turn_on
    data:
      brightness_pct: 25
    target:
      entity_id: light.kitchen_sink
mode: single

Whenever the group is switched on, children are set to a certain dim level.

Apparently, switching one child, switches the whole group. It then does not directly switch the children, but it does via the automation. Still doesn’t sound right, but I guess I’ll have to build the automations on individual switch level to work around the issue.

If you switch from using the light group to a regular group (instead of defining the group in the light domain, define it in the group domain), then you can set all: true in your yaml. This way, the group will only be on when all devices are on and off when all devices aren’t on.

group:
  - name: Kitchen lights
    all: true
    entities:
      - light.kitchen_table
      - light.kitchen_sink
      - light.kitchen_led

The only benefit to using a light group over a normal group is that you will see RGB attributes if you have a color bulb in a group of mixed bulbs. If you switch your trigger to the following, it should work as you expect; When ALL lights are on, then it sets the brightness to the child devices.

trigger:
  - platform: state
    entity_id: group.kitchen_lights
    to: 'on'

Good addition, Bill.

However, I actually like the group switch being switched on whenever a child is switched on, as it allows me to switch everything off with one click on the group button (I also happen to have an All Lights switch, which has the other groups nested in it).

I’m sure I’ll play around with it some more…

1 Like

It seems like what you’re using that automation to achieve would be better using the scene functionality.

I haven’t used scenes yet.
It looks like they work on device level and I don’t know what happens when you add a device that has multiple entities you want to switch separately (e.g. Z-Wave double switch or RGBW device).
Plus I want to have a group to call via Alexa anyway (‘Alexa, turn Kitchen on’).
So having a group and an automation per device to set the right brightness level each time it is switched on does the trick for me.

You can place the turn_on service all inside a chooser to make it only execute when the light is on. Or, just pour it into a script to make it easy to use:

light_brightness_pct_when_on:
  alias: Set light brightness percentage when on
  fields:
    brightness_pct:
      description: Brightness percentage to set when light is on
      example: 80
    entity_id:
      description: Entity id of the light
      example: light.dining_table
  sequence:
  - choose:
    - conditions:
      - condition: template
        value_template: "{{ states(entity_id) == 'on' }}"
      sequence:
      - service: light.turn_on
        target:
          entity_id: '{{ entity_id }}'
        data:
          brightness_pct: '{{ brightness_pct }}'
    default: []
  mode: single

Now you can use it just like:

id: AUT_LIGHTS_KITCHEN_ON
alias: Auto lights kitchen on preset
description: Set brightness when switching on Kitchen lights.
trigger:
  - platform: state
    entity_id: light.kitchen_lights
    to: 'on'
condition: []
action:
  - service: script.light_brightness_pct_when_on
    data:
      brightness_pct: 50
      entity_id: light.kitchen_table
  - service: script.light_brightness_pct_when_on
    data:
      brightness_pct: 25
      entity_id: light.kitchen_sink
mode: single

Yeah, there are different ways to the same result. I have 5 lights in 3 groups that need to be dimmed, so it’s either 3 scripts nested into 3 automations or 5 automations to do it directly.

Anyway, the original issue where the automation triggered lights that should not be triggered is resolved.

Thanks all for thinking along.

Corrected, because that’s the beauty of a script :wink: Aka, you need only 1 script plus an automation per light group.