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

That did not work, but good news! ScottG on the discord helped me work through the options to get a working version! For all those struggling to get Auto Entities to work with Mushroom Chips, here is a working code block:

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

Here were my mistakes, in order:

  1. Options are your friend for the auto entities card. For scenes to work, the chips must be of the entity variety, and I really recommend having the name
  2. You really want to use the tap_action: action: toggle blurb. This has to be separate lines! ScottG pointed out I was trying to make tap_action: toggle work when in the chips card it is passed as an object, not as a string (therefor the action part must be indented on the line below)

I hope this helps, and if it does, you should buy Scott a coffee:

cant be.
the config I posted works fine.
ofc all choices you can make have an effect, so yes, using the content_info: name adds the name in stead of the state.
setting a tap action other than default makes a difference.

as long as you use the magic card_param to populate the correct parameter in the auto-entities config, and set a few options of your choice, you should be good. as I suggested here

Hi , I need help with auto entities and the Maxi media player card. I do not if itā€™s posible but I would like to show the correctly playing media player. With mini media player I have no problem. I made a group of media players and with auto entities I show the currently player one but I,m not able to do it with the Maxy media player card.

This is the code I use for mini media player and I do no know how adapt it to Maxi media player. Any help will be appreciated.

    - type: custom:auto-entities
      card:
        type: entities
        show_header_toggle: false
      filter:
        include:
          - domain: media_player
            state: playing
            group: media_player.media_salon
            options:
              artwork: full-cover-fit
              hide:
                power: true
                icon: true
                source: true
                progress: false
                volume: true
                controls: true
                name: false
                info: false
              type: custom:mini-media-player
        exclude: []
      sort:
        method: last_changed
        count: 1
        numeric: true
        reverse: true
        show_empty: true
      else:
        type: picture
        image: /local/stand-by-tv-card.jpg
        tap_action:
          action: none
        hold_action:
          action: none

did you test it without any of the configuration options, and only set options to use the maxi-media-player card?

next step would be to add any of the config options you require it supports, not just copy and past options from another card

Yes I tried but show no supported players found

Sorry the code as image Iā€™m on my phone and I cant paste clean code on iOS, all with strange characters

tbh, I dont use that card, but I have installed it quickly, and can not get it right eitherā€¦ seeing the same as you do, and inspector clearly shows its the mapping not getting it right.

might have to go back to the author, or check auto-entities documentation hereā€¦

btw see Maxi Media Player - #16 by Mariusthvdb, Ive asked the author in the dedicated thread to check the error being reported

and also found the reason this cant be done, as auto-entities author explained, that generates a list like

entities:
  - entity: media_player.x
  - entity: media_player.y
  - ...etc...

which cant be handled by maxi-media-player card because it wants:

entities:
  - media_player.x
  - media_player.y
  - ...etc...

see: FR add option to list entity: media_player.abc Ā· Issue #52 Ā· punxaphil/maxi-media-player Ā· GitHub

1 Like

Thanks you for your help. Hope this can be fix

this works :slight_smile:

    - type: custom:auto-entities
      card:
        type: vertical-stack
      filter:
        template: >
          [{{ dict(type='custom:maxi-media-player', entities=states.media_player | map(attribute='entity_id') | select('has_value') | list) }}]
      card_param: cards

@petro made this in a separate chat (thanks!), and weā€™ve not yet added other config options to that. downside of template in auto-entities is that you have to get all other options also inside that template. so, depending on how complex you want it to be, you might be up for a challenge yet :wink:

should be able to add those options to the dict

1 Like

pretty sure you can use options too, the normal way. Youā€™d have to try it out.

This is awesome I will try that. Thanks!

there still is something iffy about that card, because even after I deleted all configs, I still see this in inspector

1 Like

and your question is what?

please dont put large irrelevant configs here, only the auto-entities section you need help with

1 Like

The following template is working in Dev Tools but I cannot get it to work in auto-entries, any suggestions?

type: custom:auto-entities
filter:
  template: >-
    {{  states['binary_sensor'] 
    |selectattr('entity_id','in',label_entities('External Doors'))
    |selectattr('state','==','on') |map(attribute='entity_id') |list }} 
  options:
    type: custom:mushroom-entity-card
    layout: horizontal
    secondary_info: last-changed
card:
  type: custom:layout-card
  cards: []
  layout_type: masonry
sort:
  method: friendly_name

Not checked your template - but you cannot combine ā€œtemplateā€ & ā€œoptionsā€.
All options must be defined as a part of ā€œtemplateā€. See examples in the thread.

1 Like

You can only do that with advanced templating.

type: custom:auto-entities
filter:
  template: >-
    [{% for e in label_entities('External Doors') 
          | select('search', '^binary_sensor.') 
          | select('is_state','on') %}
      {{ 
        dict(
          entity=e,
          type='custom:mushroom-entity-card',
          layout='horizontal',
          secondary_info='last-changed'
        )
      }},
    {% endfor %}]
card_param: cards
card:
  type: custom:layout-card
  layout_type: masonry
sort:
  method: friendly_name
2 Likes

why not first select label_entities and next domain binary_sensor? in my setup, that at least starts with a smaller set of entitiesā€¦

2 Likes

sure, I was just being lazy and correcting what they had

{% for e in label_entities('External Doors') | select('search', '^binary_sensor.') | select('is_state','on') %}
1 Like

exactly :wink: those label_entities templates are really powerful!

and probably your first post (without the select) would be ok too, considering there wont be other entities than those binaries with on/off stateā€¦

1 Like

I only have one left I want to rewrite if possible:

      template: >
        {%- set alert_level = states('input_number.battery_alert_level')|int %}
        {%- set ns = namespace(batt_low=[]) %}

        {%- set ns = namespace(batt_low=[]) %}
        {%- for s in label_entities('batterij')
          if is_number(states(s)) and states(s)|int < alert_level
          or not has_value(s) %}
        {%- set ns.batt_low = ns.batt_low + [s] %}
        {%- endfor %}
        {{ns.batt_low}}

selecting all batteries below alert level or lost contact :wink:

I use Auto-entities for Alert ā€œpopupsā€ in Lovelace, like this:

type: custom:auto-entities
show_empty: false
card:
  type: entities
  state_color: false
  show_header_toggle: false
  card_mod:
    style: |
      ha-card {
        background-color: rgba(251,13,13,1);
        border-radius: 5px;
        --primary-color: white;
        --paper-item-icon-color: white;
        --secondary-text-color: white;
      }
filter:
  include:
    - entity_id: alert.a_*
      state: 'on'
      options:
        secondary_info: last-changed
sort:
  method: last_changed
  reverse: true
  count: 20

I also want to show the alert message in the box, and not only the name of the friendly name of the alert. But it seems that the message is not an attribute of an alert. Is it possible to extract the alert message somehow?