#Difference between targeting a group compared to area or label in automation/script

1 messages · Page 1 of 1 (latest)

void blade
#

I have no facts but this is based on my observation.

  • Let's imagine we have 3 lights. light.a, light.b, light.c, or shorter a, b and c.
  • Let's create a group light.group, and add lights a, b and c inside.
  • Let's create a label MyLights and assign this label to all 3 lights

If I create the automation that targets entities separately, all is good, for example:

action: light.turn_on
target:
  entity_id: 
    - light.a
    - light.b
    - light.c

This will do a for loop and loop each entity separately and send the same data to each light. So far so good.

for entity in entities_list: light_turn_on(data)

Then, let's address the group:

action: light.turn_on
target:
  entity_id: 
    - light.group

According to my observation, this will do something like, kind-of pseudo code:

entities = get_entities_from_the_group
for entity in entities_list: light_turn_on(data)

But then when the selector is label

action: light.turn_on
target:
  label_id: 
    - mylabel

I would expect that what happens is that we get entities that have the label set, or the entities of the specific domain that belong to device that has the label set:

entities = get_entities_with_label(mylabel) + get_entities_from_devices_with_label_and_domain(mylabel, 'light')
for entity in entities: light_turn_on(data)

.... Continuing in the comment because the post is too long ....

#

When using the adaptive lighting integration, I have observed that if I put my lights in the group, adaptive lighting integration works correctly, however if I assign the label to adaptive lighting, then the lights won't properly get aligned.

This is because adaptive lighting catches the turn_on command, does some changes and then forwards the call to the underlying integration to actually turn on the light. Now, it seems that if I use the labels as a target, the turn_on is not called for each entity separately.

Is the data extracted from the group/area/label not happening at the same location?

That being said, I am at this point just trying to understand if there is the difference how home assistant uses the targets between entities, group entities, labels or areas.

#

OK so the first assumption I have is that when one selects the group, group integration will actually extract the entities list and forward calls to each entity. I will reserach implementation