More template help!

Thanks alot,

I will look into this as soon as I have time. I saw in the Dev tool that there where alot om listening (is that a problem)?

I really appreciate all help I can get with templates. :ok_hand:

Best regards
Thekholm

I have no professional background in CS, but my understanding is that more listeners means you use more processing resources, and that it is best practice to do what you can to limit the listeners. I assume this is most important for users who have their HA instance on lower spec platforms like RaspPis, which is a large portion of the user base.

The earlier example listened to every entity with an assigned Area, all the time. While lights are off, the updated one listens only to the light domain and when lights are on it listens to the light domain and all entities in the Areas where there are lights on. There is definitely still room for improvement.

Another thing to keep in mind when using Areas like this is that, as your number of devices grows, you may end up spending more time adjusting/maintaining templates to filter out unwanted light entities than you would have creating and maintaining groups. For example, every sonoff smart relay I own and every instance of browser mod has a light entity. None of them are lights I would want included in a card like this one. Using groups would remove the necessary evil of all those extraneous listeners.

Even the code you gave is listening for alot (binary, sensor, light and so on). The only code that I have thats only listning to light is this one, but there I dont have this (6 lights on, of / 6 total).

{% set l = ['light.killarnas_rum_group', 'light.stellas_rum_group'] %}
{% set room = states.light 
|selectattr('entity_id', 'in', l)
|selectattr('state', 'eq', 'on') 
|list%}
{% set hue = states.light
|selectattr('attributes.is_hue_group', 'true')
|selectattr('state', 'eq', 'on') 
|list%}

{{ (hue + room) |map(attribute='name') |join(', ') }}

Output: Bedroom, Livingroom, TV-Rum and so on and it only listens for Domain: Light How can I get this with this code, Bedroom (6/6), Livingroom (6/6), TV-Rum (6/6) and so on?

I also have this for lights on and total lights (24 / 67).

{{ states.light | selectattr('state', 'eq', 'on')
  | rejectattr('attributes.is_hue_group', 'true')
  | map(attribute='entity_id')
  | list | count }} / {{ states.light
  | rejectattr('attributes.is_hue_group', 'true')
  | map(attribute='entity_id')
  | list | count }}

Output: 24 / 67 of turned on lights (24) and total lights (67) and it listens only to Domain: Light
How can I get this in bold for on lights?

This one shows all the lights that is on with there name.

{{ states.light
|selectattr('state', 'eq', 'on')
|rejectattr('attributes.is_hue_group', 'true')
|map(attribute='name')
|join(', ')
}}

Output: All the lights that is on with there names. How can I only show lights in one room, light-group instead of all light names? and it listens only to Domain: Light

Best regards
Thekholm