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

Oke donā€™t know why, because i have the feeling i tried this before, but its working now:

type: custom:auto-entities
card:
  square: true
  type: grid
  columns: 4
card_param: cards
filter:
  include:
    - entity_id: sensor.mijnafvalwijzer_gft
      options:
        type: picture-entity
        show_name: false
        image: /local/afbeeldingen/GFT1.png
        card_mod:
          style: |
            ha-card
              {background: transparent;
              border-style: none;
    - entity_id: sensor.mijnafvalwijzer_papier
      options:
        type: picture-entity
        show_name: false
        image: /local/afbeeldingen/PAPIER1.png
        card_mod:
          style: |
            ha-card
              {background: transparent;
              border-style: none;        
    - entity_id: sensor.mijnafvalwijzer_pmd
      options:
        type: picture-entity
        show_name: false
        image: /local/afbeeldingen/PLASTIC1.png
        card_mod:
          style: |
            ha-card
              {background: transparent;
              border-style: none;
    - entity_id: sensor.mijnafvalwijzer_restafval
      options:
        type: picture-entity
        show_name: false
        image: /local/afbeeldingen/REST1.png
        card_mod:
          style: |
            ha-card
              {background: transparent;
              border-style: none;
  exclude: []
sort:
  method: state
  numeric: true

i noticed it didnt update the example but after saving it, it did show correct now.

1 Like

Please edit your posts and format your code by surrounding it with two sets of three backticks (```) or using the editorā€™s menu for preformatted text.

Hi all,
just installed 1.13.0

tried this code below and it shows as if I want to do this:
- entity_id: light.kg_hobbyraum_deckenlicht*
OR!!
- label: Raumlampe`

Meaning: first filter result (alone) in a row with the second filter result (alone). In the description it is ā€œANDā€ is implicitā€¦ confusedā€¦

Is this a bug or am I the bug?

type: custom:auto-entities
show_empty: false
card:
  type: entities
  title: Lights on
  show_header_toggle: false
filter:
  include:
    - entity_id: light.kg_hobbyraum_deckenlicht*
    - label: Raumlampe

Solution:
The second dash was the problem:

  include:
    - entity_id: light.kg_hobbyraum_deckenlicht*
      label: Raumlampe

worksā€¦.

1 Like

Iā€™m trying to remove the bus icons to the left of the times in my bus time table card here, but Iā€™m not sure how to go about it as Iā€™m using a filter.template to get the entities Iā€™m interested in.

Hereā€™s what it currently looks like
image

and the code:

      - type: custom:auto-entities
        show_empty: false
        unique: true
        card:
          type: entities
          title: Bus line 2
          icon: "mdi:bus"
          card_mod: &ref
            style:
              hui-sensor-entity-row:
                $: |
                  .text-content {
                    width: 60px;
                  }
                .: |
                  ha-icon.icon {
                    padding-right: 0px;
                  }
                  h1.card-header {
                    padding-bottom: 5px;
                  }
                  #states > * {
                    height: 20px;
                    width: 50px;
                  }
        filter:
          template: |-
            {% for state in states.sensor -%}
              {%- if (state.entity_id | regex_match("^sensor.bus_line_2_.*$", ignorecase=False)) -%}
                {%- if (state.attributes.time | regex_match("[0-9]{2}:[0-9]{2}:[0-9]{2}", ignorecase=True)) -%}
                  {{
                    {
                      'entity': state.entity_id,
                      'name': state.attributes.friendly_name|regex_replace(find=".*", replace=' ', ignorecase=True),
                      'icon': "mdi:sun-angle", <<-- THIS BREAKS THE CARD
                    }
                  }},
                {%- endif -%}
              {%- endif -%}
            {%- endfor %}
        view_layout:
          grid-area: mid1

As you can see I tried adding the icon parameter in the filter.template code, but that breaks the card completely so that it just disappears from the dashboard.

did you try to add the default way for removing icons inside that filter template:

    card_mod:
      style:
        hui-generic-entity-row:
          $: |
            state-badge {
              display: none;
            }

(you need to format it correctly with brackets and quotes)

like this:

               {{
                  {
                    'entity': s.entity_id,
                    'card_mod':
                      {'style':
                          ':host {
                            --card-mod-icon-color:
                              {% set state = states(config.entity)|float(-5) %}
                              {% if state > 2000 %} purple
 
                              {% elif state > 10 %} lightsalmon
                              {% elif state > 0 %} var(--power-color)
                              {% else %} var(--no-power-color)
                              {% endif %};
                          }'
                      }
                  }
               }},

or some of the other examples in this thread

Hi,

Iā€™m trying to use the new labels from the 2024.4 release in combination with auto-entities cards.
Unfortunately I canā€™t get it to work:

This is what I tried:

type: custom:auto-entities
card:
  type: entities
  title: Heizung
filter:
  template: "{{ label_entities('Heating: Schedule') }}"

The label_entities() function returns a list of entities having the specified label - in my case automations.
But the card stays empty.

Has anyone managed to do this successfully?
Is this supposed to work like this at this stage (as the labels feature has just been released)?

Sebastian

Edit: if you actually do, then ā€œrenameā€ the Label , donā€™t use Colons or Dash ( donā€™t know if that the cause thou )

Now that would be stupid, right? :wink:

Itā€™s also not working with any other labels I tried (even without any special chars in them).
I did a fresh install of the auto-entities JS file through HACS a couple of hours ago to make sure I have the latest version.

What am I missing?

Sebastian

Have no idea , However something happened to my code, when i clicked save

filter:
  template: '{{ label_entities(''Wired'') }}'

Double quotes - within single quotes , as opposite before i saved, but still works ?

Yes, i wouldnā€™t use a Label like that ( or what do you mean? ) :smile:

1 Like

works as expected:

1 Like

Thanks guys!
I finally got it to work with another restart of HA and clearing the browser cache for the HA website.

Sebastian

1 Like

I tried to apply all of the below variants of this, but the icon isnā€™t getting targeted by any of the styles and is still visible.

Also tried searching in the thread for ā€œhide iconā€ and things like that, but I didnā€™t find anything, and by now the thread is so massive that I canā€™t really sift through everything in here.

      - type: custom:auto-entities
        show_empty: false
        unique: true
        card:
          type: entities
          title: Bus line 2
          icon: mdi:bus
          card_mod:
            style:
              hui-generic-entity-row:
                $: |
                  state-badge {
                    display: none;
                  }
              hui-sensor-entity-row:
                $: |
                  state-badge {
                    display: none;
                  }
                  .text-content {
                    width: 60px;
                  }
                .: |
                  state-badge {
                    display: none;
                  }
                  ha-icon.icon {
                    padding-right: 0px;
                  }
                  h1.card-header {
                    padding-bottom: 5px;
                  }
                  #states > * {
                    height: 20px;
                    width: 50px;
                  }
        filter:
          template: |-
            {% for state in states.sensor -%}
              {%- if (state.entity_id | regex_match("^sensor.bus_line_2_.*$", ignorecase=False)) -%}
                {%- if (state.attributes.time | regex_match("[0-9]{2}:[0-9]{2}:[0-9]{2}", ignorecase=True)) -%}
                  {{
                    {
                      'entity': state.entity_id,
                      'name': state.attributes.friendly_name|regex_replace(find=".*", replace=' ', ignorecase=True),
                      'card_mod':
                        {'style':
                            'state-badge {
                              display: none;
                            }'
                        }
                    }
                  }},
                {%- endif -%}
              {%- endif -%}
            {%- endfor %}

EDIT:
I got this working when I realized that I could simplify what I was doing a lot by just using a regex filter in the entity_id include directly. I could then apply the style for state-badge like this:

      - type: custom:auto-entities
        show_empty: false
        unique: true
        card:
          type: entities
          title: Bus line 2
          icon: mdi:bus
          card_mod:
            style:
              hui-sensor-entity-row:
                $: |
                  .text-content {
                    width: 60px;
                  }
                .: |
                  ha-icon.icon {
                    padding-right: 0px;
                  }
                  h1.card-header {
                    padding-bottom: 5px;
                  }
                  #states > * {
                    height: 20px;
                    width: 50px;
                  }
        filter:
          include:
            - entity_id: "/^sensor.bus_line_2_[0-3]$/"
              options:
                card_mod:
                  style:
                    hui-generic-entity-row:
                      $: |
                        state-badge {
                          display: none !important;
                        }
        view_layout:
          grid-area: mid1
1 Like

Next thing Iā€™m looking to do is to have two columns of entity values in my bus schedule card, i.e. each row would show two times like this (note that this was just an ugly edit, the second column should have times that are after the ones in the first one):

image

I would like the times to be read top to bottom so you read the entire column 1 first, then the second column, to follow the departures.

Is this possible to achieve with auto-entities, do I need to combine it with something?
Would this somehow be possible by making the div#states.card-content container force the small row divs inside to wrap up to another column?

use


  card:
    square: false
    columns: 2
    type: grid

And try to use either(or more) of the ā€œsort:ā€ options in auto-entities

Iā€™m not quite following what youā€™re suggesting, as soon as I change

        card:
          type: entities

to

        card:
          type: grid

the card configuration breaks

try to ā€œadaptā€ this to your needs

type: custom:auto-entities
card:
  square: false
  columns: 2
  type: grid
card_param: cards
filter:
  include:
    - entity_id: "/^sensor.bus_line_2_[0-3]$/"
      options:
        type: custom:mushroom-entity-card ( Or what ever card-type here , i.e type: entity )
        card_mod:
          style:

Remove the card_mod from first above ! ( And place it below, under mushroom/entity type )

This doesnā€™t seem to be on the right track, using grid is going to split the area into many small cards like the below. Can you really get them all to just gather in one card like in the mockup I photoshopped above?

image

EDIT: I managed to sort out two columns like in my mockup by adding this style to the hui-sensor-entity-row field:

                  div#states.card-content {
                    width: 100%;
                    height: 175px;
                    display: flex;
                    flex-wrap: wrap;
                    flex-direction: column;
                  }
1 Like

Ok, i understand, one have to be familiar with the various cards and their options(which you can use all of as usual under the second card section !, beside card_mod( and i donā€™t recommend mushrooms, unless you knows howto mod them as you want, however there a huge Topics/threads in this forum, with examples and tips, for card_mod and mushrooms, but also the huge cardmod_Topics, And some cards are more difficult(or different) to mod, than others
Also i have no idea how the ā€œoutputā€ of your regex look like

But if you want 2 or more ā€œcolumnā€ you should ā€œuseā€ grid !, it will fill in order(which you choose)
But you say you found another solution, so could try with mushroom-template-card or musroom-entity ( there is alot of options/card_mod examples in card_mod Topics
So ramp up your readings, maybe you find ā€œanotherā€ good example you can copy/paste

Good luck

I am testing the new sections out. Auto entities cards are taking space even if no entities match the filter. I have set ā€œshow_empty: falseā€

Any other ideas or is this just that sections are so new please?