using a template (which works perfectly fine in template editor) and testing the various spots for the whitespace trim - I experience this:
- type: markdown
title: Hue 1 light groups
card_mod: *header
content: >
{% set group_list = expand(integration_entities('Philips Hue 1'))
|selectattr('attributes.is_hue_group','eq',true) %}
{% set ns = namespace(groups=[]) %}
{% for group in group_list %}
{% set ns.groups = ns.groups + [group.object_id] %}
{% endfor %}
{%- for g in ns.groups -%}
{% set ns2 = namespace(lights=[]) %}
{%- for l in state_attr('light.'~g,'lights') -%}
{% set ns2.lights = ns2.lights + ['light.'~l|slugify] %}
{%- endfor %}
**{{g|title}}** ({{states('light.'~g)}}):
{%- for id in ns2.lights %}
{{state_attr(id,'friendly_name')}}: {{states(id)}}
{% endfor %}
{% endfor %}
thanks Petro, removing that - in the last but one line doesnt throw an error though, its really odd.
Im probably searching for the impossible here, indenting the list of lights, and, when crossing the line, continue on the next line , but ofc again indented… maybe I have to live with
It was more of a templating exercise to begin with creating the 2 namespaces and using the 1 in the other.
its interesting though in watching the systems response, whether there’s a difference between using the integration_entities(), especially over 2 bridges
if one counts those entities, the difference isnt too extravagant (in my setting it also sees to the Tradfri lights when using states.light) but when using the integration_entities(), it also see all scenes (couple of hundred) and sensors… and yet, both seem to respond quite similarly.
- type: entities
title: Hue light groups
card_mod:
style: |
.card-header {
background-color: var(--background-color-off);
color: var(--text-color-off);
padding-top: 0px;
padding-bottom: 0px;
}
entities:
- type: custom:hui-element
card_type: markdown
card_mod:
style: |
ha-card.type-markdown {
box-shadow: none;
margin-top: 8px;
overflow-y: scroll;
height: 300px;
}
content: |
{% set group_list = states.light
|selectattr('attributes.is_hue_group','eq',true) %}
{% set ns = namespace(groups=[]) %}
{% for group in group_list %}
{% set ns.groups = ns.groups + [group.object_id] %}
{% endfor %}
{%- for g in ns.groups -%}
{% set ns2 = namespace(lights=[]) %}
{%- for l in state_attr('light.'~g,'lights') -%}
{% set ns2.lights = ns2.lights + ['light.'~l|slugify] %}
{%- endfor %}
**{{g|title|replace('_',' ')}}** (*{{states('light.'~g)}}*):
{%- for id in ns2.lights %}
> {{state_attr(id,'friendly_name')}}: *{{states(id)}}* since {{as_timestamp(states[id].last_changed)|timestamp_custom('%H:%M:%S %d %b')}}
{%- endfor %}
{% endfor %}
#expand(integration_entities('Philips Hue 1'),integration_entities('Philips Hue 2'))
before you ask why use entities: its because I want the card to scroll, and setting a scroll on the markdown, also scrolls the header out if sight. Like above, the header is fixed, and only the markdown contents scrolls.
(note that where we need to set a max-height: normally for a scroll element, using a markdown requires height: )
update
after some re_arranging, this might be better (read: lighter on the processor…)
content: |
{% set group_list = states.light
|selectattr('attributes.is_hue_group','eq',true)|map(attribute='entity_id')|list%}
{%- for g in group_list -%}
{% set ns2 = namespace(lights=[]) %}
{%- for name in state_attr(g,'lights') -%}
{%- for l in states.light
if l.attributes['friendly_name'] == name %}
{% set ns2.lights = ns2.lights + [l.entity_id] %}
{% endfor %}
{% endfor %}
**{{state_attr(g,'friendly_name')}}** (*{{states(g)}}*):
{%- for l in ns2.lights %}
> {{state_attr(l,'friendly_name')}}: *{{states(l)}}* since {{as_timestamp(states[l].last_changed)|timestamp_custom('%H:%M:%S %d %b')}}
{%- endfor %}
{% endfor %}