#Dynamic Light Group
1 messages · Page 1 of 1 (latest)
Create a helper group of lights.
I currently have a light group with all lights in it, but if only some of those lights are on, I don't want the rest of the lights to turn on if i wanted to change brightness or color.
I do this
here:
all_on_lights: >
{{ integration_entities('group')| select('search',
'light.group_all_lights') | expand | selectattr("attributes.rgb_color",
"defined") | selectattr("state", "eq", "on") | map(attribute='entity_id')
| list }}
Define this variable a script, and call your action on 'all_on_lights'
Code context:
sequence:
- variables:
all_on_lights: >
{{ integration_entities('group')| select('search',
'light.group_all_lights') | expand |
selectattr("attributes.rgb_color", "defined") | selectattr("state",
"eq", "on") | map(attribute='entity_id') | list }}
- repeat:
sequence:
- metadata: {}
data:
hs_color: "{{ range(1, 360) | random | string + ',' + 100 | string }}"
target:
entity_id: "{{all_on_lights[repeat.index - 1]}}"
action: light.turn_on
for_each: "{{ all_on_lights }}"
mode: restart
icon: mdi:sale
fields: {}
description: |-
This script can be used to change the lights in the house to random colors.
It can be used by an LLM to trigger this action when requested
Do not use this to modify individual lights or bulbs!
From what I can see of that though it wouldn't allow me to do this from a card on the dashboard. My goal if possible is to treat only the lights that are on as one so i can use a light card (or something similar) on my dashboard. sorry if i'm not explaining things very clearly
I know a light group would let me, but from what i've tried it doesn't see, possible to edit one after its created. I know its possible with the old style group, but that wouldn't be treated as a light
If you create a Number Helper with 0-100 range.
Put that helper on a Tile card with a slider
Have an automation monitor the helper for a change and then calling the script to change the lights as above, based on the number in the helper.
(also while poking around in helpers I discovered a template light. You might be able to include the above search for lights that are on into a single entity with that. Never tried it, only just discovered it)