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

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).

Anyway you will need using ā€œtemplateā€ option since you got 2 entities.
Read this.
And multiple-entity-row does not support sliders.

I think this is above me. I tried adapting your linked example to some simple sensors that my HA has, but I failed miserably.
I am surprised at how difficult this is proving to be. :persevere:

Create any complex card w/o auto-entiies.
Let it be a stack of Entities cards + Glance cards + some graphs, whatever.
Do it in storage mode.
Then open a generated dashboard file - you will find a json code.
Here is a draft of your template ))))

Oh, I was not aware. I will need to give that a try. Is it possible to switch back and forth between storage and yaml mode without creating issues on dashboards?

You may use several dashboards in storage mode & several dashboards in yaml.
Usually yaml is used for ā€œcombatā€ tasks, storage - for testing.

I just looked at the Multiple Dashboards - Home Assistant documentation and it looks like storage is the default anyway. Never considered moving my dashboards to yaml. But will do now. Much easier to backup than manually.

Thank you, I will check it out this weekend and hopefully learn somthing from the syntax that will help me here.

How can I include an entity based on the state of another entity?

I want sensor.device_a_locked to show up only when device_tracker.device_a is home.

ā€œtemplateā€ option.

I myself prefer a ā€œall config is in yamlā€ way & dislike the current trend ā€œmove config to UIā€.
Easier to backup, to temporarily include/exclude a code, move a code to another HA instance etc.

1 Like

Yes. ā€žTemplatingā€œ is like 42: itā€™s the answer to everything, right :laughing:

No idea how to do this.