I have started making a new dashboard for my Home Assistant. It will have a view for each area in the house, a summary view and some views for special cases - so much like that produced by Dwainâs Dashboard or Mushroom dashboard, but as I wish it.
Firstly I made a series of summary binary_sensors, one for each area, using the ideas in this thread These sensors have counts of lights, lights_on, lights_off etc for various domains and a list of ids of the entities. So for the area named Annex we have binary_sensor.annex_summary, which looks like this:
I want to use this sensor to generate a grid of tile cards using the list of entities in the attribute lights_id, but I canât get it right.
Firstly I tried an entities card, like this
type: custom:state-switch
entity: template
template: |-
{{
state_attr('binary_sensor.annex_summary', 'lights_count') | int > 0
}}
states:
'true':
type: vertical-stack
cards:
- type: markdown
content: '### Annex lights'
- type: custom:auto-entities
show_empty: true
unique: true
filter:
template: '{{ state_attr(''binary_sensor.annex_summary'',''lights_id'') }}'
card:
type: entities
state_color: true
show_header_toggle: false
entities: null
which works fine and produces an entities card, like so:
However I want to produce a grid of tile cards (or mushroom cards), but my inability to think and speak yaml and jinja prevents that. I have tried several different possibilities gleaned from the posts of others, but canât crack it. Any and all help would be greatly appreciated.
The two approaches I have tried are:
- type: custom:auto-entities
show_empty: true
card:
type: grid
square: false
columns: 2
card_param: cards
filter:
template: |-
{%- for element in
expand(state_attr('binary_sensor.annex_summary','lights_id'))|
map(attribute='name')|list -%}
{{
{
'type': 'tile',
'entity': [element.entity_id,]
'name': state_attr(element.entity_id, 'friendly_name'),
'tap_action': '',
{'action':'more-info'}
}
}},
{%- endfor -%}
sort:
method: friendly_name
and this one
- type: custom:auto-entities
show_empty: true
unique: true
card:
type: grid
square: false
columns: 2
card_param: cards
filter:
template: |-
{% for element in
state_attr('binary_sensor.annex_summary','lights_id') -%}
{{
{
'type': 'tile',
'entity': element.entity_id,
'name': state_attr(element.entity_id, 'friendly_name'),
'tap_action': '',
{'action':'more-info'}
}
}},
{%- endfor %}
sort:
method: friendly_name
Both result in nothing being shown. Substituting a markdown card that prints the loop counter in place of the tile card definition also produces nothing, so there is something wrong with the formatting of the loop, but I donât know what.