Many thanks for your work and the code. This seems to solve a long-term problem of mine. But unfortunately it doesn’t quite work yet… I can control the group with the template light, but it behaves in the same way as with the normal light group. if I switch off a lamp in the group and then dim the group via the template light/group, the lamp switches on again.
Am I missing something?
Here is my code:
light:
- platform: template
lights:
template_lichtgruppe_arbeitszimmer:
friendly_name: "Lichtgruppe Arbeitszimmer"
level_template: >
{% set group = 'light.arbeitszimmer' %}
{{
expand(group)
| selectattr('attributes.brightness', 'defined')
| selectattr('attributes.brightness')
| map(attribute='attributes.brightness')
| list
| default([0], true)
| average
}}
value_template: "{{ is_state('light.arbeitszimmer', 'on') }}"
turn_on:
- service: light.turn_on
target:
entity_id: light.arbeitszimmer
turn_off:
- service: light.turn_off
target:
entity_id: light.arbeitszimmer
set_level:
- service: light.turn_on
target:
entity_id: >
{% set group = 'light.arbeitszimmer' %}
{{
expand(group)
| selectattr('attributes.brightness', 'defined')
| selectattr('attributes.brightness')
| map(attribute='entity_id')
| list
}}
data:
brightness: "{{ brightness }}"