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

Iā€™ve just installed the card and Iā€™m having an issue with some real basic stuff.
Iā€™m trying to filter some lights by the group that they are in, but nothing is showing.
If I remove the group filter all lights show as expected.
Hereā€™s my card code:

type: custom:auto-entities
card:
  type: entities
  title: Kitchen
  state_color: true
filter:
  include:
    - group: kitchen
      state: 'on'
  exclude:
    - entity_id: switch.tap
sort:
  method: friendly_name
  reverse: false
  ignore_case: false
  numeric: true

Hello,
Iā€™m using auto-entities to show the next birthdays, this limited so i only can see the next 3 birthdays.
Butā€¦ i want to see the others to.
Is there like an option to add an dropdown or popup to it? so that u only can see the first 3 but when u press an arrow, u can see the rest of the list?
Thnx!

There is no such an option. Auto- entities shows either all filtered items or some of them (like first three, last three, nos 3ā€¦7)

Iā€™m really bad in coding (which basically is needed for more sophisticated lists.

Iā€™m looking to get a list of entities that have NOT sent an update for 24h. Mainly my zigbee-sensors that tend to stop working.

Any help on that?
Thank you!

Is it possible to change the name of the entity ā€œon the flyā€?
In this example Iā€™d like to remove ā€œbatteryā€ from the name, as itā€™s only batteries in this card so itā€™d redundant.

So Iā€™d like to see ā€œAqara Aussenā€ only, instead of ā€œAqara Aussen batteryā€

image

Example:

2 Likes

Is it possible to use an input_number in sort: count: ?
Something like this, but doesnā€™t working for me :frowning:

  - type: custom:auto-entities
    card:
      type: entities
      title: Voltage
    filter:
      include:
        - entity_id: "sensor.0x*_voltage"
    sort:
      method: state
      numeric: true
      count: "{{ states('input_number.auto_entities_sort_count')|int }}"
  input_number.auto_entities_sort_count:
    name: Auto Entities Sort Count
    min: 2
    max: 10
    initial: 4
    step: 2

Only by using a ā€œtemplateā€ option as a filter.

Hi, With this card im trying to add and remove devices from my vpn gateway,
Only does the option not work for the template it seams.

Does someone has a solution?

type: custom:auto-entities
card:
  type: entities
filter:
  template: >
      {% for device in states.device_tracker %}

        {% if state_attr(device.entity_id,'ip') |  regex_match('192.168.5.(1[5-9]\d|2[0-4]\d)') -%}
          {% if states('binary_sensor.vpn' + state_attr(device.entity_id,'ip') | replace('.','_')) != "on" -%} 
          {{ device.entity_id}}, 
          {%- endif %}
        {%- endif %}
      {% endfor %} 
  options:
      tap_action:
        action: call-service
        service: script.vpn_add
        data:
          entity_id: this.entity_id

Thanks for this awesome card, Iā€™m using it to show ā€œabnormalā€ states for my sensors (water, gas, smoke, etc) so that they only will show up if triggered. That works great.

Iā€™m now trying to show my triggered camera images from Blue Iris, but only if it contains a valid camera image, e.g. the camera has triggered an alert in Blue Iris.

I have set up one MQTT camera entity in HA for each of my cameras, and those get the trigger screenshot from Blue Iris through MTTQ. This works just fine, each time a camera triggers an alert the corresponding MQTT camera gets the alert screenshot from Blue Iris.

But I would like to only show the camera image if it contains an actual image, if the corresponding Blue Iris camera has not been triggered the MQTT camera entity will not contain any picture/screenshot of the alert. But I can figure out how to use this card and make a filter that checks if the MQTT camera contains a valid image or not. Iā€™m trying to use a picture-glance card for this, is this even possible?

Example code:

type: custom:auto-entities
card:
  type: picture-glance
  camera_view: auto
  entities: []
  camera_image: camera.front_door_mqtt
filter:
  include:
    - entity_id: camera.front_door_mqtt
show_empty: false

This will of course show the camera image based on the ā€œincludeā€ filter, or just a blank image if the camera contains no valid image. What I cannot figure out is how to make an ā€œexcludeā€ filter that excludes the camera entity if it does not contain a valid image.

Any ideas on how to achieve that anyone?

Paste your code into Dev Tools ā†’ Template and then post here an output.

May be I am wrong - please correct me.
You have a card:

type: some_type
some_option: camera.some_entity_id

And then you want to show this card only for ONE particular entity dependingly on some conditions, like:

if CONDITION == true for entity_1 -> show a card for entity_1
if CONDITION == true for entity_2 -> show a card for entity_2
...

What you can do is:

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  - include:
      ...some_filter
      options:
        type: some_type
        some_option: this.entity_id
        ...other options for card

or rewrite the same code for using a ā€œtemplateā€ filter (if filtering may be done by templates only).

Responding to myself here, because after digging some more I found a rather simple solution to this.

I added the ā€œavailability_topicā€ attribute to my MQTT cameras and made sure that Blu Iris sends the payload ā€œonlineā€ as well as the image whenever it detects motion. My MQTT cameras will then have the state ā€œunavailableā€ if no motion has been detected, this will change to ā€œidleā€ as soon as it gets an image and ā€œonlineā€ as its ā€œavailability_topicā€. The latter was the key to the solution. Now the ā€œpicture-glanceā€ cards for each of my MQTT cameras will only show if any movement has been detected, in which case it shows the snapshot from the last alert. Not sure if this is the easiest way to achieve this, but it works. :slight_smile:

Working code:

type: custom:auto-entities
card:
  type: picture-glance
  camera_view: auto
  entities: []
  camera_image: camera.front_door_mqtt
filter:
  include:
    - entity_id: camera.front_door_mqtt
      state: idle
show_empty: false

Thanks, yes thatā€™s how it works. :slight_smile:

My issue was that I didnā€™t have something suitable to use as a filter, which I have now solved as per my post below (or above). Thanks again!

This is not a case for auto-entities.
If you have only ONE camera entity and you need to show the card for this only entity_id conditionally - use a standard conditional card.

I donā€™t know if there was an update, but suddenly this doesnā€™t work anymore:

type: vertical-stack
cards:
  - type: custom:mushroom-title-card
    subtitle: Lights switched on ({{states('sensor.aantal_ingeschakelde_lichten')}})
  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
    sort:
      method: name
      numeric: false
    filter:
      include:
        - domain: light
          options:
            type: custom:mushroom-template-card
            primary: '{{ states[''this.entity_id''].name.replace(''lights'', ''Lights'') }}'
            secondary: '{{ states[''this.entity_id''].state }}'
            icon: mdi:lightbulb
            icon_color: |-
              {% if states['this.entity_id'].state == 'on' %}
                orange
              {% else %}
                grey
              {% endif %}
            tap_action:
              action: toggle
            double_tap_action:
              action: none
      exclude:
        - state: 'off'
        - state: unavailable
        - attributes:
            friendly_name: Group -*
        - attributes:
            friendly_name: Sun blinds
        - attributes:
            friendly_name: LED*
        - attributes:
            type: browser_mod

When I remove the ā€œoptionsā€ part, it worksā€¦but I want the mushroom part.
Any idea ?

2 Likes

I have the exact same problem. It works without the options section included. It also only seems to not work for lights. I have another card that shows active motion sensors and it still works just fine.

1 Like

So nice! I was looking for something like this for so long :partying_face: !! But what I didnā€™t liked about it was the hardcoded speaker_group entities.

ā€˜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ā€}]
}

The first part of the code is dynamic, so why not the speaker_group entities part?
Secondly, what I didnā€™t liked about it is that the ā€œMasterā€ is also shown :confused: :thinking::
Screenshot 2022-12-29 225202

So what I wanted is just to show the other speakers :grinning::
Screenshot 2022-12-29 225220

So here is my version :partying_face: :partying_face: :partying_face::

type: custom:auto-entities
show_empty: true
card:
  type: entities
filter:
  template: >-
    {%- set speakers=expand(integration_entities("sonos"))|selectattr("domain","eq","media_player")|map(attribute="entity_id")|list %}
    [ {% for speaker in expand(speakers) if speaker.attributes.group_members[0] == speaker.entity_id %}
    {%- set speaker_group = namespace(entities=[]) %}
    {%- for member in speakers if member!=speaker.entity_id %}
    {%- set speaker_group.entities=speaker_group.entities+[{'entity_id' : member,'name': state_attr(member,'friendly_name')}] %}
    {%- endfor %}
         {{
            {
              'type': 'custom:mini-media-player',
              'entity' : speaker.entity_id,
              'artwork' : 'cover',
              'group': false,
              'hide': {
                'power': true,
                'icon': true,
                'source': true
              },
              'speaker_group': {
                'platform': 'sonos',
                'sync_volume': true,
                'show_group_count': true,
                'entities': speaker_group.entities
              }
            }
         }},
    {%- endfor %} ]

And here in action :film_strip::
msedge_HLd12zqF61

2 Likes

Please let me know if you find a solutionā€¦

Solved with the update of today :grinning: