#template in individual card grid?

1 messages · Page 1 of 1 (latest)

fast flower
#

the auto entities card docs have this example

Put all sensors in individual entity cards in a grid card:

type: custom:auto-entities
card:
  type: grid
card_param: cards
filter:
  include:
    - domain: sensor
      options:
        type: entity

and later an example using templating

Example using templates:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {% for light in states.light %}
      {% if light.state == "on" %}
        {{ light.entity_id}},
      {% endif %}
    {% endfor %}

Both work independentlly but if I try and combine the two I get a "No Card Type Configured" error.

type: custom:auto-entities
card:
  type: grid
card_param: cards
filter:
  template: |
    {% for light in states.light %}
      {% if light.state == "off" %}
        {{ light.entity_id}},
      {% endif %}
    {% endfor %}

I know practically I could get example 1 to do what I am trying to accomplish in 2, but I am trying to understand templating and why its not working so I can try and come up with more complex templates. They look like they should be operating pretty similar in principle but I think I'm missing a piece of the puzzle. Thanks!

rare current
#

Full disclosure: I have no idea how this works but I think this is what you want it to do.
In your last code snippet, you actually do not have a card defined. The grid card doesn't count.

#

I did something similar with a custom:layout-card instead of grid, but I used an include: for the filter with options for the card. ```yaml
type: custom:auto-entities
card:
type: custom:layout-card
layout_type: custom:grid-layout
layout_options:
width: 100
layout:
grid-template-columns: auto auto
grid-template-rows: auto
card_param: cards
filter:
include:
- domain: light
area: Living Room
options:
type: custom:mushroom-entity-card
entity_id: this.entity_id
layout: horizontal
secondary_info: none
tap_action:
action: toggle
hold_action:
action: more-info
exclude:
- state: unavailable
sort:
method: name
reverse: false
numeric: false
show_empty: true

#
type: custom:auto-entities
card:
  type: grid
card_param: cards
filter:
  template: >
     [ 
     {% for light in states.light %} 
       {% if light.state == "off" %}
         {{ dict(entity=light.entity_id, type='button', ) }}
         , 
       {% endif %}
     {% endfor %} 
     ]