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

Dunno. If it does - an average user cannot access this info. Does the Entities card publish anywhere a number of rows included? No.

Yes.

1 Like

I was hoping that it would be possible to either access the internal count number or maybe count something like ā€œfor s in seriesā€ or something, i.e. get the number of series that are being plotted. Something like that.

I have a printer that has multiple color inks. They are used to print ā€˜professionalā€™ pictures.

I am successfully displaying the various ink color levels, sorted properly, lowest on top using the Auto-Entities card. I am delighted as I no longer have to guess which ink I have to order.

Two features I would like to add, I just cannot seem to figure out how.

  1. Is there a way to set a level (say 20%) where the icon display changes color?

  2. Is there a way to reduce the displayed entity string (using regex?) as the actual color does not show in mobile, it is too long.

I was trying to figure out how option is used but could not figure it. :confused:

This is what I have now.

type: custom:auto-entities
card:
  type: entities
  title: Epson Color ink status
entities:
  - entity: sensor.epson_xp_15000_series
filter:
  include:
    - entity_id: /.*epson_xp_15000_series_.*$/
sort:
  method: state
  reverse: false
  numeric: true
show_empty: true

Left is how it looks on desktop, while right is on the phone.

Again, thank you for an excellent card!

Kind of this:

    - entity_id: ...
      options:
        card_mod:
          style: |
            :host {
              {% if states(config.entity) ..... %}
                place here your styles
              {% endif %}
            }

This may only be achieved by using a ā€œtemplateā€ option. Check for examples here.

Thank you! Where can I start learning about this ā€œtemplateā€ option and the code {%} you included?

Only by using search in this thread (I posted many examples with templates here too).

1 Like

Iā€™m trying to ā€˜groomā€™ the name of the sensor, to better make it fit my card. But I canā€™t get it working.
My sensor looks like this:
billede

The card looks like this currently:


I would very much like to get rid of Private and Temperatue and the two paranthesis and 0:, so I made the card like this:

type: custom:auto-entities
filter:
  include:
    - entity_id: sensor.private_cpu_temperature
    - entity_id: sensor.private_temperature_drive*
  filter:
    template: |-
      {% for state in states.sensor -%}
            {
              'entity': state.entity_id,
              'name': state.attributes.friendly_name | regex_replace( find='Private |Temperature \(|\)|0:', replace='' )
            }
      {%- endfor %}
card:
  type: custom:apexcharts-card
  header:
    show: true
    title: NAS
    show_states: true
    colorize_states: true
  graph_span: 7d
  apex_config:
    legend:
      show: false
  all_series_config:
    stroke_width: 1
    type: line
    curve: smooth
    group_by:
      duration: 6h
      func: avg

If I try to use the template in deveoper tools this line
{{state_attr("sensor.private_temperature_drive_0_1","friendly_name") | regex_replace( find='Private Temperature \(|\)|0:', replace='' ) }}
gives me the right result.

So what am I doing wrong ? :slight_smile:

You cannot specify filters like this.
Since you decided to use ā€œtemplateā€ - enumerate required entities there only.
Select required entities by using smth like ā€œselectattr(ā€¦)ā€.

1 Like

Hello,

Is it possible to show an attribute of a filtered entity ?
I want to display the firmware version of all my Shelly devices, i can get every ā€œfirmware updateā€ entities in my list but it show me ā€œup to dateā€ instead of the version of the firmware.

Thanks !

Hi @Ildar_Gabdullin
Ahh, of course.

So this gave me an ok result:

type: custom:auto-entities
filter:
  template: |-
      {% for state in states.sensor -%}
        {%- if (state.entity_id | regex_match("^sensor.private_temperature_drive_0*|^sensor.private_cpu_temperature", ignorecase=False)) -%}
          {{
            {
            'entity': state.entity_id,
            'name': state.attributes.friendly_name | regex_replace( find='Private |Temperature \(|\)|0:|Temperature', replace='' )
            }
          }},
        {%- endif -%}
      {%- endfor %}
card:
  type: custom:apexcharts-card
  header:
    show: true
    title: NAS
    show_states: true
    colorize_states: true
  graph_span: 2d
  apex_config:
    legend:
      show: false
  all_series_config:
    stroke_width: 1
    type: line
    curve: smooth
    group_by:
      duration: 1h
      func: avg

I didnā€™t ā€˜chooseā€™ to use templates, it was the only solution I found.
Iā€™m very happy to hear other solutions, I think this is a bit ā€˜heavyā€™.
And I donā€™t understand your last suggestion simply due to lack of knowledge, could you elaborate please?
billede

1 Like

It appears if use the template method of filtering, I canā€™t apply options to the generated glance or chip. (see my example trying to apply the tap_action)

Iā€™m trying to figure out what Iā€™m doing wrong here applying the options a filter type of template.

Iā€™ve tried this with mushroom ā€œchipsā€ and no luck there either.

Iā€™m trying to show recently turned off devices, and then just have a single tap to turn them back on if they were turned off by mistake and removed from a similar card that has only lights that are currently on.

Iā€™ve tried everything I can think of and I need some help.

type: custom:auto-entities
view_layout:
  grid-area: footer
show_empty: false
card:
  type: glance
filter:
  template: |
    {% for light in states.light %}
      {% if light.state == "off" and
        as_timestamp(now()) - as_timestamp(light.last_changed) < 60 
      %}
        {{ light.entity_id}},
      {% endif %}
    {% endfor %}
  options:
    tap_action:
      action: toggle
sort:
  method: last_updated
  reverse: true
  ignore_case: true

Edit: I should note this options section works for me when I use a include filter instead of a template filter.

Not possible ?

Similar question here on template filter and having options to be passed to the card.

I want to show all playing sonos players which are not in a group, or master of a group. Those playing in a group, but being no master should not show up.

This is what I got so far with @123 help:

type: custom:auto-entities
show_empty: false
card:
  type: entities
filter:
  template: |
    {% set ns = namespace(players = []) %}
    {% for player in states.media_player 
         | selectattr('state', 'eq', 'playing') 
         | selectattr('attributes.group_members', 'defined')
         if player.attributes.group_members[0] == player.entity_id %} 
      {% set ns.players = ns.players + [player.entity_id] %}
    {% endfor %}
    {{ ns.players }}

This works like a charm.

Now I want this to work with mini-media-player which expects the entity to be passed as entity and not as entities. Just replacing type: entities with type: custom:mini-media-player is not working.

Passing the option entitiy: this.entity_id is not possible as the template part seems not to accept an options section, as @zimmer62 has pointed out above.

Any hint appreciated how to the auto-entity card to play with the mini-media-player card.

1 Like

Untested:

  template: |
    {% for player in states.media_player 
         | selectattr('state', 'eq', 'playing') 
         | selectattr('attributes.group_members', 'defined')
         if player.attributes.group_members[0] == player.entity_id %} 
         {{
           {
             'type': 'your_card',
             'entity:' player.entity_id
           }
         }},
    {% endfor %}
1 Like

Check your code:
image
You cannot use the ā€œfilterā€ option inside another ā€œfilterā€ option.

This is genius. It was nearly there. I was able to figure that out.

This worked for me:

type: custom:auto-entities
show_empty: false
card:
  type: entities
filter:
  template: |
    [
    {% for player in states.media_player 
         | selectattr('state', 'eq', 'playing') 
         | selectattr('attributes.group_members', 'defined')
         if player.attributes.group_members[0] == player.entity_id %} 
         {{
            {
              'type': 'custom:mini-media-player',
              'entity' : player.entity_id,
              'artwork' : 'full-cover',
              'hide': {
                'power': true,
                'icon': true
              },
              'speaker_group': {
                'platform': 'sonos',
                'show_group_count': true,
                'entities': [
                  {
                    'entity_id': 'media_player.ralf',
                    'name': 'Ralf'
                  },
                  {
                    'entity_id': 'media_player.bad',
                    'name': 'Bad'
                  },
                  {
                    "entity_id": "media_player.kuche",
                    "name": "KĆ¼che"
                  },
                  {
                    "entity_id": "media_player.wohnzimmer",
                    "name": "Wohnzimmer"
                  },
                  {
                    "entity_id": "media_player.eltern",
                    "name": "Eltern"
                  },
                  {
                    "entity_id": "media_player.annika",
                    "name": "Annika"
                  },
                  {
                    "entity_id": "media_player.gaste",
                    "name": "GƤste"
                  }
                ]
              }
            }
         }},
    {% endfor %}
    ]

1 Like

Please help. This is kinda working in Developer tools > Template, but not in auto-entities card:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {% for zone in
      [
        {
          'friendly_name': '000001',
          'valve_position': states('sensor.04_000001_heat_demand'),
          'climate': states.climate.ramses_cc_01_154356_00
        },
        {
          'friendly_name': '000002',
          'valve_position': states('sensor.04_000002_heat_demand'),
          'climate': states.climate.ramses_cc_01_154556_00
        }
      ] | sort(attribute='valve_position', reverse=true)
    %}{{ zone.climate }},{% endfor %}

So Iā€™m sorting by one attribute, but I want to show another entity as the correct one in the end.

and no cardā€™s type specified.

first 3 lines?

type: custom:auto-entities
card:
  type: entities

My bad. Awfully sorry.

Show output of dev tools.