🔹 Auto-entities - Automatically fill cards with entities

I am trying to populate the entities with filter: template: but I would like to change the display name of each entity based on their entity_id. It seems like something using options: as in this solution. It just seems like options: won’t work with filter: template:. I am open to any approach to solve this problem.

Basically I am trying to display all the settings I have configured by room, or by behavior (motion light activation, circadian/adaptive lighting, etc.) but I have to display the input_boolean/input_select/input_switch with a different name for each of these configuration methods. When showing settings by room, I need to display the behavior as the display name of the settings entity. When showing settings by behavior, I need to display the room as the display name of the settings entity.

I created this template which gathers the data I need into lists, but I’m not sure what the best way to turn this into the display I am aiming for.

{% if states('input_select.settings_behavior') == "Motion Activation" %}
  {% set behavior_entity_type = 'input_boolean' %}
  {% set behavior_regex = '\'input_boolean\.((?!motion_lights)[^\'])+\',?' %}
{% elif states('input_select.settings_behavior') == "Natural Lighting" %}
  {% set behavior_entity_type = 'switch' %}
  {% set behavior_regex = '\'switch\.((?!adaptive_lighting_(?!adapt|sleep))[^\'])+\',?' %}
{% endif %}
{% set entity_list = (states[behavior_entity_type] | map(attribute='entity_id') | list | regex_replace(behavior_regex)) %}
{% set area_list = (entity_list | regex_replace('input_boolean.motion_lights_')) %}
{{ [entity_list, area_list] | regex_replace('"\[','[') | regex_replace('\]"',']') }}

I also tried using config-template-card to create do the switching, but I’m having trouble getting this working.

      - type: entities
        entities:
          - input_select.settings_behavior
      - type: custom:config-template-card
        entities:
          - input_select.settings_behavior
        variables:
          behavior_prefix: |
            if (states[ 'input_select.settings_behavior' ].state === "Motion Activation") {
              return 'input_boolean.motion_lights_';
            } else if (states[ 'input_select.settings_behavior' ] === "Natural Lighting") {
              return 'switch.adaptive_lighting_';
            }   
          behavior_regex: |
            if (states[ 'input_select.settings_behavior' ].state === "Motion Activation") {
              return 'input_boolean.motion_lights*';
            } else if (states[ 'input_select.settings_behavior' ] === "Natural Lighting") {
              return '/switch\.adaptive_lighting_(?!adapt|sleep)/';
            }   
        card:
          type: custom:auto-entities
          card:
            type: custom:auto-entities
            card:
              type: entities
              title: 'Areas'
            filter:
              include:
                - entity_id: ${behavior_regex}
                  options:
                    type: 'custom:template-entity-row'
                    name: |
                      {{ config.entity.split(${behavior_prefix})[-1] | regex_replace('_', ' ') | capitalize }}

The only other way I can think to do it is with a very big custom:state-switch card containing a bunch of auto-entities cards. Which seems like a headache to come back to if I need to add more settings.

First of all, a huge thank you to @thomasloven for this fabulous card.
I confess to not having read all the posts, so please bear with me if my question has already been answered.
I would love to be able to sort by the most recent entry. Is that already possible?

Do you mean "last-changed"?

No, I mean last added to HA.

I do not know any exposed property expressing a “creation time” for entity.
If it is not present - then it is not possible to sort by it.
So, first find out about this property.

Could someone help me I can NOT figure out how to make the background transparent on this card. With my code as is the background is transparent when in the editor. soon as I save it does not show as transparent.

type: 'custom:auto-entities'
show_empty: false
style: |
  ha-card {
   background-color: transparent;
  }
card:
  type: entities
  title: Currently On / Running
  show_header_toggle: false
  style: |
    ha-card {
     background-color: transparent;
    }
filter:
  include:
    - domain: light
    - domain: switch
  exclude:
    - state: 'off'
    - state: unavailable
    - entity_id: light.desk_wall_right_light
    - entity_id: light.desk_wall_left_light
    - entity_id: light.wood_stove_l_e_ds
    - entity_id: light.fam_tv_l_e_ds
    - entity_id: light.family_room_wall_l_e_ds
    - entity_id: switch.g3syn_home_mode
    - entity_id: light.his_bed_l_e_ds
    - entity_id: light.his_room_access_point
    - entity_id: light.my_lights
    - entity_id: light.google_wifi_ap_a
    - entity_id: light.google_wifi_ap_b
    - entity_id: light.family_room_bulb_1
    - entity_id: light.family_room_bulb_2
    - entity_id: light.family_room_bulb_3
    - entity_id: light.family_room_bulb_4
    - entity_id: light.fire_side_bulb_1
    - entity_id: light.fire_side_bulb_2
    - entity_id: light.fire_side_bulb_3
    - entity_id: light.boiler_room_bulb_1
    - entity_id: light.boiler_room_bulb_2
    - entity_id: light.basment_bulbs
    - entity_id: light.fire_side_bulbs
    - entity_id: light.family_room_bulbs

The 1st style will not work.
The 2nd style works:

But does it still work after you save and return to the dashboard? Soon as I do it reverts to the default theme even with red. This is really messing with me as even when i go back to “edit” it will blink red and go back to the dark mode default. I have MANY cards on my setup and this one is the ONLY 1 that wont go transparent.

I do not see any flickering.
I tested this case with a card which is not placed inside some other card.
Could you provide a whole code for your card?
Also, I am using a default Lovelace theme.

OMG, you were 100% right! I moved it to a stand-alone card and BOOM it worked! HTF I did not try that months ago I don’t know… Thank you so much go’s to show some times you just need a kick in the but. haha

Is there a way to also automatically list all attributes from an entity? An auto-attributes card, if you so like?

Hey, is there a way to always show the newest “entry”, i.e. just showing one entry? Using layout cards it is supposed to always show the media control card of the device it is currently playing on, but due to the Spotify Integration, there are always two - The normal spotify one, and then the one from the device it is actually playing on.

Any help?

  1. template: A jinja2 template evaluating to a list of entries to include.
  2. include: A list of filters specifying which entities to add to the card.
  3. exclude: A list of filters specifying which entities to remove from the card.
    NavyArmyCCU Login

spam? typo?

I have tried to find an answer, but there is already so much going on here, so maybe it was already answered:
Would it be possible to extend it to allow adding more complicated stuff in the “card” parameter?

I am working on an integration that will show the status of my packages. The entities have some attributes that I would like to show with the entity-attributes-card (GitHub - custom-cards/entity-attributes-card: Entity Attributes, but I am assuming this applies to a lot of other cards as well).

I have tried using the template approach, but basically I am limited to 1 line per entity, which is too limiting.

This is how 1 card looks like, I would like to have it repeated for everything the auto-entities card includes and have the possibility to use some kind of placeholders for the entity

type: entities
title: Entities card
  entities:
  - <entity placeholder required here>
  - type: 'custom:entity-attributes-card'
    entity: <entity placeholder required here>
    heading_name: Name
    heading_state: State
    filter:
      include:
        - <entity placeholder required here>.Sender

You can see that on the last line I would even need to concatenate with another string.

Is that something that is already possible/that would be possible to implement?

I am stuck with the "sort::count" property.
The property is supposed to reduce a number of displayed items.
But it does not work for me - look at this list of sensors with "unknown" state:

type: vertical-stack
cards:
  - type: 'custom:auto-entities'
    card:
      type: entities
    unique: true
    show_empty: true
    filter:
      include:
        - domain: sensor
          state: unknown
          sort:
            method: name
            reverse: false
            ignore_case: true
            first: 0
            count: 5
            numeric: false

Here is just a part of the card - it shows more than 5 items:
image
Why the "count" property does not work?

Here is a strange thing - let’s move the "sort" options to the “root” level:

type: vertical-stack
cards:
  - type: 'custom:auto-entities'
    card:
      type: entities
    unique: true
    show_empty: true
    filter:
      include:
        - domain: sensor
          state: unknown
    sort:
      method: name
      reverse: false
      ignore_case: true
      first: 0
      count: 5
      numeric: false

Now it works:
image

Is it a bug?
Registered a new issue - "count" option works only for global sort options · Issue #194 · thomasloven/lovelace-auto-entities · GitHub


Update (19.05 21 00:29 GMT+03): seems to be fixed in 1.9.0

Under the Sort: count: Can a variable be used instead of a static number. I would like to use an input number into the count. This way I can change how many shoe in the card.
sort:
method: state
numeric: true
count: 3

Instead like this
count: “{{states(‘input_number.daystoshow’)}}”
Doesn’t seem to work

Use "template" feature for this.

Not sure how to do that for the count.

Hey all. Any idea why this filter is including items with the status “Replace”, but not those with the status “yellow” or “off”? I’ve double and triple checked in the dev tools state to make sure I was using exactly the right string as what I defined, but it just seems to like some and not others.

  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
      title: Devices Reporting Problems
      show_header_toggle: false
    filter: 
      include: 
        - entity_id: "*nest*"
          state: "unavailable"
          state: "Warning"
          state: "grey"
          state: "yellow"
          state: "off"
          state: "dead"
          state: "disconnected"
          state: "warning"
          state: "critical"
          state: "failing"
          state: "access error"
          state: "Replace"