Changing color of a light group without turning lights on that are off?

I have multiple lights in my living room that are in a light group. Sometimes I want to change color or brightness of all the lights that are currently on. When I use the group to modify the lights, ALL the lights in that group turn on. I don’t want that - lights in the group that are off should remain so, and only the ones that are on should change color or brightness. Is there any way to achieve that?

One way would be to use a filter that expands the group and only selects those lights that are currently on:

  entity_id: >-
    {{ expand('light.my_light_group') 
      | selectattr('state' ,'eq' ,'on') 
      | map(attribute='entity_id') 
      | list }}

Thanks for pointing me in the right direction. Here’s my solution.

First, I created a light group containing all the lights I wanted to be able to control and named it ALL_LIGHTS.

Then, I created this automation:

alias: Expand light group
trigger:
  - platform: state
    entity_id:
      - light.smart_bulb_1
  - platform: state
    entity_id:
      - light.smart_bulb_2
  - platform: state
    entity_id:
      - light.smart_bulb_3
  - platform: state
    entity_id:
      - light.smart_bulb_4
action:
  - service: group.set
    data:
      object_id: active_lights
      entities: |-
        {{ expand('light.all_lights') 
          | selectattr('state' ,'eq' ,'on') 
          | map(attribute='entity_id') 
          | list }}
mode: queued
max: 10

This creates a group called group.active_lights. I can put this on my dashboard and it allows me to control color and brightness of all the lights that are on, restricted to those within the group ALL_LIGHTS, which is exactly what I wanted.

A note on the triggers. First I tried to use a state trigger that only watches for changes in the state of all_lights, but obviously this doesn’t work because the state only changes from off to on when one of the lights in the group is turned on. It doesn’t change when you turn on more lights, so this is not a sufficient trigger to update the dynamic group every time an additional light is turned on. I’m sure there’s a more elegant solution, but for now it works fine.

This method works fine on things like more-info but not with sliders I am afraid. The tile card or mushroom light card requires a light entity not a group entity. Only group options that is accepted are the ones made from the helpers section. I was planing to use this with a light slider but I guess it is not possible within Home Assistant.

So what’s the official method for this now? Because this automation makes use of the old-style groups and from what I can tell not even a template light will take a filtered list of “on” lights.

Yeah, this seems very clunky and limiting.

I migrated over from the Hue bridge. With the Hue API I was able to send a command to a whole group of lights at once to change their brightness or temperature and as long as I didn’t have “turn on” as part of that command, those which were on would update and those which were off would stay off.

I’m really surprised I can’t do that through HA.

As far as I can tell I either have to live with all the lights turning on, or I have to expand to the individual lights, filter to those which are on, and then have the message sent to those. But this means all those messages go out separately, which might be too much for my zigbee adaptor to handle, messages might get lost, and they certainly won’t all change in sync.