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

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?

Im trying to use an input select variable to display all light entities in a room. But its still showing more then the selected room.

  • What am I missing?

type: custom:auto-entities
show_empty: false
card:
  type: entities
filter:
  template: |-
    {% set area_filter = ['input_select.room'] %}
    {%- set areas = states.light
    | map(attribute='entity_id')
    | map('area_name') | unique | reject('none')   
    | list -%}      
    {%- for area in areas  -%}  
    {% set lights = states.light
    | selectattr('entity_id', 'in', area_entities(area)) 
    | list -%}         
      {{{ 'type': 'custom:mushroom-title-card',
          'title': area}}},
      {%- for light in lights  -%}
          {{{ 'type': 'custom:mushroom-light-card',              
              'entity': light.entity_id,
              'use_light_color': 'true',
              'show_brightness_control': 'true',
              'show_color_control': 'true',
              'collapsible_controls': 'true',
              'show_color_temp_control': 'true', }}},
      {%- endfor %}{%- endfor %} 

You are not using area_filter in your code. So, you are not dropping the other areas out of your list.

Can you please guide me?

{%- set area_filter = states( 'input_select.room') -%}
{{- area_entities( area_filter  ) | select('search', '^light\.')  | list -}}

Assigns the value of an input_select to variable area_filter
Selects all entities in that room/area ( area_filter ), filters that list down to just lights

Cant get it to work, gets an entity index 0 error.

Can you please add your solution into the main code?