Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 102976

Count total lights on for a light group

$
0
0

Hello All,

I recently created light entities out of shelly switches and while i was at it I created light groups of those newly created light entities as well as existing light entities. I’m looking for a way to count total lights on per light group. I’ve seen posts on using if statements and manually adding each entity which defeats the purpose of my newly created light groups, same way expanding a standard group wont work as i did not make these standard groups.

I saw this code to expand a light group and it works great at expanding the light group

{{expand(state_attr('light.all_lights', 'entity_id'))|map(attribute='entity_id')|list}}

This is code I found to expand a standard group and get count of on state ,which appears to work.

{{ expand('group.davidsroom') | selectattr('state', 'eq', 'on') | list }}

I tried the below as a merge of both lines above but clearly I dont know if its meant to work or I’m missing anything. Code doesn’t error, it does return the list of entities in developer tools template but it does not give me a count (always shows 0)

{{expand(state_attr('light.all_lights', 'entity_id'))|map(attribute='entity_id') | selectattr('state', 'eq', 'on') | list | count }}

Any assistance is greatly appreciated

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 102976

Trending Articles