Toggle groups too when inside entities groups (subgroup) toggle

Hey,

groups are a powerful shortcut in setup and automation, however
putting a group among the entities of another group does not work. If you have a motion sensor group
you can put it in an alarm group with another sensor (door opening) but the activation of the alarm group
motion sensor will not trigger the activation of the alarm group. We have to repeat the sensors in the
2 groups.

 occupancy_sensors:
    name: MVT directors
    entities:
      - binary_sensor.ewelink_ms01_1_ias_zone
      - binary_sensor.ewelink_ms01_2_ias_zone


  smoke_sensors:
    name: Smoke detectors
    entities:
      - binary_sensor.heiman_smokesensor_em_1_ias_zone
      - binary_sensor.heiman_smokesensor_em_2_ias_zone

  alarm_sensors:
    name: Alarm detectors
    entities:
      - groups.occupancy_sensors
      - binary_sensor.ewelink_ds01_1_ias_zone
      - groups.smoke_sensors

It would be good to be able to integrate a group as an entity (with the same management rules as an entity) but with taking care of circular groups.

In the absence of feasibility, it would perhaps be necessary to prohibit putting a group entity in the configuration for avoid malfunction.

Don’t forget to vote for your own request.

this works perfectly:

  philips_motion_sensors_all:
    name: Philips motion sensors all
    icon: mdi:run-fast
    entities:
      - group.philips_motion_sensors_inside
      - group.philips_motion_sensors_outside

  philips_motion_sensors_inside:
    name: Philips motion sensors inside
    icon: mdi:run-fast
    entities:
      - binary_sensor.laundry_sensor_motion
      - binary_sensor.dining_table_sensor_motion
      - binary_sensor.auditorium_sensor_motion
      - binary_sensor.frontdoor_sensor_motion
      - binary_sensor.library_sensor_motion
      - binary_sensor.corridor_sensor_motion
etcetc


  philips_motion_sensors_outside:
    name: Philips motion sensors outside
    icon: mdi:run-fast
    entities:
      - binary_sensor.backdoor_buiten_sensor_motion
      - binary_sensor.driveway_buiten_sensor_motion
      - binary_sensor.garden_backyard_buiten_sensor_motion
   etcetc

use this in a template:

{{expand('group.philips_motion_sensors_all')|map(attribute='entity_id')|list}}

to see if HA understands what you’re doing :wink:

You can create groups in groups. It seems like your feature request should be named differently. Something like “Nested group trigger.” Possibly a new trigger type for group that will trigger off any entity (or entities) in the group, with modifiers like “all entities”, “one entity”, “no entities” with a state field attached.

but they already trigger off any entity in the nested groups.

:man_facepalming:
thank you

Hmm, I think I see what you mean. I will rename.
The goal is to get the state of the groups like any other groups and not to add a new trigger, in fact if a subgroup toggle on, the main groups should toggle on too like it do if an entity of group toggle on (if flags all is not all)

Does groups.philips_motion_sensors_all state is on when groups.philips_motion_sensors_inside is on ?
because for my use case, is not.

The behavior of groups will never change. This has been tried many times but there are technical reasons why it has never changed. You’re welcome to continue down but I doubt anything will come out of it.

I don’t want to change the behavior of groups, absolutely not, just apply same rules for all entities of the groups, even if this entity is a group too…
Can you give more details about technical reasons?

Groups state is based on what lies in the group and there is a hierarchy related to that. Groups can contain many different state types, not just on/off. Depending on what’s in the group, that will affect the groups state. This is not configurable, it’s done naturally. Then when you try to nest this behavior it gets extremely complicated for little reward.

yep, works fine

Well the goal is not too change, just use entities group state to the state of group too like any other entitites of the group, the main difficult is to manage circular dependencies, this need a check. For the reward, it will more simple to create powerful scripts with less mistakes. You can manage by group without repeating entities, think ‘ansible’ tool for example, the powerful come from the ability to precisely target the actors

So what can be wrong in my setting, :thinking:

again, the problem is that group states are not simply on and off. adding this in will change the behavoir and make it complicated. It’s not simply adding the group domain into the check.

As I said before, this exact thing has been tried before and nothing came out of it.

To further clarify, this is why the expand() function exists in templates. It will recursively grab all entities inside groups and place them into a list without duplicates.

Mariusthvdb said that is working

Then you must not understand how a groups state changes. A groups state will be on if any entity is on. The state will not change if one is on and another turns on. Meaning, a trigger will not occur.

if any of the entities in the nested groups turn on, that groups turns on. If the nested group turns on, it turns on the parent group.