🔹 Auto-entities - Automatically fill cards with entities

you should set the card you want to use for final display in the options section like here:

  - type: custom:auto-entities
    card:
      type: entities
      title: Multiple lights
    show_empty: false
    filter:
      include:
        - domain: light
          state: 'on'
          attributes:
            rgb_color: '! none'
          options:
             type: custom:multiple-entity-row
             toggle: true
             secondary_info: last-changed
             entities:
               - entity: this.entity_id
                 attribute: brightness
                 name: Bri
                 unit: '%'
               - entity: this.entity_id
                 attribute: rgb_color
                 name: Rgb
      exclude:
        - entity_id: light.party_lights

so, first set the filtering for auto-entities to find the set of entity_id’s you need, next set how you want these to be displayed.

Translated to your requirements:

    - type: custom:auto-entities
      card:
        type: entities
        title: Multiple cameras
      show_empty: false
      filter:
        include:
          - domain: camera
            options:
               type: custom:hui-element
               card_type: picture-entity
               show_state: true
               show_name: true
               camera_view: live

note this is an entities card, which gets populated with camera entities, and you would probably want some card_mod styling to not use a box-shadow, and some margin to fill the entities space better.

          - domain: camera
            options:
               type: custom:hui-element # this is required for most cards to be listed in an entities cards
               card_type: picture-entity
               card_mod:
                 style: |
                   ha-card {
                     box-shadow: none;
                     margin: -8px -16px;
                   }
               show_state: true
               show_name: true
               camera_view: live

you could also use a grid card:

    - type: custom:auto-entities
      card:
        type: grid
        title: Multiple cameras
      card_param: cards
      show_empty: false
      filter:
        include:
          - domain: camera
            integration: unifiprotect # filters out non cctv cams like weather etc
            options:
               type: custom:hui-element
               card_type: picture-entity
               show_state: true
               show_name: true
               camera_view: live
        exclude:
          - state: unavailable

which in my opinion is just that bit more elegant for cards like these.
note Ive also filtered the unavailable cams, which in my config are the ones that only get powered when the alarm is active :wink:

let us now what your experience is, because here, the good cards update with some flickering, while the entities card seems more stable. though still the odd flickering there. seems the constant evaluating of the states in auto-entities doesnt play nicely with the camera refresh

Hi- is there a way to set the numeric precision of entity state values, ie the number of digits after the decimal point?

Thanks I must not have understood the docs since I though the card type for the entities was declared under card: . Its working great now (until I break it again lol)

Hi. Lots of messages in this thread. Pardon me if I missed the answer. I don’t understand why my sorting does not work. What am I missing ?

I checked state of the Doorbell battery level. It is numeric.

state_class: measurement
unit_of_measurement: %
device_class: battery
friendly_name: doorbell Battery percentage

please post yaml, and no screenshots…

set the

    sort:
      method: state
      numeric: true

on the filter level

With conventional entity rows:

code
type: custom:auto-entities
card:
  type: entities
unique: true
show_empty: true
filter:
  include:
    - entity_id: sensor.*traccar*
      attributes:
        device_class: battery
      sort:
        method: state
        reverse: false
        numeric: true

Hey Tx :slight_smile: Works indeed much better.

type: custom:auto-entities
card:
  type: custom:battery-state-card
filter:
  include:
    - entity_id: '*battery*'
  exclude:
    - entity_id 1: '*state'
    - entity_id 2: '*health'
    - entity_id 3: '*power'
    - entity_id 4: '*temperature'
sort:
  method: state
  reverse: false
  numeric: true

I’d like to add a tap-action in my template.
How can I do this?

type: custom:auto-entities
filter:
  template: |-
    {% for x in states.climate -%}
      {{
        {
          'type': 'custom:mushroom-climate-card',
          'show_temperature_control': true,
          'layout': 'horizontal',
          'entity': x.entity_id,
          'tap-action': '',
             'action':'more-info',
          'name': state_attr(x.entity_id, 'friendly_name')|replace('Thermostat ', '')
        }
      }},
    {%- endfor %}
show_empty: true
card:
  square: false
  columns: 1
  type: grid
card_param: cards
sort:
  method: friendly_name

isn’t more-info the action by default already?

what happens if you don’t specify that at all?

no, it toogles then :slight_smile:

I see, use:

                'tap_action':
                  {'action':'more-info'}

and it shows more-info

btw, its the same behavior using:

    - type: custom:auto-entities
      filter:
        include:
          - domain: climate
            options:
              type: custom:mushroom-climate-card
              show_temperature_control: true
              layout: horizontal
              # required because default action is not what documentation claims
              tap_action:
                action: more-info

and a bit surprising indeed. should be the default, as documented, and no reason auto-entities would interfere there

fear its a bug in the mushroom-climate card:

    - type: custom:mushroom-climate-card
      show_temperature_control: true
      layout: horizontal
      entity: climate.heater_dorm

does not more-info either…

1 Like

thanks a lot.
I started without template, but then I couldn’t find out, how to rename. That’s why I had to go with a template.

yes, the renaming needs another setup, but I figured that wasnt the main point if your question now. got to remember that in those template filters, you simply need to embrace the objects/dicts with braces to keep them together.
read this primer by Thomas: Thomas Lovén - YAML for Non-programmers

it seems like it’s not going to work after all.
Still toggles, and does not show more info.
Here is my code, any mistake?

type: vertical-stack
cards:
  - type: custom:mushroom-title-card
    title: ''
    subtitle: Einstellung
  - type: custom:auto-entities
    filter:
      template: |-
        {% for x in states.climate -%}
          {{
            {
              'type': 'custom:mushroom-climate-card',
              'show_temperature_control': true,
              'layout': 'horizontal',
              'entity': x.entity_id,
              'name': state_attr(x.entity_id, 'friendly_name')|replace('Thermostat ', ''),
              'tap-action':
                 {'action':'more-info'}
            }
          }},
        {%- endfor %}
    show_empty: true
    card:
      square: false
      columns: 1
      type: grid
    card_param: cards
    sort:
      method: friendly_name

should be tap_action:

you can also do:

'tap_action': {'action':'more-info'}
1 Like

Could you please clarify with example.
I would like to get a dynamic value for sort: count: but no success :frowning:

Show us your unsuccessful attempt with defining a sort inside the “template” option, we’ll try to fix it.

Is there any way to filter two groups at once? How to?

The current value of input_number.auto_entities_sort_count in the Template editor:

{{ states('input_number.auto_entities_sort_count')|int }}
6
    sort:
      method: state
      reverse: true
      numeric: true
      count: |
        template: > 
          {%-   if states('input_number.auto_entities_sort_count')|int == 6 %} 6
          {%- elif states('input_number.auto_entities_sort_count')|int == 8 %} 8
          {%- elif states('input_number.auto_entities_sort_count')|int == 10 %} 10
          {% endif %}

You cannot use a “template” option INSIDE any other option, it must be only inside the “filter” option.