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

Thanks. I got it to work with this:

card:
  type: entities
filter:
  template: >-
    {{states.light | selectattr('entity_id', 'in',
    area_entities(states.input_select.room_selection.state)) |
    map(attribute='entity_id') | list }}

BUT I cannot get custom:bubble-card to populate for entities as this doesnā€™t work properly, it shows ALL lights. Any ideas? Is there a way to use template without it being overriden/ignored by include?

card:
  type: grid
  columns: 2
  square: false
card_param: cards
filter:
  template: >-
    {{states.light | selectattr('entity_id', 'in',
    area_entities(states.input_select.room_selection.state)) |
    map(attribute='entity_id') | list }}
  include:
    - domain: light
      state: 'on'
      options:
        type: custom:bubble-card
        card_type: button
        button_type: slider
        show_attribute: false
        show_last_changed: true
        show_state: true
  exclude: []

You can use any of these combinations:

  • include
  • include + exclude
  • template

Means - all ā€œoptionsā€ must be a part of a template.
Search here, there are ready examples.

Yeah, I think me adding the ā€œdomain: lightā€ overrides my template to select only lights with the matching area name. I cannot get the options to work in template

Got it to work! Itā€™s beautiful. That wasnā€™t as simple as I thought it would be.

card:
  type: grid
  columns: 2
  square: false
card_param: cards
filter:
  template: >-
    {%- for s in states.light|selectattr('entity_id', 'in',
    area_entities(states.input_select.room_selection.state)) -%}
      {{
        {
          'type': 'custom:bubble-card',
          'card_type': 'button',
          'entity': s.entity_id,
          'button_type': 'slider',
          'show_last_changed': 'true',
          'show_state': 'true'
        }
      }},
    {%- endfor %}
sort:
  method: state
  numeric: true

Iā€™ve got a card counting down our birthdays (itā€™s kinda thing within our household). got a very simple piece of code, but would like to see the whitespaces between the entities to be less.

Code:

type: custom:auto-entities
show_empty: false
card:
  title: Verjaardagen
  type: entities
entities: null
filter:
  include:
    - entity_id: sensor.verjaardag*
    - entity_id: sensor.anniversar*
sort:
  method: state
  ignore_case: false
  reverse: false
  numeric: true

image

I have searched this topic and the github page, but canā€™t seem to find it, or I donā€™t know what iā€™m looking for. Does anyone know how to do this?

All you need to do is target your card element with card_mod:

card:
  title: Verjaardagen
  type: entities
  card_mod:
    style: |
      #states > * {
        margin: 0 !important;
      }

Youā€™ll need to have card_mod installed for this:

2 Likes

Try something like this:

type: custom:auto-entities
show_empty: false
card:
  type: custom:layout-card
  layout_type: grid
  layout:
    grid-template-columns: repeat(auto-fit, minmax(185px,1fr))
card_param: cards
filter:
  include:
    - domain: switch
      area: escritorio
      options:
        type: tile
        color: red
        show_entity_picture: false
        tap_action:
          action: toggle
        icon_tap_action:
          action: more-info
  exclude:
   

Change the filter for your needs.

I am trying to replicate sub_button and grids within grids. Any ideas how to do that with auto-entities?

Hereā€™s an example:

square: false
type: grid
cards:
  - type: custom:bubble-card
    card_type: separator
    name: ROOM1
    sub_button:
      - name: '1'
        show_name: true
        icon: mdi:lightbulb
        show_background: false
        tap_action:
          action: none
  - type: custom:bubble-card
    card_type: separator
    name: ROOM2
  - square: false
    type: grid
    cards:
      - type: custom:bubble-card
        card_type: button
        entity: light.living_room_floor_lamp
      - type: custom:bubble-card
        card_type: button
        entity: light.living_room_floor_lamp
    columns: 2
columns: 1

Here is what I can do now (I have it all in 1 column, but it does populate every light assigned to each room)

type: custom:auto-entities
card:
  type: grid
  columns: 1
  square: false
card_param: cards
filter:
  template: |-
    {% for option in state_attr('input_select.room_selection','options') -%}
      {%- if states.light|selectattr('entity_id', 'in',area_entities(option))|list|count -%}
        {{
          {
            'type': 'custom:bubble-card',
            'card_type': 'separator',
            'name': option,
            'card_layout': 'normal',
          }
        }},{%- for s in states.light|selectattr('entity_id', 'in',
      area_entities(option)) -%}
        {{
          {
            'type': 'custom:bubble-card',
            'card_type': 'button',
            'entity': s.entity_id,
            'button_type': 'slider',
            'show_last_changed': 'true',
            'show_state': 'true'
          }
        }},
      {%- endfor %}{% endif -%}
    {%- endfor %}
view_layout:
  position: main


Could you add a way to template the name? Itā€™s very very often that when I have a group of entities that requires using this custom card, that they all share something in the name that I want to take out.

1 Like

Just wanted to share this little thing i came up with:

Auto entities lists all my areas and creates a area-card with temp, humidity and luxā€¦ still working on how to get a different icon for each area, dont wanna rename my rooms, but could be a possibilityā€¦

type: custom:auto-entities
filter:
  template: |
    [ {% for omrade in areas()|sort %}
      {{ 
        {
        'type': 'custom:streamline-card', 
        'template': 'klimakort',
        'variables': [
        {'entry': omrade}
          ]
        } 
      }} 
      , 
    {% endfor %}  ]
  include: []
  exclude: []
card:
  square: false
  type: grid
  columns: 2
show_empty: true
card_param: cards
sort: {}

and a decluttering card (streamline-cardā€¦ because that has a gui-editor lol)

streamline_templates:
  klimakort:
    card:
      type: custom:mushroom-template-card
      primary: '{{area_name(''[[entry]]'') | title }}'
      secondary: >-
        {% set temp = (area_entities('[[entry]]') | select('is_state_attr',
        'device_class', 'temperature') | map('states') | select('is_number') |
        map('float') | list or [0]) | average | round(1) %}

        {% set hum = (area_entities('[[entry]]') | select('is_state_attr',
        'device_class', 'humidity') | map('states') | select('is_number') |
        map('float') | list or [0]) | average %}

        {% set lux = (area_entities('[[entry]]') | select('is_state_attr',
        'device_class', 'illuminance') | map('states') | select('is_number') |
        map('float') | list or [0]) | average | round(1) %}

        {{ [ ('šŸŒ”ļø' ~ temp|int ~ 'Ā°C') if temp, ('šŸ’§' ~ hum | int ~ '%') if hum,
        ('šŸ”†' ~ lux | int ~ 'lx') if lux] | select() | join(' ') }}
      icon: hue:room-office
      entity: '[[entry]]'
      fill_container: true
      tap_action:
        action: navigate
        navigation_path: '#popup-[[entry]]'
      layout: vertical

2 Likes

Doesnā€™t the normal area card do exactly what the custom area template card youā€™re making does? Even shows the icons for each area

Yes it does but imo its fugly and dosent fit the rest of my design :see_no_evil:

I just activated all ā€œlast seenā€ attributes of the entities:
image

It should be possible to sort the entities regarding to their last seen status or not?
Can anybody help me to get the correct yaml working?
I am struggling with it :frowning:

edit:
got it:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: sensor.*_last_seen
sort:
  method: last_changed
  numeric: false
  reverse: false
1 Like

Does this mean that, if I have 20 sensors with a specific attribute I want to show on this card, I need to create 20 template sensors out of that attribute to be able to use the auto entities card?

Probably that advice was given when Entities card was not supporting ā€œattributeā€.

Alright, Iā€™ve come back to this - I have a lot of great auto-entities cards made on my dashboard now and yet itā€™s the original one that is messing with me the worst. Hereā€™s what Iā€™ve got:

type: custom:auto-entities
show_empty: true
card_param: chips
card:
  type: custom:mushroom-chips-card
  alignment: justify
filter:
  include:
    - domain: scene
      area: Living Room
      options:
        type: entity
        content_info: name
        tap_action:
          action: toggle
  exclude: []
sort:
  method: friendly_name

This is nice, except that it causes the scene to toggle on instantly. This is kind of abrupt when Iā€™m wanting to set the scene when we have guests.

Hereā€™s the data from the chips card if I want to have it call the action to turn on a scene:

type: custom:mushroom-chips-card
chips:
  - type: entity
    entity: scene.SCENENAME
    icon_color: accent
    tap_action:
      action: perform-action
      perform_action: scene.turn_on
      target:
        entity_id: scene.SCENENAME
      data:
        transition: 5

Iā€™ve tried just copying and pasting the tap-action into the options field in Auto Entities but it does not want to pick a specific entity to target. Iā€™m not even messing with the transition value until I can get the auto entities - chips interaction to work. The syntax I used to try to accomplish that is

tap_action:
  action: perform-action
  perform_action: scene.turn_on
  target:
    entity_id: []

What am I missing?

Not using any mushrooms. Try this way:

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - domain: switch
      options:
        type: simple-entity
        tap_action:
          action: perform-action
          perform_action: switch.toggle
          target:
            entity_id: this.entity_id

I am simply listing the scenes with their picture, like this (decluttering card template):

    - type: custom:auto-entities
      card:
        type: grid
        columns: 8
      card_param: cards
      filter:
        include:
          - domain: scene
            area: '[[area_id]]'
            options:
              type: custom:button-card
              template: button_scene

resulting in:

or with a simple listing:

      - type: custom:auto-entities
        card:
          type: entities
          title: Nu scening
          card_mod:
            class: class-header-margin
        show_empty: false
        filter:
          include:
            - attributes:
                dynamics: dynamic_palette

resulting in

and nothing gets initiated automatically

what happens if you just leave out the action?

Edited the original post - realized I had the bad syntax in instead of the working one on the original example

@Ildar_Gabdullin why no mushroom cards? I have been using these cards since day 1 - I like the look and the ease of configuration.

@Mariusthvdb The lack of action on each button gets me a nice list on the dashboard with no way to easily apply them from the dashboard. Using

action: 
  action: toggle

Works, but it applies the scene with zero fade. There is no option with the toggle to have a transition - I tried.

Do not like round design, do not like seeing lot of space wasted.
I already proposed you a way of defining a target, did it work in your card?