#How to create a dynamic light group consisting of all lights that are currently on

1 messages · Page 1 of 1 (latest)

opal portal
#

My current dashboard has bubble cards sliders to adjust brightness (default bubble-card) and kelvin temperature:

I'm trying to create a bubble card on a dynamic entity, consisting of all lights that are currently toggled on.
I'll use it as a master switch to toggle brightness of lights currently on (and turn them off)

SImilarly, I want to create another slider that does the same but for the kelvin temperature

However I have a hard time figuring out how to create a dynamic group entity

deep bolt
# opal portal My current dashboard has bubble cards sliders to adjust brightness (default bub...

This is something that I worked on during the summer of 2023 with the help of TheFes and petro. We got it working for the most part and I intended to get it finished off and documented but never did.
It uses a custom template that is added to your configuration.yaml. I was looking over the code last night. It is roughly 100 lines long (I actually need to add 12 more lines to it). It handles brightness and color temp but does not handle RGB. (That was the last thing I was planning on adding to it.)
When I get home from work this evening, I want to see if I can optimize the code a bit and hopefully reduce it by about 30 lines. I'll try to get it posted to my github this evening in at least the un-optimized form so you can check it out.

deep bolt
#

Sorry for the late reply. I've worked on the dynamic light group a little bit more and have posted it on my Github. There are two versions that essentially accomplish the same thing. Both go in the configuration.yaml; one in light: and the other in template:. Neither method supports the light's color, yet; I'll probably need some help with that.
EDIT: Apparently the color_temp doesn't work any more. Looking in to it. FIXED. Also, updated to color_temp_kelvin.

#

The key to getting it to work is the template to determine what entities to handle. yaml {{ states.light | rejectattr('entity_id', 'eq', 'light.dynamic_lights') | rejectattr('entity_id', 'eq', 'light.all_lights_on') | rejectattr('entity_id', 'in', integration_entities('group')) | rejectattr('entity_id', 'in', integration_entities('fullykiosk')) | rejectattr('entity_id', 'in', integration_entities('demo')) | rejectattr('entity_id', 'in', integration_entities('Demo')) | rejectattr('entity_id', 'in', integration_entities('bambu_lab') + integration_entities('browser_mod')) | selectattr('state' , 'eq' , 'on') | sort(attribute='name') | map(attribute = 'entity_id') | list }} The templates finds all light entities, rejects the two versions of dynamic lights and various integrations such as light groups and others that create light entities that are not applicable and keeps lights that are currently turned on. You may need to adjust your template accordingly. It wouldn't take much to adapt it to handle lights in a certain room or floor, for example. You can paste this template into Developer Tools > Template and see what it returns. Currently, mine returns ['light.kitchen', 'light.living_room1', 'light.living_room2', 'light.office1', 'light.office2', 'light.stove']
Integrations can be rejected with their own line or combined using the + sign.