🔹 Auto-entities - Automatically fill cards with entities

ok, thanks, and the decl_life360_battery_info_row_with_graph template?

btw, isnt the whole Idea of the decluttering card you only need to enter the Name in the card config, and then have the decluttering card do all the work?

replace:

    variables:
      - __SENSOR_BATTERY_CHARGING: binary_sensor.battery_charging_life360_mama
      - __SENSOR_BATTERY: sensor.battery_life360_mama
      - __SENSOR_LIFE360_UPDATE_ALERT: binary_sensor.life360_update_alert_mama
      - __DEVICE_TRACKER_LIFE360: device_tracker.life360_mama

with

id: mama

and move the whole section to the decluttering card to use

    variables:
      - __SENSOR_BATTERY_CHARGING: binary_sensor.battery_charging_life360_[[id]]
      - __SENSOR_BATTERY: sensor.battery_life360_[[id]]
      - __SENSOR_LIFE360_UPDATE_ALERT: binary_sensor.life360_update_alert_[[id]]
      - __DEVICE_TRACKER_LIFE360: device_tracker.life360_[[id]]

compare this decluttering template:

card:
  type: entities
  title: '[[title]] Mobile app'
  show_header_toggle: false
  entities:
    - 'device_tracker.[[id]]'
    - 'sensor.[[id]]_battery_level'
    - type: custom:fold-entity-row
      head:
        type: section
        label: Details
      entities:
        - type: custom:auto-entities
          card:
            type: entities
            style: |
              ha-card {
                box-shadow: none;
                margin: 0px -16px 0px -36px;
                }
          filter:
            include:
              - entity_id: 'sensor.[[id]]_*'

and card config using that:

  - type: custom:decluttering-card
    template: mobile_app
    variables:
      - id: mijn_mobiel
      - title: Mijn mobiel

You are absolutely right, It will decrease a volume of the code.
But I decided to use templates which do not depend on sensors’ names.
I am sorry for an offtopic here…

no, its not off topic! its about using auto-entities to create magic cards like yours! have to consume that config (I’ve only tried the template-card when it came out and stopped because it bogged my system at that time, never looked back because I’ve not needed it since.) Think you would fare well with the reduced decluttering card in this particular config.

thanks!

o, and please dm me the config for the graph 2nd template :wink:

Really, the 2nd picture do not have auto-entities at all))).
That is why I call it off topic.

OK )). I was thinking about publishing the template on the forum but decided not to do it since I am not sure about “efficiency” of this code…

I’m using the auto-entities. 3 rows high & 3 wide of glance cards for my sensors. However, each row is super close together. I was wondering if anyone has ideas for how I can space/pad them out a bit?

            - type: 'custom:auto-entities'
              card:
                type: glance
                columns: 3
              filter:
                include:
                - entity_id: binary_sensor.*contact
                  options: 
                    show_last_changed: true
              sort:
                method: last_updated
                numeric: true
                count: 9
                reverse: true

Try using card-mod:

type: horizontal-stack
cards:
  - type: 'custom:auto-entities'
    card:
      type: glance
      title: with card-mod
      columns: 3
      card_mod:
        style:
          .entities:
            .entity:
              $: |
                state-badge {
                  margin-top: 0px;
                  margin-bottom: 0px;
                }
                .name {
                  margin-top: 12px !important;
                }
                div:not(.name) {
                  margin-bottom: 12px !important;
                }
    filter:
      include:
        - entity_id: '*ping_device_tracker'
          options:
            show_last_changed: true
    sort:
      method: last_updated
      numeric: true
      count: 9
      reverse: true
  - type: 'custom:auto-entities'
    card:
      type: glance
      title: without card-mod
      columns: 3
    filter:
      include:
        - entity_id: '*ping_device_tracker'
          options:
            show_last_changed: true
    sort:
      method: last_updated
      numeric: true
      count: 9
      reverse: true
2 Likes

Thank you so much @Ildar_Gabdullin! I have tried many different methods via Google & forum search (trying not to post) and this is the only method that has actually worked. If I could press thank you again I would :smiley:

1 Like

Hey guys. Just for starters, I really love the auto-entities-Card. However since one of the updates (not sure which one) one of my auto-entities-cards broke. I’m trying to get everything to look the way it did before. And I’m getting really close, but this little thing I cannot get my head around. And I hope someone can help.

I have a view in panel mode. In the view I have an auto entities card that shows all devices I track on my network as button cards with their IP addresses.
Before the breaking change it showed 7 columns with devies, but after it only shows 4, no matter how much space I have or what I set in my card config.

This is my config:

type: 'custom:auto-entities'
card:
  type: 'custom:layout-card'
  layout: horizontal
  column_num: 7
  view_layout: horizontal
filter:
  include:
    - domain: device_tracker
      options:
        type: 'custom:button-card'
        size: 65%
        show_entity_picture: true
        style: |
          ha-card {
            background: none;
            box-shadow: none;
          }
        styles:
          grid:
            - grid-template-areas: '"i" "n" "ip"'
          card:
            - height: 130px
            - width: 130px
          name:
            - font-size: 13px
          custom_fields:
            ip:
              - align-self: center
              - justify-self: center
              - font-size: 12px
        custom_fields:
          ip: |
            [[[
              return `<span><span style="color: var(--text-color-sensor);">IP: ${states['this.entity_id'].attributes.ip}</span></span>`
            ]]]
  exclude:
    - entity_id: device_tracker.telefoon_duncan
    - entity_id: device_tracker.telefoon_sabrine
sort:
  method: friendly_name
  numeric: true

This shows like:

I have tried changing the column_num: 7 (which used to work) to columns: 7 and also setting min_columns: 7 or max_cols: 7 but nothing seems to change the number of columns. It always picks the default (4 cols without sidebar, 3 cols with sidebar). So I probably need to set the max_cols: 7 in some other place, but can’t find where.
However when I change the card type from custom:layout-card to glance, it does work…

Would really appreciate some help, as I just can’t seem to figure out why it doesn’t work anymore…

Using your config:
Note:

  1. Corrected "sort" options.
  2. Replaced “ip” custom_field with a “nothing” string.
  3. Left your layout-card definition as is.
type: 'custom:auto-entities'
card:
  type: 'custom:layout-card'
  layout: horizontal
  column_num: 7
  view_layout: horizontal
filter:
  include:
    - domain: device_tracker
      options:
        type: 'custom:button-card'
        size: 65%
        show_entity_picture: true
        style: |
          ha-card {
            background: none;
            box-shadow: none;
          }
        styles:
          grid:
            - grid-template-areas: '"i" "n" "ip"'
          card:
            - height: 130px
            - width: 130px
          name:
            - font-size: 13px
          custom_fields:
            ip:
              - align-self: center
              - justify-self: center
              - font-size: 12px
              - color: red
        custom_fields:
          ip: '[[[ return ''nothing'' ]]]'
  exclude:
    - entity_id: device_tracker.life360*
    - entity_id: device_tracker.*ping*
    - entity_id: device_tracker.*_*_*
sort:
  method: friendly_name
  ignore_case: true
  numeric: false

Using CORRECTED layout-card definition:

type: 'custom:auto-entities'
card:
  type: 'custom:layout-card'
  layout_type: 'custom:horizontal-layout'
  layout:
    max_width: 250
    max_cols: 7
filter:
  include:
    - domain: device_tracker
      options:
        type: 'custom:button-card'
        size: 65%
        show_entity_picture: true
        style: |
          ha-card {
            background: none;
            box-shadow: none;
          }
        styles:
          grid:
            - grid-template-areas: '"i" "n" "ip"'
          card:
            - height: 130px
            - width: 130px
          name:
            - font-size: 13px
          custom_fields:
            ip:
              - align-self: center
              - justify-self: center
              - font-size: 12px
              - color: red
        custom_fields:
          ip: '[[[ return ''nothing'' ]]]'
  exclude:
    - entity_id: device_tracker.life360*
    - entity_id: device_tracker.*ping*
    - entity_id: device_tracker.*_*_*
sort:
  method: friendly_name
  ignore_case: true
  numeric: false

Using Grid card:

type: 'custom:auto-entities'
card:
  type: grid
  columns: 7
card_param: cards
filter:
  include:
    - domain: device_tracker
      options:
        type: 'custom:button-card'
        size: 65%
        show_entity_picture: true
        style: |
          ha-card {
            background: none;
            box-shadow: none;
          }
        styles:
          grid:
            - grid-template-areas: '"i" "n" "ip"'
          card:
            - height: 130px
            - width: 130px
          name:
            - font-size: 13px
          custom_fields:
            ip:
              - align-self: center
              - justify-self: center
              - font-size: 12px
              - color: red
        custom_fields:
          ip: '[[[ return ''nothing'' ]]]'
  exclude:
    - entity_id: device_tracker.life360*
    - entity_id: device_tracker.*ping*
    - entity_id: device_tracker.*_*_*
sort:
  method: friendly_name
  ignore_case: true
  numeric: false

That works like a charm! Thank you very much! I just couldn’t see it anymore after al there hours of staring :laughing:

Hello,

with the auto-entities card i like a list of temperature devices whose battery_level is below 60%
this works, but my friendly names are composed like temperatuur batterijniveau tuin (translate temperature battery_level garden). I want to strip the temperatuur batterijniveau part, its in all of the names, so a bit redundant.

I tried several options with the options setting but so far no luck, all i tried to put in is taken literally and displayed as name so no name regex replace possibility so far as I can see. anybody out here with a solution?

type: 'custom:auto-entities'
card:
  type: entities
  state_color: true
  title: Batterij laag temperatuursensoren
filter:
  include:
    - entity_id: sensor.*temp*_batterijniveau*
      state: < 60
      options:
         name: ??????????????????????????????????????
  exclude:
    - entity_id: sensor.beweginglichtsterktetemp*
sort:
  method: state
  reverse: true
show_empty: true

temperatuurlaag

you cant directly in auto-entities, but you could have a go at template-entity-row in the options

Kind of this:

filter:
  template: |
    {% set batteries = expand('group.batteries') -%}
    {%- for battery in batteries -%}
      {%- set NAME = battery.entity_id -%}
      {%- set NAME_SHORT =  NAME.split('sensor.battery_')[1] -%}
      {{
        { 'entity': battery.entity_id,
          'name': NAME_SHORT,
          'secondary_info': 'last-changed'
        } }},
    {%- endfor -%}

O yes, I forgot about the template option, not sure if it will go all the way though, fulfilling all necessary requirement here. At least should add:

if battery.state|int < 20

to make it

{%- for battery in batteries if battery.state|int < 60 -%}

using the template entity row is way more flexible though:

      - type: custom:auto-entities
        card:
          type: entities
          style: |
            ha-card {
              box-shadow: none;
              margin: 0px 0px 0px -36px;
            }
        filter:
          include:
            - group: group.github_repos_in_use
              options: &github_options
                tap_action:
                  action: more-info
                hold_action:
                  action: navigate #url
                  navigation_path: /ui-settings/weblinks
                  #url_path: >
                  #  {{state_attr('this.entity_id','latest_release_url')}}
                type: custom:template-entity-row
                style: |
                  :host {
                    --paper-item-icon-color:
                      {% set id = config.entity.split('.')[1] %}
                      {% set repo = 'input_boolean.' + id %}
                      {{'gold' if is_state(repo,'on') else 'green'}}
                      ;
                state: >
                  {% if states(config.entity) is not none %}
                    {% if state_attr(config.entity,'latest_release_tag') %}
                    {{state_attr(config.entity,'latest_release_tag')}}
                    {% else %} {{states(config.entity)}}
                    {% endif %}
                  {% else %} Unknown
                  {% endif %}
                secondary: >
                  {% if states(config.entity) == 'unavailable' %} Unavailable
                  {% elif states(config.entity) is not none %}
                    {{state_attr(config.entity,'latest_commit_message')}}
                  {% else %} Unknown
                  {% endif %}
              sort:
                method: name

You are right!
This was a good educational example.

Hi guys,

Thanks for the hint, will try the template and template-entity-row option, and Marius sorry to say but your educational example way to complicated, way to steep for a beginner to even get a glance of whats its doing in relation to my question, thanks for letting me know what the possibilities are but in no way Iam at your level, just scratching the surface here :wink:

regards Frank

These examples are very useful for learning ))) and they are not too complicated, just get rid of unimportant things.

You are absolutely right, but I see it as, I asked to teach me how to ride a bike, and the example put me in a space shuttle, overwhelmed, and going stripping till I get the results I want not gonne cut it starting with the whole

style: |
:host {

thing, no mention of it in the custom:template-entity-row documentation, even google has no answer on the search home assistant :host

So, good example yes, but not for beginners, sorry…

Those “style” things are for “card-mod”.
Try learning this example (without card-mod):

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          include:
            - group: group.github_repos_in_use
              options:
                type: custom:template-entity-row
                state: >
                  {% if states(config.entity) is not none %}
                    {% if state_attr(config.entity,'latest_release_tag') %}
                    {{state_attr(config.entity,'latest_release_tag')}}
                    {% else %} {{states(config.entity)}}
                    {% endif %}
                  {% else %} Unknown
                  {% endif %}
                secondary: >
                  {% if states(config.entity) == 'unavailable' %} Unavailable
                  {% elif states(config.entity) is not none %}
                    {{state_attr(config.entity,'latest_commit_message')}}
                  {% else %} Unknown
                  {% endif %}
              sort:
                method: name

I will try learning it too since "template-entity-row" is a new thing for me too )))

basically what this does, is use the auto-entities card, set it to display entities in an entities card, which it should get from the entities in the group. (if you want, you can also use the other options of auto-entities, but the group is very easy)

It should do that, using the specified options. In this case I suggested the template-entity-row, with which you can set anything (state, icon, name etc etc, see the options there) with a template.

for that you use the config.entity (you dont hard code any entities, since this is created automatically) and the templates are for that entity. Depending on your naming, you should adjust the template.
Dont quote config.entity in those templates, since it is a system variable, and not a string.
What is your naming convention in the sensors?