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

type: custom:auto-entities
show_empty: false
card:
  type: vertical-stack
card_param: cards
filter:
  template: |-
    [{% set area_filter = states('input_select.room') %}
    {%- for light in area_entities(area_filter) | select('search', '^light.') -%}
      {{ { 'type': 'custom:mushroom-light-card',              
            'entity': light,
            'use_light_color': 'true',
            'show_brightness_control': 'true',
            'show_color_control': 'true',
            'collapsible_controls': 'true',
            'show_color_temp_control': 'true', } }},
    {%- endfor %}]
1 Like

Is it possible to sort by two methods?

For example:

sort:
  method: state, entity_id
  reverse: true

Team,
Iā€™m trying to get a list of entities with values that are rounded, without having to create a lot of template sensors.
image

  - type: custom:auto-entities
    card:
      type: entities
    filter:
      include:
        - entity_id: sensor.energy_.*_daily

As you can see the values are horrible.
The reason for using auto-entities or similar is the fact that I can click any of these to see ā€œmore-infoā€. I tried to combine auto-entities with state-entity-row without luck.

Any ideas how I could accomplish this?

DJ

Right after posting this question I found a way to do this: :grin: :grin:

  - type: custom:auto-entities
    card:
      type: entities
      title: yesyes
    filter:
      include:
        - entity_id: sensor.energy_.*_daily
          options:
            type: custom:template-entity-row
            state: >-
              {{ states('this.entity_id') | round(1) }} kWh

Result:
image

2 Likes

Where am I going wrong? The button press proceeds without the confirmation.

        - type: custom:auto-entities
          card:
            type: entities
            title: Battery Maintenance
          filter:
            include:
              - entity_id: "button.*_battery_replaced"
                options:
                  tap_action:
                    action: call-service
                    confirmation:
                      text: "Are you sure?"
                    service: button.press
                    target:
                      entity_id: this.entity_id
          sort:
            method: last_changed
            reverse: true

did you test the action on an individual (test) button?

Interesting ideaā€¦ I didnā€™t, so I tried it now, but I did realise something.

I found that it works if I click on the name, but not on the button (both when using auto-entities and an entities card directly).

Is my expectation wrong here that it should work for the button?

need to check that, but yes, I do seem to remember unexpected difference in operating the name and the button. let me check what I have on that.

can at least confirm what you report:

clicking either icon or name popup the confirmation, clicking the ā€˜Klikā€™ button immediately performs the action. (or, does Not pop up the confirmation ā€¦ didnt check whether the identify was successfully performed)

Suppose that would at least be unexpected and warrant a Frontend Issue/Discussion

found thisā€¦ No confirmation with toggle switch on Entities card Ā· Issue #19509 Ā· home-assistant/frontend Ā· GitHub, and seems to be per design.

I believen your solution here can be this:

  - entity: button.lightbulb_identify
    type: button #<--- this makes it respond to the Button, and to the button only
    tap_action:
      action: call-service
      service: button.press
      confirmation:
        text: "Are you sure?"

btw, what card is that (given the 3 bullets at the bottom)? Is it swipe card?

1 Like

Thanks for confirming, Marius, and for your research.

Iā€™ll try your suggestion. The other option I thought of since was to make it a simple entity, but as pointed out in the GitHub discussion, thatā€™s a bit awkward. I think your suggestion will work better. Iā€™ll try it later.

EDIT: @Mariusthvdb Iā€™m happy with your suggestion. It works just fine in this case. Thanks again.

As for the bullets: Yes, itā€™s an auto-entities card is within a custom swipe card.

1 Like

Iā€™ve implemented the following listing of all my groups:

type: custom:auto-entities
card:
  type: entities
  title: All groups
  show_header_toggle: false
  state_color: true
  theme: Mushroom Shadow
filter:
  include:
    - domain: group
      options:
        type: custom:fold-entity-row
        group_config:
          secondary_info: last-changed
          state_color: true
sort:
  method: friendly_name

But how to list all labels and their assigned entities?
The same question for areas and floors.

Not sure I entirely understand what you mean - but there is a filter criteria for labels.

e.g. (not tested)

type: custom:auto-entities
card:
  type: entities
  title: All labels
  show_header_toggle: false
  state_color: true
  theme: Mushroom Shadow
filter:
  include:
    - label: MYLABEL
      options:
        type: custom:fold-entity-row
        group_config:
          secondary_info: last-changed
          state_color: true
sort:
  method: friendly_name

Hi all,
I am hitting a wall and hope you can help me out!
My goal is to automatically create a specific cover card for each cover entity in my home.

This is what my manual cover card looks like:

My manual cover card
type: custom:stack-in-card
cards:
  - type: custom:mushroom-cover-card
    entity: myentity
    fill_container: false
    name: Jalousien
    show_position_control: true
    show_buttons_control: true
    show_tilt_position_control: false
  - type: custom:mushroom-chips-card
    chips:
      - type: entity
        entity: script.cover_tilt_up
        icon: mdi:window-shutter-open
        content_info: name
        tap_action:
          action: call-service
          service: script.cover_tilt_up
          data:
            entity_id: myentity
          target: {}
      - type: entity
        entity: script.cover_tilt_down
        icon: mdi:window-shutter-open
        content_info: name
        tap_action:
          action: call-service
          service: script.cover_tilt_down
          data:
            entity_id: myentity
          target: {}
    alignment: center
    card_mod:
      style: |
        ha-card {
          margin: 5px 0 10px 0;
          }
        ha-card .chip-container :not(:last-child) {
          margin-right: 20px;
          }

Unfortunately, I canā€™t seem to get this to work with auto entities. That said - I am far from knowing what Iā€™m doing :wink:

This is my current (NOT working) code. Can you help me get this to work?

type: custom:auto-entities
filter:
  include:
    - domain: cover
      options: null
  exclude:
    - state: unavailable
    - label: exclude-frontend
card:
  type: custom:layout-card
  layout_type: custom:grid-layout
  layout:
    margin: var(--layout-card-grid-margin-correction)
    grid-template-columns: >-
      repeat(auto-fill, minmax(min(var(--light-cards-min-width), 100%),
      1fr))
  cards:
    - type: custom:mushroom-cover-card
      entity: []
      fill_container: false
      name: Jalousien
      show_position_control: true
      show_buttons_control: true
      show_tilt_position_control: false
    - type: custom:mushroom-chips-card
      chips:
        - type: entity
          entity: script.cover_tilt_up
          icon: mdi:window-shutter-open
          content_info: name
          tap_action:
            action: call-service
            service: script.cover_tilt_up
            data:
              entity_id: []
            target: {}
        - type: entity
          entity: script.cover_tilt_down
          icon: mdi:window-shutter-open
          content_info: name
          tap_action:
            action: call-service
            service: script.cover_tilt_down
            data:
              entity_id: []
            target: {}
      alignment: center
      card_mod:
        style: |
          ha-card {
            margin: 5px 0 10px 0;
            }
          ha-card .chip-container :not(:last-child) {
            margin-right: 20px;
            }
show_empty: false
sort:
  method: friendly_name
card_param: entity

At the moment, all it does is this:
image

but it should be displaying 3 cover cards, which works fine if I just use the mushroom cover card on itā€™s own.

Pieter, as it was already mentioned by Marius, tap_action does not work for buttons & checkboxes. It was probably assumed that tapping a checkbox is always ā€œtogglingā€, double-tapping is meaningless; same for a button. But inability to re-define an action causes an inability to add confirmation, side effectā€¦

1 Like

You seem to want to display a LABEL inside a fold-entity-rowā€™s ā€œheadā€ + all entities assoc. with this label.
First, a fold-entity-rowā€™s ā€œheadā€ must be either a ā€œsectionā€ row or a ā€œcustom:template-entity-rowā€ - in both cases a row may have a ā€œtitleā€ which may be placeholder for a labelā€™s name.
Second, since you want to list all possible labels (i.e. w/o defining labelsā€™ names explicitly) - you have to use a ā€œtemplateā€ option inside ā€œauto-entitiesā€ which enumerates all labels, then for some particular label constructs a fold-entity-row with a ā€œheadā€=labelā€™s name and ā€œentitiesā€=assoc. entities.

Same way for flloors & areas.

1 Like

That was explained really well. Kudos.

fwiw, I did bring up the issue with one of the main Frontend contributors, to have the option stand alone, and not inside the action config.
No promises were made, but I got an ā€œInteresting, let me play around with that a bitā€ response :wink:

so hope still lives

1 Like

does anybody have an idea how I can get this to work?

dont really get why you would do anything like that with auto-entities, and only 3 covers? seems more trouble than worth it.

if you want to de-duplicate identical repetitive yaml, just use an anchor?

ā€¦ or a decluttering card (if possible)

3 shutters are just the ones I have connected at the moment while setting this up - there are more to come and when at a later point I add a couple blinds, Iā€™d like to have them added automatically.

any ideas? :slight_smile: