Hey, so i’ve got these group with id light.luces witch has four light in it, and i want to display on my dashboard the amount of light of that group that are currently on.
Is there a way to do it from the UI?
This is how I did it:
template:
- sensor:
- name: number_of_lights_on
unique_id: sensor_number_of_lights_on
icon: mdi:lightbulb-group
unit_of_measurement: "on"
state: >
{% set lights = [
'light.luces'
] %}
{{ expand(lights) | selectattr('state','eq','on') | list | count }}
Then just use sensor.number_of_lights_on
to show the total on the UI.
1 Like
I am very similar, but I use a reject group to exclude light groups.
template:
- name: "count of lights on"
icon: mdi:lightbulb-on
unique_id: count_lights_on
unit_of_measurement: "on"
state: >
{% set reject = [
'light.house_lights',
'light.lux_scenes',
'light.downstairs_lights',
'light.upstairs_lights',
'light.livingroom_lamps',
'light.livingroom_lamps_half_on',
'light.livingroom_lamps_half_off',
'light.livingroom_blooms',
'light.hallway',
'light.outside',
'light.landing',
'light.patio'
]
%}
{{ states.light
| rejectattr('entity_id', 'in', reject)
| selectattr('state','equalto','on')
| list
| length
}}