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

Shure, no probleme.
here you are:

cards:
  - content: |
      # Batteriestatus:
    type: markdown
  - card:
      show_header_toggle: false
      type: entities
    filter:
      exclude:
        - entity_id: '*battery_state*'
      include:
        - entity_id: '*battery*'
    show_empty: false
    sort:
      method: name
      numeric: true
    type: 'custom:auto-entities'
id: card_batterylow
type: vertical-stack

You might have to play with the include and exlude filter to get your best results.

Withā€¦

    sort:
      method: state
      numeric: true
      reverse: true

ā€¦you get the sorting from the screenshot.

1 Like

Unfortunately, I canā€™t easily test or debug in Edge, since Iā€™m a mac user, and the mac version uses the chromium engineā€¦

2 Likes

making use of this very nice card, I do wonder what the default sort order is (ie when one doesnā€™t use sort: in the card config).

My entities are listed in a way I donā€™t recognize to be alphabetical, or by the config in the backend at all, nor by state or order in the group they auto-populate, well, by anything reallyā€¦

Would be cool to understand how and why they are listed as they are:

this is the card config for the Switches cl:

      - type: custom:fold-entity-row
        head:
          type: section
          label: Switches cl
        entities:
          - type: custom:auto-entities
            card:
              type: entities
              show_header_toggle: false
            filter:
              include:
                - entity_id: 'switch.*_cl'
                  options:
                    secondary_info: last-changed

26

or

secondly, if Id like the entities of

      - type: custom:fold-entity-row
        head:
          type: section
          label: Lights
        entities:
          - type: custom:auto-entities
            card:
              type: entities
              show_header_toggle: false
            filter:
              include:
                - group: 'group.all_lights_only'
                  options:
                    secondary_info: last-changed

to be sorted according to the group order, what would be the correct sort config?

all_lights_only:
  name: All lights only
  icon: mdi:lightbulb-outline
  entities:
# Philips_Hue_lights
    - light.backdoor_outdoors
    - light.gate_outdoors
    - light.porch_outdoors
    - light.laundry_ceiling
    - light.dining_corner
    - light.symfonisk
    - light.dining_table_lamp_1
    - light.dining_table_lamp_2
    - light.dining_table_lamp_3
    - light.kist
    - light.cabinet
    - light.serre_chair
    - light.lounge_chair_regular
etc
etc
etc

Ive filed a FR to add last-triggered to the sort options, which would be way cool to auto generate a card with the most active automations and scripts, and be a magic tool for the inspection of the system. Hope you will consider.

First of all, you are using fold-entity-row and auto-entities the ā€œwrongā€ way (with the disclaimer that ā€œif itā€™s stupid and it works, itā€™s not stupidā€ - thereā€™s no actually wrong way).

They are both specificlaly designed to work like

- type: custom:auto-entities
  card:
    type: custom:fold-entity-row
    head:
      type: section
      label: Lights
  filter:
    .. etc...

Edit: I must say your way looks really good, though.

Second; last triggered is an attribute of the script, as opposed to last_changed and last_updated which are ā€œmagicalā€ values. You can already sort by attribute values.

On to your question.
The order the entities show up in if not sorted is the same they are given in the "hass object", which is pretty much your current Home Assistant state. It depends a bit on your python, version, the order your integrations are loaded in, the order things are set up in your configuration and which sign of the zodiac Jupiter is currently in. In short, think of it as random.

If you use a group, the entities should show up in the same order they are listed in the group definition, but I canā€™t guarantee it.

1 Like

Hahaha! The sorting options are awesome as is this card. Really appreciate your great work Thomas.

haha, yes, that was my conclusionā€¦ thanks for confirming.

of course! thanksā€¦

this doesnt work though:

  - type: custom:auto-entities
    card:
      type: entities
      title: All Automations auto
      show_header_toggle: false
    filter:
      include:
        - domain: automation
          options:
            secondary_info: last-triggered
    sort:
      attribute: last_triggered

well, I hoped, but as you can see it isnā€™t the case. Sorted them by name for now, which at least has some eye candy, but group order would really be better, since they can be sub-ordered in the group without having to create separate groups.

cool, didnā€™t realize I did it the wrong way. Still, Iā€™ll try it the correct way, and see if it changes the issues I have :wink:
thanks for reporting back!

well it does make a difference, and in fact a significant one. Not in the order of the entities, but in the way it is rendered in the frontend:

my way:

your way:

39

have to think why this is happening, but, maybe good to realize the difference and make good use of it. Must admit I kind of like the elevated group popping out of the fold as an extra emphasis. But, as you say, not as per original design :wink:

Does it exist a way to use the auto-entities to show only the lights and sensors with an state = unavailable?

@thomasloven I tried to moved from monster-card to auto-entities but I have an issue with Boolean attribute. The following card was working with monster-card, but not with auto-entites:

EDIT: the latest version fixed the issue, thanks !

card:
  type: glance
filter:
  exclude:
    - state: 'off'
    - state: unavailable
    - entity_id: '*group*'
    - attributes:
        is_deconz_group: false
  include:
    - domain: light
      options:
        tap_action:
          action: toggle
show_empty: false
type: 'custom:auto-entities'

@gmario Iā€™m using the following to get unavailable entities:

card:
  type: glance
filter:
  exclude:
    - state: 'off'
    - state: 'on'
    - entity_id: '*group*'
    - attributes:
        is_deconz_group: false
  include:
    - state: unavailable
    - domain: light
      options:
        tap_action:
          action: toggle
show_empty: false
type: 'custom:monster-card'

First, this card is amazing. Thank you.

Is there any way to make show_empty: false based solely on filtered entities?

I only want to show my card if my filter: include: entity is true. But when I show my card, I also want to show entities that arenā€™t filtered.

Currently, my unfiltered entities are making my card show all the time.

HI,

trying to list my hue sensors as follows:

  - type: custom:auto-entities
    card:
      type: entities
      title: Hue threshold sensors
      show_header_toggle: false
    filter:
      include:
        - entity_id: '*_sensor_threshold'

which works fine, except for one thing: I have 4 threshold sensors for outside (ā€˜buitenā€™) I like to display together, while now they are scattered in the list. How can I order these to show first or last in the total list groups together?

this is what it looks like right now:

Add a not to the include filter you already have to filter them out, and then a new filter to filter them back in where you want them.

yes, thanks!

made a decluttering template for it:

auto_hue_sensors:

card:
  type: custom:auto-entities
  card:
    type: entities
    title: 'Hue [[type]] sensors'
    show_header_toggle: false
  filter:
    include:
      - entity_id: 'sensor.*_[[type]]'
        not:
          entity_id: '*buiten*'
        sort:
          method: name
      - entity_id: '*buiten_*_[[type]]'
        sort:
          method: name

and Lovelace config:

  - type: custom:decluttering-card
    template: auto_hue_sensors
    variables:
      - type: sensitivity

  - type: custom:decluttering-card
    template: auto_hue_sensors
    variables:
      - type: threshold

because to the extra _day and _night extension couldnā€™t find a way to use the decluttering template for this (yet, might have another go at it later on):

  - type: custom:auto-entities
    card:
      type: entities
      title: Hue schedule sensors
      show_header_toggle: false
    filter:
      include:
        - entity_id: 'sensor.*_schedule_*'
          not:
            entity_id: '*buiten*'
          sort:
            method: name
        - entity_id: '*buiten_schedule_*'
          sort:
            method: name


thanks! magical card it is.

1 Like

HI,
have to get back to one of my above posts concerning this auto-entities card for automations:

  - type: custom:auto-entities
    card:
      type: entities
      title: All Automations auto
      show_header_toggle: false
    filter:
      include:
        - domain: automation
          options:
            secondary_info: last-triggered
    sort:
      attribute: last_triggered

the sorting is nowhere near based on the last_triggered attributeā€¦ didnā€™t realize it then, but now that I fixed most other issues, I would like to understand what is incorrect here. Is it too difficult for the frontend to keep adjusting this view based on last_triggered (very frequent triggering) or is the config simply incorrectā€¦

note: I am talking about the sort: attribute: last_triggered, not the secondary_info: last-triggered, which is something else, and does work alrightā€¦

as a matter of fact,I canā€™t get any sort method to work for this cardā€¦ name nor entity_id. Even when I put the sort under the filter, no change is displayed?

really puzzled here.

The method: property is Required for sorting.

of courseā€¦ sorry I missed that. Still, no sure Im doing it as it should now:

  - type: custom:auto-entities
    card:
      type: entities
      title: All Scripts auto
      show_header_toggle: false
    filter:
      include:
        - domain: script
          options:
            secondary_info: last-triggered
    sort:
      method: attribute
      attribute: last_triggered
      reverse: true

it does make a difference, but is not consistent over the full list:

the scripts which havenā€™t been triggered yet donā€™t show a secondary_info line, do they cause havoc? Why are they not listed at the bottom ?

That may very well be the problem. last_triggered is a rather new feature which I havenā€™t looked into yet, but since Itā€™s a timestamp I imagine it should require some special treatmentā€¦

1 Like

sure, I made the PR for showing it on Lovlace-cards secondary_info in the first placeā€¦
Just now added the ā€˜bugā€™ discussion to add a ā€˜neverā€™ on that row if not yet triggered: https://github.com/home-assistant/home-assistant-polymer/issues/4428

awaiting that, do you have any suggestions for the order in this auto-card? Could I maybe only show the last 5 last_triggered entities by adding count: 5, to prevent constant re-rendering of the view?

please let me put forward another challenge I canā€™t find the solution for yet. Id like to auto create a card with all views to be able to create a ā€˜Castā€™ card. I now have this manually setup:

  - type: entities
    title: Cast Control
    show_header_toggle: false
    entities:

      - type: cast
        name: Home
        view: 'home'

      - type: cast
        name: System
        view: 'home_assistant'

      - type: cast
        name: Lights
        view: 'lights'

I can add all 23 tabs (ā€¦) of course, but couldnā€™t I somehow use the auto-entities card to create this. Simply follow the setup in ui-lovelace.yaml, and read the title (name) and path (view) into this cardā€¦

edit probably no, since these arenā€™t entitiesā€¦maybe something like lovelace_gen could do thisā€¦

Hi there,
Iā€™m trying to use auto-entities,layout-card and the button card to show lights as buttons if they are on.

It works like a charm but I like to put a header over the buttons (e.g. markdown card). I set the parameter show_empty:false in auto-entities-card. If there are no lights on, the auto-entities-card is not shown. But how could I hide a the header?

Example:

- type: vertical-stack
  cards:
          - type: markdown
            content: '#### Eingeschaltete Lampen'
          - type: custom:auto-entities
            show_empty: false
            filter:
              include:
                - domain: light
                  state: "on"
                  options:
                     type: custom:button-card
                     entity_id: this.entity_id
            card:
              type: custom:layout-card
              layout: horizontal
              min_columns: 3