I already use a light-by-light approach to see if a particular light is already on, but can I do this group/area/label-based? Only apply a scene to those lights which are already on?
If this is the service ‘Scene Apply’, may I have an example of what the yaml would look like… Thanks!
You can certainly select only the lights that are on in an area, group or with certain labels with a template. Scenes do not support templates though. So you would have to use a script instead.
I recently changed all my scenes to scripts. It simplified my automations considerably.
Here’s an example of a service call that turns off all lights that are on in three areas. If you’re dealing with labels instead of areas, use label_entities instead of area_entities.
Template for a Light Group. For a legacy Group (the kind defined in YAML exclusively) replace light.test_light_group with the entity_id of your legacy Group.
I’ve found that calling the service to labelled entities no longer ‘requires’ the selector in the first place.
for lights and switches , I didnt bother anymore since some time, but media_players tend to be unavailable here because of main power not being on, so I had that templated.
otherwise the volume setting, or playing a file on those would return an error.
using those services to labelled entities no longer requires that, so those selectors have become even simpler
Thanks. So using your example, it’s ’ | selectattr(‘state’, ‘eq’, ‘on’)’ that is determining whether the light is on or not. I’ll see if I can integrate that into what I’m trying to do.
I think you’re missing the point of my inquiry… I want to change the bulb color of only those lights that are presently on and labelled with a specific label. If I send the scene to all, all lights will be turned on.
Funny thing is… I actually had several ‘Scenes’ created, but didn’t realize, not one was active If they had more options, I would probably want to integrate them. Since I have a limited number of actual devices routinely used, not sure how it matters the number of service calls made.
It’s a shame this basic functionality is completely missing from HA. This extremely common usecase should be a native part of the app. Instead we have to contend with the disgusting YAML syntax and try to hack things together with ducttape. I love Home Assistant, but some of the decisions the development team have made are total head scratchers.
Use a script instead of a scene. There are far more options. There is a GUI for creating scripts and even selecting by entity, device, area or label but for dynamic selection (e.g. only lights that are on) you will have to use jinja templates (not to be confused with YAML).