I stumbled across that post that gives 2 smart approaches on how to deal with mixed-states bulbs
I need to try the Proportional toggle one!
…
Done. Here is my working example with 3 lights
description: Toggle sofa lights and TV light proportionally
trigger:
- platform: event
event_type: deconz_event
event_data:
id: aqara_switch_living_room
unique_id: 54:ef:44:10:00:5b:6f:c3
event: 2002
device_id: 27a83c2f0c73aeda8ba26ef3cb6937a5
condition: []
action:
- variables:
count_on: >
{{ expand(state_attr('light.sofa_tv', 'entity_id')) |
selectattr('state','eq', 'on') | list | count }}
count_off: >
{{ expand(state_attr('light.sofa_tv', 'entity_id')) |
selectattr('state','eq', 'off') | list | count }}
light_action: "{{ iif( count_on >= count_off, 'off', 'on' ) }}"
- service: light.turn_{{ light_action }}
metadata: {}
data: {}
target:
entity_id: light.sofa_tv
mode: single