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

Yeah, I am not sure why it was working then stopped. But, I will have to work out a way to do a template, I am just very slow at making them :grimacing:

So, I have worked out this sensor template to remove the ā€œdaysā€ and just return a number:

- platform: template
    sensors:  
      bin_green:
        friendly_name: 'Green Bin Days'
        unit_of_measurement: 'days'
        value_template: >
          {% set str = (states('sensor.green')) %}
          {% set sub = str.split(' ')[0] %}
          {{ sub }}

Now I just need to work out how to get that into the auto entities.

Hi again,

I manage 2 households on my HA system.
I want to diplay on Dashboard 1 the remaining time of the washingmachine in the auto-entity card only if an boolean switch is ā€œonā€. On dashboard 2, I want to display the remaining time if the boolean switch is ā€œoffā€ The card is hidden if the washingmachine is off. How do I configure this?

Hi did you find a solution?

replacing the legacy History panel, I use

type: entities
entities:
  - entity: input_number.history_span
  - type: custom:hui-element
    card_type: entities
    entities:
      - type: custom:config-template-card
        entities:
          - input_number.history_span
        variables:
          span: states['input_number.history_span'].state
        card:
          type: custom:auto-entities
          card:
            type: history-graph
            hours_to_show: ${span}
            card_mod:
              style: |
                ha-card {
                  box-shadow: none;
                  margin: 8px -16px 0px -16px;
                }
          filter:
            include:
              - domain: '*'
    card_mod:
      style: |
        ha-card {
          box-shadow: none;
        }
        .card-content {
          max-height: 800px;
          overflow-y: scroll;
        }

and on desktop that shows just fine, even allowing the period to be controlled by the input_number.

However, on iOS mobile, I dont see a graph at all, only the popup per entity, and the slider.

is this an auto-entities issue, or am I facing another mobile thing. Maybe the history-graph?
would appreciate if someone could have a look
thanks

edit

even with:

    - type: entities
      title: History include all domains
      entities:

        - type: custom:auto-entities
          card:
            type: history-graph
            hours_to_show: 12
            card_mod:
              style: |
                ha-card {
                  box-shadow: none;
                  margin: 8px -16px 0px -16px;
                }
          filter:
            include:
              - domain: "*"

thereā€™s an issue on Mobile, so forget I posted here, Ill take it to Mobile/Frontend

update

just as a fyi: this can be done, because of imitations in the IOS/App rendering of the history-graph image canvas, see History-graph wont show graph (but does show the popup per entity) Ā· Issue #2171 Ā· home-assistant/iOS Ā· GitHub

ios has a maximum image texture size that it enforces and the history page exceeds it. mac in catalyst mode copies this.

adding a domain selector fixes it (and makes it no longer be a show all domains ofcā€¦)

            - type: custom:config-template-card
              entities:
                - input_number.history_span
                - input_select.domain
              variables:
                span: states['input_number.history_span'].state
                domain: states['input_select.domain'].state
              card:
                type: custom:auto-entities
                card:
                  type: history-graph
                  hours_to_show: ${span}
                  card_mod:
                    style: |
                      ha-card {
                        box-shadow: none;
                        margin: 8px -16px 0px -16px;
                      }
                filter:
                  include:
                    - domain: ${domain}

Is it possible to filter entities based on other elements? Essentially Iā€™d like to include a specific element based on other criteria not directly tied to said entity.

To be specific, I want to include entity switch.front_porch_light Only during the day. I donā€™t need to know the porch light is on at night, because it should be and I donā€™t want to see it when checking all the lights are off at night before bed. But if it fails to turn off or gets turned on accidentally during the day, itā€™d be great to see that the porch light is on.

In my mind the config would look something like this:

type: custom:auto-entities
card:
  type: entities
  title: Active Lights/Fans
filter:
  include:
    - name: /[Ll]ight/
      state: 'on'
      not:
        entity_id: switch.front_porch_light
    - entity_id: switch.front_porch_light
      state: 'on'
      IF_SUN_ELEVATION > 0

obviously thatā€™s not how it works, but is that sort of concept possible?

try using ā€œtemplateā€ option

Is there a way of excluding light groups? Iā€™m using the code that @Mariusthvdb provided above:

type: custom:auto-entities
card:
  type: entities
  title: Multiple lights
  show_header_toggle: false
filter:
  include:
    - domain: light
      state: 'on'
      attributes:
        rgb_color: '! none'
      options:
        type: custom:multiple-entity-row
        toggle: true
        secondary_info: last-changed
        primary:
          entity: this.entity_id
          attribute: brightness
          name: Bri
          unit: '%'
        secondary:
          entity: this.entity_id
          attribute: rgb_color
          name: Rgb
    - domain: light
      state: 'on'
      attributes:
        color_temp: '! none'
      options:
        type: custom:multiple-entity-row
        toggle: true
        secondary_info: last-changed
        primary:
          entity: this.entity_id
          attribute: brightness
          name: Bri
          unit: '%'
        secondary:
          entity: this.entity_id
          attribute: color_temp
          name: Color
sort:
  method: friendly_name
  ignore_case: true


Iā€™m trying to figure out how to create a card that will show which users are playing media from my plex server and what they are playing. These are both secondary state attributes that Iā€™m having a lot of trouble figuring out how to bring into a card. Iā€™ve tried every version I can think of using auto-entities, without much success. Iā€™ve also tried using auto-entities along with config-template-card and multiple-entity-row, but still havenā€™t had much luck. I hoping someone might be able to help me figure out the best way to go about this.

Iā€™m going to hide the details of what Iā€™ve already tried below in order to keep this post from being obnoxiously huge, but please read on if youā€™re interested or have any ideas about how I might be able to accomplish this. Thanks!

Summary

There are two options for where the information about the plex users can be pulled from. First, there is an entity for my Plex server: sensor.plex_tower, which shows how many users are currently playing media as its state, and has the following attributes:

xthursdayx - Plex Web: [Rec] (2007)
unit_of_measurement: Watching
icon: mdi:plex
friendly_name: Plex (Tower)

The first attribute is specific to user currently playing media, the location theyā€™re playing from, and the media (title and year). Because of this, there will be multiple of these attribute entries when multiple users are playing. This attribute also doesnā€™t have a separate, generic name, so each time a user plays something the name of the attribute itself is different.

The second option is to pull the information from media_player entities that are automatically generated when a user plays media from my Plex server via any player, These entities are named after the user and player, for example: media_player.plex_ghostorchid_plex_web_firefox_osx. However, if my admin user is the one playing media, the entitey is just calls the user ā€œplexā€: media_player.plex_plex_web_firefox_osx. These entitiesā€™ states will either be playing, paused, or unavailable and they contain a lot more attribute information than the previous sensor I described. For example:

friendly_name: Plex (Plex Web - Firefox - OSX)
supported_features: 131584
is_volume_muted: false
media_content_id: 96086
media_content_type: movie
media_duration: 4715
media_position: 2832
media_position_updated_at: 2022-08-23T20:18:16.018673+00:00
media_title: [Rec] (2007)
media_content_rating: ca/18A
media_library_title: Movies
player_source: session
media_summary: "REC" turns on a young TV reporter and her cameraman who cover the night shift at the local fire station. Receiving a call from an old lady trapped in her house, they reach her building to hear horrifying screams -- which begin a long nightmare and a uniquely dramatic TV report.
username: xthursdayx
entity_picture: /api/media_player_proxy/media_player.plex_plex_web_firefox_osx_3?token=**************************************************

So, to create an entities card with a list of the users playing media, and the media theyā€™re playing, Iā€™ve tried the following options.

If I try to just use a normal entity card for the sensor entity associated with my plex server I get a card like this, that just shows the name of the Plex server and how many people are watching:

Iā€™ve tried using an auto-entities card to filter entities in the media_player domain that have the state playing:

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
  title: Plex Now Watching
filter:
  include:
    - domain: media_player
      state: playing
  exclude: []
sort:
  method: entity_id
show_empty: true

However, that just gives me a card that shows the name of the player where the media is being played and the icon associated with the media:

I also tried adding the attributes option to the entity, which did give me the username, but the entry name is still the Plex player (Plex Web - Firefox - OSX in this case) and I donā€™t think that there is a way to add two attributes, such as both the username and title of the media being played.

type: custom:auto-entities
card:
  type: entities
  show_header_toggle: false
  title: Plex Now Watching
filter:
  include:
    - domain: media_player
      state: playing
      options:
        type: attribute
        attribute: username
  exclude: []
sort:
  method: entity_id
show_empty: true

This results in an entity with an icon of the movie (which I would like to keep), the name of the player (e.g. Plex (Plex Web - Firefox - OSX)) and the username of the watcher (xthursdayx in this case). This is close to what I want, but the long ā€œplayer nameā€ is not useful to me. I would rather replace this with the username of the person playing the media, and then replace the username in the current configuration with the name of the media (e.g. REC (2007) ).

Iā€™ve also tried using a template filter for the sensor entity associated with my Plex server:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |-
    {% set SENSOR = 'sensor.plex_tower' -%}
    {%- for attr in states[SENSOR].attributes -%}
      {{
        {
          'type': 'attribute',
          'entity': SENSOR,
          'attribute': attr,
          'name': attr
        }
      }},
    {%- endfor %}

Which gave me most of the information I want in the first line, which is associated with the one (unnamed attribute created for this user) but the other attribute information, such as the unit of measurement and icon name, I donā€™t need, I did also like that the previous versions showed the small icon associated with the media being played.

Finally, I tried using a multiple-entity-row to bring in both the username of the watcher and the title of the media, but I donā€™t think that you can use wildcards in the entity_id for that card, so I just got the message: Entity not available: media_player.plex_*

type: custom:auto-entities
card:
  type: entities
  title: Watching
filter:
  include:
    - entity_id: media_player.plex_*
      state: playing
      options:
        type: custom:multiple-entity-row
        entity: media_player.plex_*
        entities:
          - attribute: username
            name: 
sort:
  method: entity_id

If you made it this far, I really appreciate it! I know that this was a lot to dump here, but Iā€™m kind of at a dead end and not sure where to go form here. Any thoughts or suggestions would be much appreciated. Thanks!!

    - entity_id: media_player.plex_*
      state: playing
      options:
        type: custom:multiple-entity-row
        entity: this.entity_id

it all depends on your specific situation. If you only have Hue light groups, you could exclude those based on an attribute specific to the Hue integration

    filter:
      exclude:
        - attributes:
            is_hue_group: true # or hue_type: *

in my case, with several other light integrations, the simplest way was to create a few groups and included those in the auto-entities:

    filter:
      include:
        - group: light.main_inside_lights
        - group: light.guest_room_lights
        - group: light.plafond_spots
        - type: divider
        - group: light.outdoors_floodlights
        - group: light.terrace_outdoors_group

as you can see that allows for some other frontend frivolities, like ordering and dividing :wink:

you can also nest these light groups into a single lights_only group:

group:

  all_lights_only:
    name: All lights only
    icon: mdi:lightbulb-group
    entities:
      - group.all_inside_lights
      - group.all_outside_lights

and keep nesting these too.

Hey all, been trying to filter out a media player entity only if another entity is playing. For context, Iā€™m trying to hide my SHIELDā€™s Android TV media player if the integrated Chromecast media player is playing. Any ideas? Iā€™ve thought about using a template filter to show either one or the other, but that gets processed before the exclude filter runs so Iā€™ll probably have to rework my entire config for the card. Iā€™ve added the config of the card below.

type: custom:auto-entities
filter:
  include:
    - options:
        type: custom:mushroom-media-player-card
        media_controls: play_pause_stop, on_off, next
        volume_controls: volume_set
        use_media_info: true
      domain: media_player
  exclude:
    - attributes:
        type: browser_mod
    - state: 'off'
    - state: unavailable
    - state: standby
    - entity_id: media_player.spotify_robert_young
sort:
  method: last_triggered
show_empty: false
card:
  type: entities

Trying to get all entities with ā€œ.zigbee_ā€ in the entity_id, but this is showing nothing.
Example: light.zigbee_17

type: custom:auto-entities
card:
  type: glance
filter:
  exclude:
    - {}
  include:
    - entity_id: '*.zigbee_*'
  exclude: []

works (Y) looks lik the editor is making invalid yaml in that case.

New question:
Is is possible to make the entities card sow the entity_id insted of the name/friendly_name

Hello everyone,
I created a dedicated thread but will move it here as advised by @Ildar_Gabdullin .

Thread: Possible to force line break? (e.g. auto-entities with glance)

I will copy below my post from the thread just so everything is in one place.

Can anybody help me out, please?
Essentially I am trying to get


Hello everyone,
I am trying to display a slider and next to it the data from a sensor. Basically the slider of the thermostat with setpoint and then the actual room temperature from a Xiaomi Mijia Thermometer in the room.
Since I have multiple rooms and systematic nomenclature, I would like to use auto-entities.

My current code:

type: horizontal-stack
cards:
  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
      min: 4.5
      max: 23
      step: 0.5
      hide_state: false
      card_mod:
        style: |
          ha-card {
            --ha-card-background: rgba(0, 0, 0, 0);
            --ha-card-box-shadow: none;
          }
    filter:
      include:
        - entity_id: climate.eq_3_*
          options:
            type: custom:slider-entity-row
  - type: custom:auto-entities
    sort:
      method: area
    show_empty: false
    card:
      type: glance
      show_name: false
      show_icon: false
      card_mod:
        style: |
          ha-card {
            --ha-card-background: rgba(0, 0, 0, 0);
            --ha-card-box-shadow: none;
          }
    filter:
      include:
        - entity_id: .*xiaomi_temperature*

But this gives me
image

As you can see, the sensor temperatures are listed next to each other and only break when no more room is available. I would like to have them underneath each other, so each row only contains one slider and one glance state entry.

Thank you for your help
Alex

As I already told you - you must create a vertical stack of horizontal stacks, where each stack is ā€œslider + glanceā€.
Start with displaying the same entity on the slider & on the glance (finally you will need one entity on the slider, another on the glance).
Then you will see (already visible on your wrong draft) that your final card has 50% of width for sliders, 50% of width for glance. Then you will make the right part more narrow - either by card-mod or by using layout-card (instead of horizontal stack).
Then your card is almost ready - but you need to specify a different entity on the glance part. So build your code for ā€œtemplateā€ option.
This this the Way.

I will need to play with that. I have not used template yet with auto-entities filters. Not sure how to make a template that will only pass to a specific card.

I cannot access my server right now either (at the office) but will it work to automatically create new stacks with their own sub-filter?

Because what would be needed is

Stack 1 (row filter: .living_room) slider (filter: .eq_3_temperature) glance (filter: .xiaomi_temperature)
Stack 2 (row filter: .dining_room) slider (cell filter: .eq_3_temperature) glance (cell filter: .xiaomi_temperature)
Stack 3 (row filter: .office) slider (cell filter: .eq_3_temperature) glance (cell filter: .xiaomi_temperature)
Stack 4 (row filter: .kitchen) slider (cell filter: .eq_3_temperature) glance (cell filter: .xiaomi_temperature)

So I would need a filter per row plus a filter per cell.
And all of this would be significantly more code than it was supposed to be.

Auto-entities will not automatically create new horizontal stack rows within the vertical stack. But that is what would be needed if I add horizontal stacks.
With this approach I would need much more code than I hoped. It would be easier to make it all manual then.

Or does your approach create the rows automatically somehow?

The template itself does create a card.

There is ONE filter - on the only auto-entities card.
First create a filter w/o using a ā€œtemplateā€ option.
After finalizing creating a card - rebuild it to using ā€œtemplateā€.
Check examples with ā€œtemplateā€ here.

No.
As I said - first use one filter to get entities of ONE kind (some ā€œinput_numberā€, for instance).
Create a card, finalize it.
Then rebuild your filter to template - which creates TWO kinds of entities.

Do a simpler task: create a list of rows in Entities card, where state (& slider) is displayed for some ā€œinput_numberā€, and for ā€œnameā€ display a name of some ā€œsensorā€ (your template filter must generate a sensorā€™s & input_numberā€™s entity_ids).

Pfuh, that sounds quite difficult. I will try to work my way through it. It probably sounds easy peasy to you. Maybe I just need to read it a few more times to see its simplicity :see_no_evil:

While looking for template examples in this thread I found this post using multiple-entities-row.

I will try and see if maybe that custom card already support what I am trying to achieve without having to do layout work afterwards (which sometimes does not work properly across different devices).