Groups - group.set automation not updating group

Hello,
I am setting up an automation to update one of my groups by removing a member at night. The actions I have here run without errors, but the members of the group don’t change when I check the Helpers tab. Please advise, and thanks in advance!!

service: group.set
data:
  object_id: "dynamic_ac_units"
  entities: 
    - switch.ac_unit_1 
    - switch.ac_unit_2_kitchen

1 Like

Although I dont use this service function myself, I believe that you would need to reload as well for the action to take as per the documents:

I did try adding the reload action immediately after- does it have to be in the same script?

No, but the changes you made will not show up I believe until the groups are reloaded in some way. To be sure you could run your script then go to developer tools / yaml and manually reload groups then check if the changes are applied as you expected.

Done, same result though. No errors in the logs, but no change in the group. I did notice that if I change the object_id to something that doesn’t exist, it also runs with no errors…

1 Like

Here is the group for reference

Ah, well I may be reading the documents wrong here but I believe the script you are trying to run is only for the old yaml groups and not for those created in the Ui

The group.set service is for creating modifying entities whose domain is group.

You used the Helpers menu to create a Switch Group entity called switch.dynamic_ac_units. Note that this entity’s domain is switch and not group therefore it’s my understanding that you can’t use the group.set service call to modify it.

If you need to programmatically create/modify a group’s membership, I suggest you define it as a traditional group and not as a Switch Group helper.

1 Like

Which presumably you can only currently do in yaml, correct?

Understood- thank you for explaining the difference for me!
I’ve updated the group accordingly, see below. Do you see any flaw? Still not changing the group members, even after an update.

Group Setup in configuration.yaml:

group:
  dynamicac:
    name: dynamicac
    icon: mdi:snowflake
    entities:
        - switch.ac_unit_1

Code inside of call_service in my automation:

service: group.set
data:
  object_id: dynamicac
  entities:
    - switch.ac_unit_2_kitchen

GUI Visual of both:

Correct. The Helpers menu has a Group helper but the resulting entity’s domain is not a group but whichever domain was chosen from the menu (binary_sensor, cover, fan, etc).

Screenshot from 2022-08-18 11-44-14

Ironic that the Group helper cannot create a group entity but it is what it is. :man_shrugging:

2 Likes

Then you’re doing something wrong (that I can’t pinpoint) because it works for me. I can use group.set to create a group and then use the same service call to modify its membership. The change is immediately visible when the group entity is viewed in Developer Tools → States.

service: group.set
data:
  name: Just a test group
  object_id: test_group
  entities:
    - input_boolean.alarm_1
    - input_boolean.alarm_2
    - input_boolean.alarm_3

service: group.set
data:
  name: Just a test group
  object_id: test_group
  entities:
    - input_boolean.alarm_1
    - input_boolean.alarm_3

1 Like

Got it. I was looking under my groups code in configuration.yaml, not realizing that it doesn’t update with those service calls. My bad- and thanks!!

1 Like

Misleading.

Misunderstood.

I guess there was no better way to express what that helper achieves so they chose “Group” which was already the name of an existing entity domain. Kind of a misunderstanding of who does what but there it is … a Group Helper that doesn’t actually create group entities.