NLand99
(N Land99)
1
Hello,
i managed to get the number of lights into a helper where light is on - this gives me a fairly high number.
{{ states.light | selectattr("state","eq","on") | map(attribute="entity_id") | list | count }}
I would prefer to see the number of rooms where the light is on. Does anyone have an idea how to manage that?
Thanks for the community help!
Tom
Troon
(Troon)
2
Please post code using the </> button, so:
{{ states.light | selectattr("state","eq","on") | map(attribute="entity_id") | list | count }}
as that doesn’t mess up quotes and indentation.
How have you associated lights to rooms? Areas? If so:
{{ set(states.light
|selectattr("state","eq","on")
|map(attribute="entity_id")
|map("area_name")
|list) }}
Line breaks just for readability; and set
is a Python structure like a list but with no duplicates:
NLand99
(N Land99)
3
Thanks for the quick help - now i am getting the list of the rooms,… i just would need the number
but this was fixed with a | count 
1 Like