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

I want to know how to do this as wellā€¦

how can I do this:

  - type: custom:auto-entities
    card:

    filter:
      include:
        - group: group.z_wave_switches
          options:
            type: vertical-stack
            cards:
              - type: custom:decluttering-card
                template: update_zwave_switches
                variables:
                  - id: *object _id of switch in the group*

this is a work in progress, so the top card is not yet set, (do I need the vertical stack there, or ?).

to give you an idea what the manually configured stack look like for a couple of entities:

  - type: vertical-stack
    cards:
      - type: custom:decluttering-card
        template: update_zwave_switches
        variables:
          - id: afzuigkap_zolder

      - type: custom:decluttering-card
        template: update_zwave_switches
        variables:
          - id: amp_right_auditorium

      - type: custom:decluttering-card
        template: update_zwave_switches
        variables:
          - id: dorm_studenten

      - type: custom:decluttering-card
        template: update_zwave_switches
        variables:
          - id: freezer_garage

      - type: custom:decluttering-card
        template: update_zwave_switches
        variables:
          - id: freezer_bijkeuken

where each decluttering card is a horizontal stack of 3 button cards :wink:

cut it short: I need to template the object_idā€™s of each group member and auto fill these in the decluttering card

something like this pseudo-code:

  - type: custom:auto-entities
    card:
      type: vertical-stack
      cards:
        - type: custom:decluttering-card
          template: update_zwave_switches
    filter:
      template: |
        {{ expand('group.z_wave_switches') | map(attribute='object_id') | list }}

hope this is clearā€¦

Why not use grid card with column: 3 as option instead of vertical+horizontal? And then decluttering card as the card inside it using filter, which will give a grid with 3 button cards horizontally.

yes, I could do that too, my config is from before the grid card :wink:
will try and rebuild that, might be better. thanks for the suggestion.

but my main question is not about the layout, it is about the selection of the entities, and how to use the object_id in the auto-entities cards filter / decluttering-card

  - type: custom:auto-entities
    filter:
      include:
        - group: group.z_wave_switches
    card:
      type: vertical-stack
      cards:
        - type: custom:decluttering-card
          template: update_zwave_switches
          variables:
            - id: this.object_id

doesnt work but gives a better Idea maybeā€¦

Use case: I have several custom:auto-entities inside an entities card. If none of the auto-entities show up, I have a blank entities card.

Q: How can I hide the whole card, if none of the auto-entities cards inside that card show anything?

example:

type: custom:auto-entities
card:
  type: entities
  title: šŸšŖ TĆ¼ren, Fenster & Co
  state_color: true
  show_header_toggle: false
show_empty: false
entities:
  - type: custom:auto-entities
    [...]
  - type: custom:auto-entities
    [...]
  - type: custom:auto-entities
    [...]
    show_empty: false
    unique: true
    sort:
      method: last_changed
      reverse: true

If you want someone to help you, you should simplify a task.
200 lines in your code.
image
Start with TWO simple lists in your entities card.

The sense of the code is just to visualize what my words were talking about :smiley:
Should be much easier to read meanwhile. Now IĀ“m sure the help will come shortly :wink:

Then do not put auto-entities INSIDE entities card:

  - type: custom:auto-entities
    card:
      type: entities
      title: some title
      state_color: true
    unique: false
    show_empty: false
    filter:
      include:
        - entity_id: sensor.ac68u_snmp_mem*
          options:
            secondary_info: last-changed
          sort:
            method: name
            reverse: false
            ignore_case: true
        - entity_id: sensor.cleargrass_1_*
          options:
            secondary_info: last-changed
          sort:
            method: state
            reverse: false
            numeric: true
        - entity_id: sensor.cleargrass_2_*
          options:
            secondary_info: last-changed
          sort:
            method: state
            reverse: false
            numeric: true

There are three lists inside.
In your case you will probably get an empty card since you do not have entities sensor.ac68u_snmp_mem*, sensor.cleargrass_1_*, sensor.cleargrass_2_*.

As I need a title for each list (for each custom:auto-entities) I think I need to put them inside an entities card. This is what you could (have) see(n) in my initial post with full yaml code (200 lines, you remember :-D).

TITLE FOR WHOLE CARD
- Subtitle (Title of auto-entities card)
... List elements
... List elements
...
- Subtitle (Title of auto-entities card)
... List elements
... List elements
...
- Subtitle (Title of auto-entities card)
... List elements
... List elements
...

WhereĀ“s the difference in your code snippet compared to mine?
You use single entities within ONE auto-entities card, I need to nest several of them because I visually combine several lists to one card.

Again, main question: How can I hide the whole card, if none of the auto-entities cards inside that card show anything?

Hope I described the issue good enough.

Strange you do not see the difference.
You got Auto-entities inside Auto-entitiesā€¦
Dream inside a Dream (ā€œInceptionā€)

Then there is no solution.

Surely you may put "type: section" rows before each list - but then only these rows are displayed if lists are empty - and then the card will be displayed too since the WHOLE list is not empty.

If itĀ“s really not possible to hide the card when no lists elements exist (still doubt it)ā€¦

Why can auto-entities not realize thereĀ“s no element (consisting of nested, empty sub auto-entities) @thomasloven? This is working on the first level, so just wondering.

You may try to achieve this by using template option of auto-entities card.
Actually, LOT OF THINGS are possible with a template. Just learn & doā€¦

Sorry for repost, butā€¦

I have a question. I want to achieve somewhat simple setup. I want to have fold entities auto populated with auto entity like here:

obraz
But with toggles for the sections.

I played with static fold entity and was able to get whatā€™s in the screenshot but I donā€™t know how to use auto-entity to get entities for the fold row.

I know I could have the toggle for the section if I would for example create light group with all entities for area but I was thinking if there is a way to do it without this step.

Just a tipā€¦ I tried to make more items fit in a small space.

FROM:


TO:
image

This is the css-mod item I added to the code:

type: custom:auto-entities
card:
  type: entities
  style: |
    #states > div {
      margin: -15px 0px;
    }

To capture the individual divs under <div id="state"> you have to add ā€œ> divā€ in the css.

Other example: with secondary info (note that the coloring does not work like this. the screenshot was colored with the browser inspector)

image

type: custom:auto-entities
card:
  type: entities
  style: |
    #states > div {
      margin: 0px 0px;
    }
    .secondary, ha-relative-time {
      color: #ed2323;
    }

Cheers
DJ

1 Like

I really love the idea of auto-entities and this is an awesome card!

I was creating a card in another thread using apexcharts-card and custom-config-card to create a dynamically changeable plot Dynamic selection.

The only downside being, that I have to manually define the input_select.sensors_to_show. I think this is were auto-entities could come in and make this far more convenient and future proof.

Would it be possible to use auto-entities to define variables on-the-fly?

My idea was:

  • Create an input_select with the includes for auto-entities (e.g. ā€˜areaā€™, ā€˜sensorsā€™, ā€˜devicesā€™ etc.). These are static anyway and do not change when adding new devices.
  • Use this input_select as include parameter for auto-entities. Auto-entities would then create a list of e.g. all areas
  • Create a variable of the auto-entities list and forward it to the next card.

Would this be possible?
My current code is

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_select.days_back_to_show
        name: Number Of Days To Show
      - entity: input_select.sensors_to_show   #this is what auto-entities would need to supply
        name: Select Sensor
  - type: custom:config-template-card
    entities:
      - input_select.days_back_to_show
      - input_select.sensors_to_show
    variables:
      sensor: states['input_select.sensors_to_show'].state
      span: states['input_select.days_back_to_show'].state+'d'
      days: |
        -states['input_select.days_back_to_show'].state+'d'+'1d'
    card:
      type: custom:apexcharts-card
      graph_span: ${span}
      span:
        start: day
        offset: ${days}
      series:
        - entity: ${sensor}
          stroke_width: 2
          group_by:
            func: raw

EDIT:
I think it should be something along the lines of this, but I am not sure how auto-entities passes on the entities it uses, so I am not sure if it can populate a series.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_select.days_back_to_show
        name: Number Of Days To Show
  - type: custom:auto-entities
    card:
      type: custom:config-template-card
      variables:
        sensor: states['input_select.sensors_to_show'].state
        span: states['input_select.days_back_to_show'].state+'d'
        days: |
          -states['input_select.days_back_to_show'].state+'d'+'1d'
      card:
        type: custom:apexcharts-card
        graph_span: ${span}
        span:
          start: day
          offset: ${days}
        series:
#          - entity: ${sensor}    this would need to be populated
            stroke_width: 2
            group_by:
              func: raw
              #duration: 1min
    entities:
      - input_select.days_back_to_show
    filter:
      include:
        - domain: sensor

@AleXSR7001 I do not think you will be able to achieve what you want.

First of all, when calling domain: sensor auto-entities will return ALL of your sensors.
So making graphs for ALL of them at the same time, while trying to preview large time spans, such as 10 days, will definately make your tab crash.

Second, try this as a simple example:

    type: custom:auto-entities
    card:
      type: entities
    filter:
      include:
        - domain: sensor
          options:
            type: custom:apexcharts-card
            graph_span: 1h
            span:
              start: day
              offset: 1h
            series:
              - entity: this.entity_id ### this is how you achieve auto-entities 
                                      ### to pass the entity_id 
                stroke_width: 2
                group_by:
                  func: raw
                  duration: 1min

You will have this result

As you can see, auto-entities pass the entity_id twice and apexchars-card does NOT accept an entity value on the main config, so it throws an error that value.entity is extraneous

What you CAN do, is to use the stock history graph and the hui-element card.
However you will not be able to go days back, but only hours back.

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_select.hours_to_show
      - entity: input_select.sensors_to_show ### define options such as 'sensor', 'binary_sensor', 'light' etc
  - type: custom:config-template-card
    entities:
      - input_select.hours_to_show
      - input_select.sensors_to_show
    variables:
      hours: states['input_select.hours_to_show'].state
      sensors: states['input_select.sensors_to_show'].state
    card:
      type: custom:auto-entities
      card:
        type: entities
      filter:
        include:
          - domain: ${sensors}
            options:
              type: custom:hui-element
              card_type: history-graph
              hours_to_show: ${hours}
              entities:
                - entity: this.entity_id

1 Like

I am not concerned about the amount of sensors as I would be adding a second and maybe third input_select.
So I would most like have

  1. days to show
  2. area to show
  3. device type/domain to show

So in the end it would be around 1-5 sources (same as now).

I think this is a ā€œmissingā€ feature im auto-entities. It can only handle the parameter ā€œentitiyā€ and not ā€œentitiesā€, so it cannot fill the series: entities:.

I will try my luck in the auto-entities github and ask if it could be added as a feature :slight_smile:

Hi.

I am in need with auto-entities and showing an attributeā€¦ I want to show the IP of a device_tracker item, under developer_tools i can see that attribute is availble but i just canā€™t seem to get it showing in the auto-entities listā€¦

The following code is the working

type: custom:auto-entities
card:
  type: entities
  title: Home
filter:
  include:
    - domain: device_tracker
  exclude:
    - state: unavailable
    - state: not_home
sort:
  method: name

I know the following fixed entities card wil work :

type: entities
title: Entities card sample
entities:
  - type: attribute
    entity: device_tracker.desktop
    attribute: ip

Anyone an idea how to get that working with auto-entities ?

Try this:

type: custom:auto-entities
card:
  type: entities
  title: Home
filter:
  include:
    - domain: device_tracker
      options:
        type: attribute
        attribute: ip
  exclude:
    - state: unavailable
    - state: not_home
sort:
  method: name

It works if ALL trackers have this attribute.
Otherwise it will show ā€œ-ā€ for those trackers which do not have.
For example, ASUSWRT-based trackers do have ip attribute, Life360-based & ping-based (which is strange for me) - do not.