Count entities in a light group?

trying to cut down on manually created groups (with light entities) and transforming these to light groups makes me wonder how we can count the lights in these light groups, general, or with tests too on/off

apparently the background cost of maintaining these groups with lights, is so heavy, that transforming them into light groups would be rewarding.

however, I need the ability to count the on/lights, so please have a look f that would be possible.

I have already concluded we can’t ‘expand’ these light groups, so I am not really confident it is possible at all.

Everything you could ever need!

From there, he has the exact example you would want!

Template to count all entities that are a state

This template counts all entities that have a specific state. e.g. count all lights that are on.

{% set domain = 'light' %}
{% set state = 'on' %}
{% set count = states[domain] | selectattr('state','eq', state) | map(attribute='entity_id') | list | count %}

Thanks,
I am aware of that thread by Petro, but in my specific case it does not really help…

I need to count the entities of a group, or light group, not just entities in a domain

I see. It’s close at least!

expand(states.group.XXX) will return the same thing states[domain] returned.

{{ expand(states.group.all_doors) | selectattr('state', 'eq', 'off') | map(attribute='entity_id') | list | join(', ')  }}

yes, but I am supposed to ditch the groups… as I explained in the starting post, and replace them by light groups

Oh, the confusion is “all_doors” for me is a group I made consisting of all my doors. It’s not an automatically created group.

You can still create groups, and I don’t think these groups are very process expensive. The expensive part was the automatic creation/removal/maintenance of all of these groups that many people used.

The light group isn’t for grouping things to keep track of. It is not the same thing as a group of lights.

The group light platform lets you combine multiple lights into one entity. All child lights of a light group can still be used as usual, but controlling the state of the grouped light will forward the command to each child light.

It is a single entity now. And from what I can tell, there is no attribute that shows each individual light in the group.

After rereading your question, I finally understand it. So my only answer is “I don’t believe creating a group of lights (not a light group) to be bad for the system. But I think you’re right that it’s not possible to track a light group like you could a group”

well, Im still not convinced about that after setting homeassistant.core: debug in logger. the amount of data logged for administrating the groups with lights was quite simply stunning… I have quite a few lights, and had many of these on more groups, depending on the needs for counters and layout in the house.

Some of these even doubled, as default groups, so they can be counted and checked for individual light state, and as light groups, for the supposed advantage previously mentioned.

keeping up with all that info takes quite some backend power.

of course Ymmv.
thanks