I actually created a template light to do just that for someone on Facebook yesterday
color_temp can be added as well, but that’s a bit more tricky as the min and max can vary between lights in the group
# Template light which uses a light group, but only adjust the brightness of the lights which are on
# Change object_id on line 8 and friendly_name on line 9
# Change all references to 'light.groep_speelhoek' to your own light group
light:
- platform: template
lights:
template_play_area:
friendly_name: "Template Play Area"
level_template: >
{% set group = 'light.groep_speelhoek' %}
{{
expand(group)
| selectattr('attributes.brightness', 'defined')
| map(attribute='attributes.brightness')
| list
| default([0], true)
| average
}}
value_template: "{{ is_state('light.groep_speelhoek', 'on') }}"
turn_on:
- service: light.turn_on
target:
entity_id: light.groep_speelhoek
turn_off:
- service: light.turn_off
target:
entity_id: light.groep_speelhoek
set_level:
- service: light.turn_on
target:
entity_id: >
{% set group = 'light.groep_speelhoek' %}
{{
expand(group)
| selectattr('attributes.brightness', 'defined')
| map(attribute='entity_id')
| list
}}
data:
brightness: "{{ brightness }}"