Trouble with Updating a Group Using group.set Service in Automation

Hello Home Assistant Community,

I’ve been experiencing an issue with updating a group dynamically using the group.set service in an automation. The goal is to update the group selected_kueche based on the states of input_boolean entities. The automation seems to be triggered correctly, but the group remains empty. I’m looking for some guidance on what might be going wrong.

Here’s the setup:

  1. Entities:
  • Two input_boolean entities: input_boolean.selected_light_kueche and input_boolean.selected_light_essen.
  1. Goal:
  • Dynamically update the group selected_kueche with light.kueche when input_boolean.selected_light_kueche is on, and similar for input_boolean.selected_light_essen.
  1. Automation:

yaml
alias: Update dynamische Lichtgruppe_test
trigger:
- platform: event
event_type: “”
action:
- service: group.set
data:
object_id: selected_kueche
entities:
- light.kueche

(same result with action:

  • service: group.set
    data:
    object_id: selected_kueche
    add_entities:
    - light.kueche)
  • Issue:
  • The automation is triggered, and the logs show that the group.set service is called. However, the group selected_kueche remains empty.
  • Log excerpts:
    2023-12-03 17:50:02.123 DEBUG (MainThread) [homeassistant.components.automation.xx] Automation triggered
    2023-12-03 17:50:02.126 INFO (MainThread) [homeassistant.components.automation.xx] Update dynamische Lichtgruppe_test: Running automation actions
    2023-12-03 17:50:02.127 INFO (MainThread) [homeassistant.components.automation.xx] Update dynamische Lichtgruppe_test: Executing step call service
  1. Additional Context:
  • Home Assistant version: 2023.11.3
  • I’ve confirmed that the entity light.kueche is available and working correctly outside of this automation.
  • The group selected_kueche was initially empty and created through the Home Assistant UI.

Could anyone provide insights into why the group is not being updated or suggest what I might be missing here? Any help or suggestions would be greatly appreciated!

PS I also have tried the folowing:

group definition in config:
group:
selected_test:
name: Ausgewählte Testgruppe
entities:

automation:
alias: Manuelle Testautomatisierung für Gruppenaktualisierung
description: “”
trigger:

  • platform: event
    event_type: “”
    action:
  • service: group.set
    data:
    object_id: selected_test
    entities:
    - light.kueche
    - light.essen

does not work either

Please format your request properly. You’ll be much more likely to get a response.

1 Like

Please still go back and edit your request but I think your issue is that your light group is a “new” style group which takes on the domain of it’s entities and becomes light.new_group for example, not group.new_group.

The service group.set only works with “old” style group. I think.

1 Like

Thanks good advice,will try that next time.
I just filtered the entity manual and actually it works but is not visible in the ui of helpers (exactly, second version without light. )
Hmm, ok than my solution is not working somewhere else yet ;o)

If what you are trying to do is control specific lights when specific input_booleans are turned on you can accomplish this with a choose or if/then structure in your automation rather than creating groups.

sorry but i think it doesn’t work with my automation example:

alias: Survillance - Create cams group
description: ""
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - service: group.set
    data_template:
      object_id: all_cams
      entities: "{{ states.camera | map(attribute='entity_id') | list }}"
mode: single

Any suggestion?

Change data_template to data. Where did you get that from? data_template has been deprecated for years now.

Sorry but i was away HA since long time…
what i’m trying to do is creating a group at the HA startup via automation, that includes all webcam entities.

Can you help me?

Here is the automation from my config where I do exactly that.

the problem is that group.set service doesnt exist anymore…

this is the output:

The automation “Survillance - Create camera group” (automation.crea_gruppo_telecamere) has an action that calls an unknown service: group.set.

This error prevents the automation from functioning correctly. Perhaps this service is no longer available, or perhaps a typo caused it.

To fix this error, edit the automation and remove the action that calls this service.

Click SUBMIT below to confirm that you have fixed this automation.

What version of HASS are you using? Post the YAML for your entire automation.

HA core 2024.2.3

this is my automation:

alias: Survillance - Create all cams group
description: ""
trigger:
  - platform: homeassistant
    event: start
condition: []
action:
  - service: group.set
    data:
      object_id: all_cams
      entities: |
        {{ states.camera | map(attribute='entity_id') | list | sort}}
mode: single

If you don’t have any group defined in .yaml, the service is not loaded on startup.

before the last HA core updating, this service creates a group from scratch…
Now you tell me that in order to use this service i have to create it from the yaml file?

maybe just adding

group:

to configuration.yaml is sufficient.

i have this line in configuration.yaml that include another yaml file where are all my groups

group: !include groups.yaml

i know but modify it dinamically via automation is better

solved with the last HA update