šŸ”¹ Auto-entities - Automatically fill cards with entities

Although that does work, I was really hoping for a solution that would allow me to keep the sections as I find that more visually appealing. Thank you for your suggestion, though!

I am not sure but will try to explain.

  1. Lets imagine that the template returns a list if entity_ids.
    One record = one entity.
    These records may be sorted by state, name etc.

  2. The template returns a list of records:

entity: xxxxxxx
name: xxxxxx
.....

Again , each record = entity, they may be sorted.
I do not know how the card knows that THIS IS A LIST OF ENTITIESā€¦

  1. The template returns a list of records:
type: custom:declutterin-card
template: some_template
variables:
  - AAAAAAAA: ....
  - BBBBBBB: ....
...

Each record cannot be explicitly associated with some entity; in fact, it may represent several entities.
In this case we have to sort in the template itself.

1 Like

At least I understood. Thanks. This makes sense. Thought before, That with template, the sorting is per Definition ignored. But if it still tries to sort sortable template output, thats great.

Any way to show secondary info with templates (Iā€™d like to see last-changed under each entity without using another card). FYI - I use the template since I have entities in groups in groups:

      - type: custom:auto-entities
        card:
          type: entities
          show_header_toggle: false
          state_color: true
        filter:
          template: >-
            {{ expand(states.group.lights_all) | selectattr('state', 'in',
            ('on', 'open', 'unlocked', 'not_home')) | map(attribute='entity_id')
            | list }}
        sort:
          method: friendly_name

Scroll up a little, there was a link to example. Also, you may use a magical ā€œsearch in threadā€ feature.

Hey all, im still pretty knew, im not a coder and i can figure out most things by looking at examples, but im having trouble trying to excluding automations from my list. Can someone help me out here pls? i know its easy

type: custom:auto-entities
card:
  type: entities
  title: Doors Currently Open
  state_color: true
  show_header_toggle: false
filter:
  include:
    - entity_id: '*door*'
      state: 'on'
exclude:
  - domain: automation
sort:
  method: none
show_empty: false

wrong indentation

1 Like

I have another one

im trying to have auto entities create graphs for my device batteries. im not a coder, what does this error mean

Cannot read properties of undefined (reading ā€˜lengthā€™)

type: custom:auto-entities
card:
  type: entities
  title: Devices Battery Level's
  state_color: false
  show_header_toggle: false
filter:
  include:
    - entity_id: '*battery_level*'
      options:
        type: custom:mini-graph-card
        hours_to_show: 96
        points_per_hour: 0.4
        animate: true
        align_icon: left
        align_header: left
        upper_bound: 100
        lower_bound: 0
  exclude: []
sort:
  method: friendly_name
  reverse: false
  numeric: true

Wrong.
options - for each entity.
Since you need graphs - why have you specified ā€œtype: entitiesā€?

The right code is (example):

type: custom:auto-entities
card:
  type: custom:mini-graph-card
  name: Devices Battery Level's
  hours_to_show: 24
  points_per_hour: 60
  align_icon: left
  align_header: left
  lower_bound: 0
  line_width: 1
  show:
    fill: false
    labels: true
filter:
  include:
    - entity_id: sensor.battery_*

image

I have card like this:

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
  state_color: true
  title: Presence OFF
filter:
  include:
    - name: presence_*
      options:
        secondary_info: last-updated
      state: 'off'
  exclude: []
sort:
  method: last_updated
  numeric: true
  reverse: true

This shows me ā€œdeadā€ or missing devices on my network. But some of my devices are long-term off and I am fine with it, but donā€™t want to remove them. Usually the way to detect this is that their last update is the same as date of last HA start.
I have added input_datetime helper that gets stored current datetime 2 minutes after start of HA.
I would like to add additional filtration to this card where if itā€™s attribute last-updated < my stored value it is not shown.
I am struggling to get it working and I am not sure if that is even possible.

It should be somehow like this ā€¦

{{ as_timestamp(states('input_datetime.last_boot_timestamp')) | int > last-updated }}
{{ as_timestamp(states('input_datetime.last_boot_timestamp')) | int }}

ā€¦ but it did not work for me.

I would appreciate suggestions. Thanks.

you can template card options with custom:config-template-card which embeds your full config you posted here and allows to input a template as you like it to be

Thank you for your answer. I had a look at config-template-card but I fail to see how to do that. The documentation seems a bit sparse. It seems like the entities that are watched must be explicitly stated, but my list needs to come from auto-entities.
I really need just to add another filter to auto-entities.
If you could give some example it would be greatly appreciated.
Thank you.

well, that scenario (auto-entities filling a config-template-card) has just been added as a FR by me in the repoā€¦

other than that, I thought you wanted to template some of the cards options (not the entities), and that is quite possible.

1 Like

would you know of a way to have an auto-entities filled grid card with custom:button-cards with a template filter?

I have made the confg with auto-entities and a fixed filter set, (where the button-card is used in the options: field) but can not make it happen using a filter: template (because that wont accept optionsā€¦)

I do hope I make a user error. but believe I tried it allā€¦

    - type: custom:auto-entities
      card:
        type: grid
        title: Test Icon color Buttons
        columns: 4
      card_param: cards
      filter:
        include:
          - entity_id: sensor.*_actueel
            options:
              type: custom:button-card
              aspect_ratio: 1/1
              show_state: true
              template: support_custom_ui
        exclude:
          - state: '<20'
      sort:
        method: state
        numeric: true

and this wrks too:

      - type: custom:auto-entities
        card:
          type: entities
          card_mod: &mod
            style: |
              ha-card {
                box-shadow: none;
                margin: -16px -16px 0px -16px;
              }
        filter:
          template: >
            {% set threshold = states('input_number.power_threshold')|float(0) %}
            {% set ns = namespace(above_threshold=[]) %}
            {% for s in states.sensor
             |selectattr('entity_id','search','_actueel')
             if s.state|float(0) > threshold %}
            {% set ns.above_threshold = ns.above_threshold + [s.entity_id] %}
            {% endfor %}
            {{ns.above_threshold}}
        sort:
          method: state
          numeric: true

works fine, but replacing the

      filter:
        include:
          - entity_id: sensor.*_actueel

with the template from the second example doesnt work, because we can no longer set options in that caseā€¦

hope you see what I am missing

why, because i literally have no idea what im doing lol i dont know code, its trial an error for atm
I was hoping that each battery would have its own graph card not all battery devices on the one graph.

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - entity_id: sensor.battery_*
      options:
        type: custom:mini-graph-card
        entities:
          - this.entity_id

Thanks for helping :slight_smile:

This is what i have and now this error??
The ā€œentityā€ option was removed, please use ā€œentitiesā€

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - entity_id: '*battery_level*'
      options:
        type: custom:mini-graph-card
        entities:
          - this.entity_id

I do not see any errors:

Bugger! This is what i see.

@Mariusthvdb

  - type: custom:auto-entities
    card:
      type: grid
      title: Test Icon color Buttons
      columns: 4
    card_param: cards
    filter:
      template: >-
        {% set threshold = states('input_number.test_number')|float(0) -%} {%-
        for s in states.sensor|selectattr('entity_id','search','battery_')
           if s.state|float < threshold -%}
          {{
            {
              'type': 'custom:button-card',
              'entity': s.entity_id,
              'aspect_ratio': '1/1',
              'show_state': 'true'
            }
          }},
        {%- endfor %}
    sort:
      method: state
      numeric: true

2 Likes