How to set group state with automation

Is anyone familiar with if its possible to set the state of a group to something else with an automation?

In the front end when you tap on a group that doesn’t have switches, it pops up a card that displays a bar showing its state and the state is constant as unknown. I would like to use the state of a sensor in its place by updating the state based on the sensor then hide the sensor from the front-end. Below is code I’ve tried but doesn’t work. Hoping someone will have done this or have some suggestions.

automation:
  alias: change nest group state to heating
  trigger:
    platform: state
    entity_id: sensor.living_room_thermostat_hvac_state
    to: 'heating'
  action:
    entity_id: group.nest
    state: 'heating'
    
  alias: change nest group state to off
  trigger:
    platform: state
    entity_id: sensor.living_room_thermostat_hvac_state
    to: 'off'
  action:
    platform: state
    entity_id: group.nest
    state: 'off'

did you found a solution? I have the same problem :frowning:

same here…

Would be nice to have a group.set_state service.

3 Likes

I am also interested to have a similar feature. My setup looks as follows:


I have a group of scripts which trigger playing radio stations. Currently the group state is always “off” or “Aus” even though I have set “control: hidden”. It would be great if the group state would either display something like “off” and “playing” or, even better, when playing, display the currently played radio station name.
Do you have an idea how to achieve this?

Would like to know this aswel. Would be cool if there is a group.set_state service.

1 Like

any update?

1 Like

Hello, did someone found a solution ?

Is there a solution to this? Sometimes due to the Life360 problems at the moment I need to override a device tracker or two and just set “group.individual” to not_home

Any update on this? This feature would be really useful.

You can change state of your group (as state of any HA object) by using this python script.
I’ve just tried it successfully.
The only issue you might have is at some point HA might restore the group’s state back to what it was… :wink:

Another approach is to go through ALL objects of the group (which is doable) and change their state by calling home assistant.turn_xxx.

2 Likes

it simply works:

action:

  • service: switch.turn_off
    target:
    entity_id: group.poweroutlets
    mode: single