Hi All,
I’m trying to make a few sensors for displaying stuff on my dashboard. I feel that I want to make a smarter version of a list of lights that are turned on and a sensor with the count of lights that are on.
I have a working template sensor for a list of lights that are on:
lights_turned_on:
value_template: >
{{ states.light
| rejectattr('state', 'eq', 'off')
| rejectattr('entity_id', 'equalto', 'light.keuken_kookeiland_3')
| rejectattr('entity_id', 'equalto', 'light.keuken_kookeiland_4')
| selectattr('state','eq','on')
| map(attribute ='name')
| list
}}
If I make the same template sensor with the ‘count’ filter I get a number returned of the numerb of lights that are on. I then have to remember to modify both if something changes in my filtering. So I want to use the sensor sensor.lights_turned_on to provide the count. If I paste the following in Developer Tools > Template a list is returned (contained in another object i presume)
{{ (states.sensor
| selectattr('entity_id','eq','sensor.lights_turned_on')
| map(attribute ='state')
| list )
}}
So when I run this through the Count filter it returns 1. How (if at all possible) can I split this back into an object that I can count the number of lights within the sensor.
Other smart solutions are also welcome obviously.
Kind regards, Marcel