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

(off-top)
None of my dashboards is based on sections due to different glitches.
Using sections for testing only.

Iā€™ve been using them here and there, they have a nice look. It would be nice to get them to work with auto-entities. Iā€™m sure itā€™s doable, auto-entities is in maintenance mode so someone with frontend dev experience will need to add it

1 Like

have an example there?

using sections everywhere, so I can test if you want.

not much to test, just attempt to use auto entities using custom:hui-grid-sections as the card type. It will likely crash your browser or cause it to lag.

But what for? What do you want to achieve?

ā€¦ a dynamic number of entities inside a section grid. Or dynamic number of cards, doesnā€™t matter what.

Iā€™m not really asking for help here, Iā€™m explaining that it doesnā€™t work and warning others that it doesnā€™t work.

hmm, I only use cards: everywhereā€¦
have only single column views, so no use for grid: sections yet

only auto-entities that breaks my config is using filter on label.
it did that also in masonry so unrelated.

But, Thomas is back and rewriting some of his cards, maybe he will check auto-entities too

Well, at least this small example work OK w/o errors in console (Chrome).
Here ā€œauto-entitiesā€ populates Grid card (not that hui-grid thing):

  - type: sections
    title: 25x
    cards: []
    sections:
      - type: grid
        cards:
          - type: heading
            heading: New section
          - type: vertical-stack
            cards:
              - type: entities
                entities:
                  - entity: input_number.test_number
                    name: count
              - type: custom:auto-entities
                card:
                  type: grid
                  columns: 2
                  square: false
                card_param: cards
                filter:
                  template: >-
                    {% set NUMBER = states('input_number.test_number')|int(default=0) -%}
                    {%- for ENTITY in (
                                        states.input_boolean |
                                        selectattr('entity_id','search','\.test_boolean') |
                                        selectattr('state','eq','on') |
                                        sort(reverse=false,attribute='name') | list
                                      )[:NUMBER] -%}
                      {{
                        {
                          'type': 'entity',
                          'entity': ENTITY.entity_id
                        }
                      }},
                    {% endfor -%}
      - type: grid
        cards:
          - type: heading
            heading: New section
          - type: entities
            entities:
              - entity: input_boolean.test_boolean
              - entity: input_boolean.test_boolean_2
              - entity: input_boolean.test_boolean_3
              - entity: input_boolean.test_boolean_4
              - entity: input_boolean.test_boolean_5
              - entity: input_boolean.test_boolean_6
              - entity: input_boolean.test_boolean_7
              - entity: input_boolean.test_boolean_8
              - entity: input_boolean.test_boolean_9
              - entity: input_boolean.test_boolean_10

But what you wanted seems to be populating ā€œhui-grid-sectionā€ to populate a whole section, not a grid card within it.
Actually, I have no idea how it is possible to place

          - type: custom:auto-entities
            card:
              type: custom:hui-grid-section
              ...
            card_param: ???
            filter:
              template: ...

into this structure where every entry is supposed to be ā€œgridā€:

type: sections
sections:
  - type: grid
    cards: ...
  - type: grid
    cards: ...

grid card and grid section are 2 different areas of code.

seeing that you both really want to try this.

type: section
sections:
- type: custom:auto-entities
  card:
    type: custom:hui-grid-section
  card_param: cards
  ...

fill in the rest

I do not think it is possible.
At least for now.

title: test-3
path: test-3
type: sections
sections:

  - type: custom:auto-entities
    card:
      type: custom:hui-grid-section
    card_param: cards
    filter:
      include:
        - entity_id: input_boolean.test_boolea*
          options:
            type: entity

Yes, thatā€™s what Iā€™m saying. It does not work and it causes exceptions upwards of 50 a second.

How do I include a variable list of entities in an entitites card then?

I have all my stuff organized around topics/rooms using entities cards. Therefore, itā€™s breaking the scheme if I can only add the auto-entites if Iā€™m using the auto-entities card.

Do not place this code as a ROW inside Entities card.
Instead, use auto-entities as the ā€œupperā€ card, list your static entities like in my example.

Ah, I see what you meant. However, it looks like with this approach itā€™s not possible to position the auto-entities somewhere in between other rows and/or use the desired sorting method? Hereā€™s what I mean (with only sections for now, my target card is more complex):
image

type: custom:auto-entities
entities:
  - type: section
    label: Timer
  - type: section
    label: Wecker
filter:
  include:
    - entity_id: sensor.google_home_mini_timer_*
      options:
        type: custom:timer-bar-card
        translations:
          paused: pausiert
          active: beendet
        extend_paper_buttons_row:
          position: right
          buttons:
            - icon: mdi:close
    - entity_id: sensor.google_home_mini_alarm_*
      options:
        type: custom:multiple-entity-row
        show_state: false
        secondary_info:
          attribute: end_time
          format: datetime
        entities:
          - icon: mdi:close
  exclude:
    - state: unavailable
    - state: ""
    - state: idle
show_empty: false
card:
  type: entities
  show_header_toggle: false
  state_color: false
  title: Title
sort:
  method: none

Iā€™d want to have ā€œTimerā€ section > timer auto-entities > ā€œAlarmsā€ section > alarm auto-entities. In the documentation I couldnā€™t find a way to ā€œcustom sortā€ the entities e.g. by setting the position manuallyā€¦

You can certainly do that.

Two different auto-entities cards. One for each.

To place static rows between filtered rows - place these rows as filters:

type: custom:auto-entities
card:
  type: entities
entities:
  - zone.home
  - person.ildar
  - type: section
    label: xxx
filter:
  include:
    - entity_id: input_number.test_n*
      sort:
        count: 3
    - type: section
      fake_option: 1
    - entity_id: sun.sun
    - type: section
      fake_option: 2
      label: yyy
    - domain: counter
      sort:
        count: 2
unique: entity

2 Likes

was on the topic of reusing the area card once again and wanted a quick and dirty auto-entities listing

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  template: |
    {% for a in areas() %}
    {{
      {"type": "area",
       "area": a,
      }
    }}, 
    {% endfor %}

which shows ok

and with certain classes:

    {% for a in areas() %}
    {{
      {"type": "area",
       "area": a,
       "sensor_classes":
         {"temperature","humidity"},
      "alert_classes":
        {"motion","moisture","running","garage_door"},
       }
    }}, 
    {% endfor %}

this filter however flukesā€¦
what am I not seeing?

Youā€™re providing sets to motion and sensor_classes, not lists. Change them to lists.

1 Like

rightā€¦

    {% for a in areas()
        |reject('search','klimaat|main|mobile|huis|test') %}
    {{
      {"type": "area",
       "area": a,
       "navigation_path":"/ui-sub-views/"~a,
       "sensor_classes":
         ["temperature","humidity"],
      "alert_classes":
        ["motion","moisture","running","garage_door"],
       }
    }}, 
    {% endfor %}

Thanks a lot, your solution is working perfect.
I just had to modify my regex for the search condition of selectattr
from: /^sensor.calendar_event[1-9]$/
to: sensor.calendar_event[1-9]