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

I would also need the state, so script may not be the best option.

As for the template, I already tried but without success. Can someone help me with other examples? thanks.

Show us the code you tried.

I have nothing to show because I couldnā€™t find a way to use the template-entity-row inside the multiple-entity-row.

Surely it is not possible.
What I already advised you - create a list of multiple-entity-row by the template option and specify an entity for the action.

1 Like

I think the best option you have is to use a script like this:

  - type: custom:auto-entities
    card:
      type: custom:fold-entity-row
      padding: 10
      head:
        type: custom:template-entity-row
        name: Device Volumes
        icon: mdi:volume-high
        tap_action:
          action: fire-dom-event
          fold_row: true
    filter:
      include:
        - entity_id: input_number.*_volume
          options:
            secondary_info: last-changed
            tap_action:
              action: call-service
              service: script.media_player_volume_set
              service_data:
                entity_id:
                  - this.entity_id

So it can translate it for you to the new domain and action it.

@luisleonardo.pt
Adapt this example to you needs:

  - type: custom:auto-entities
    card:
      type: entities
    filter:
      template: >
        {% for DEVICE in states.device_tracker |
                         selectattr("entity_id","in",integration_entities("asuswrt")) |
                         selectattr("attributes.ip","defined") |
                         sort(reverse=true,attribute='name') -%}
            {{
              {
                'type': 'custom:multiple-entity-row',
                'entity': DEVICE.entity_id,
                'secondary_info': 'last-changed',
                'entities':
                  [
                    {
                      'name': 'type',
                      'attribute': 'source_type',
                      'styles':
                        {
                          'text-align': 'left'
                        },
                      'tap_action':
                        {
                          'action': 'more-info',
                          'entity': 'sun.sun',
                          'confirmation':
                            {
                              'text': 'entity: '+ (DEVICE.entity_id).split('.')[1]
                            }
                        }
                    },
                    {
                      'name': 'IP',
                      'attribute': 'ip',
                      'styles':
                        {
                          'width': '70px',
                          'text-align': 'right',
                          'font-size': '9px'
                        }
                    }
                  ],
                'show_state': false,
                'state_color': true
              }
            }},
        {%- endfor %}
    sort:
      count: 4

ŠøŠ·Š¾Š±Ń€Š°Š¶ŠµŠ½ŠøŠµ

Specify your own filter to enumerate your docker sensors.

Use a similar method:

 'text': 'entity: '+ (DEVICE.entity_id).split('.')[1]

to specify your switch entity.

4 Likes

Thanks. It worked. Later I will post my final code.

I have a rest sensor that pulls information on gas stations and their prices from a website and stores the whole list using json_attributes.

Every item has a lot of metadata such as longitude/latitude for describing where the gas station is and itā€™s current price. What I want to be able to do is to present this data using the awesome flex-table-card. The data should be dynamically filtered by location from the current logged in user.

This template gives me the current logged in person-object or zone.home and I use that to measure the distance of every item in the list and outputting items within 5km. I think of sorting the result using the flex-table-card. This code works.

  {% set current_person = states.person|selectattr("attributes.user_id", "==", user.id) | map(attribute='entity_id') | first | default('zone.home', false) %}
  {% set gas_prices = state_attr('sensor.gas_prices', 'prices') %}
  {%- for item in gas_prices -%}
      {% set station_distance = distance(item.latitude, item.longitude, current_person) %}
      {%- if station_distance < 5.0 -%}
        {{ item.name }},
  {%- endif -%}
  {%- endfor -%}

However. All cards are always operating with filtering multiple entityā€™s and not json listsā€¦ Is there a way to build a entity list using json similar to these two topcs?

šŸ”¹ Auto-entities - Automatically fill cards with entities - #531 by Ildar_Gabdullin and šŸ”¹ Auto-entities - Automatically fill cards with entities - #638 by Ildar_Gabdullin

The difference is that I need to make a list of entities with multiple attributes that I can pass to flex-table-card and from there use field/column manipulation as usualā€¦ As far as I can tell these examples only make single attributes and defining type to entity seems to be invalid. So as far as I can tell I just need to build the data object that flex-table can handleā€¦ If anyone has any ideas on how to do that I would be thrilled. :slight_smile:

auto-entities generates a list of entities.
Then the list may be used for flex-table-card.
But - I do not think that flex-table-card can work with JSON attributes.
Check issues to be sure.

Update: that could be a hasty conclusion; need some more time to test.

Has anyone luck with the Auto-entities card in combination with a custom:mushroom-template-card? It works with a custom:mushroom-entity-card:

Part of my code:

type: custom:auto-entities
card:
  type: grid
  columns: 3
  square: false
card_param: cards
show_empty: false
filter:
  include:
    - entity_id: sensor.status_wasmachine
      state: 'Aan'
      options: 
      type: custom:mushroom-template-card
      icon: >-
        {% if is_state('sensor.status_wasmachine', 'Uit') %}
        mdi:washing-machine-off {% else %} mdi:washing-machine {% endif %} 
      primary: Wasmachine
      secondary: '{{ states(''sensor.status_wasmachine'') }}'
      icon_color: >-
        {% if is_state('sensor.status_wasmachine', 'Uit') %} grey {% else %}
        blue {% endif %} 
    - entity_id: binary_sensor.garagepoort_door
      state: 'off'
      options:
        type: custom:mushroom-entity-card

Results in
image

I know nothing about mushroom cards but I see a wrong indentation here.

1 Like

Thx a lot :slight_smile:

Hi guys! Iā€™m looking for a way to automatically display entities in 2x2 grids and each grid is for a separate swipe-card.
This is the the original, static config:

type: custom:swipe-card
cards:
  - type: grid
    square: false
    columns: 2
    cards:
        - type: custom:button-card
          entity: person.demouser1
          template:
            - person
        - type: custom:button-card
          entity: person.demouser2
          template:
            - person
        - type: custom:button-card
          entity: person.demouser3
          template:
            - person
        - type: custom:button-card
          entity: person.demouser4
          template:
            - person  
- type: grid
    square: false
    columns: 2
    cards:
        - type: custom:button-card
...

And this is the furthest I got:

type: custom:auto-entities
card:
  type: custom:swipe-card
card_param: cards
filter:
  include:
    - entity_id: '*person*'
      options:
        type: custom:auto-entities
        card:
          type: grid
          columns: 2
        card_param: cards
        filter:
          template: |
            {%- for people in states.person | batch(4)  -%}
            {%- if loop.index0 == 0 %}
              {%- for person in people -%}
                {{ 
                  { 
                    'entity' : person.entity_id,  
                    'type' : 'custom:button-card',
                    'template': 'person'
                  }
                }},
              {%- endfor -%}
            {% endif %}
            {%- endfor -%}
      sort:
        count: 5
        first: 0

Now the first 4 entities are shown 5 times, because I cannot create an outer loop unfortunately.

I also tried creating a template for the outer auto-entities and returning a bigger object, but nothing is shown this way:

type: custom:auto-entities
card:
  type: custom:swipe-card
card_param: cards
filter:
  template: |
    {% set ns = namespace(obj="") %}
    {% set arr = '{"type": "custom:auto-entities", "card": {"type": "grid", "columns": 2}, "cards":[' %}


    {%- for people in states.person | batch(4)  -%}
      {% set ns.obj = '' %}
      {%- for person in people -%}

        {% set ns.obj = ns.obj +  '{"entity": "' + person.entity_id + '", "type": "custom:button-card", "template": "person"},' %}

      {%- endfor -%}
      {% set arr = arr + ns.obj + '], '%}
    {%- endfor -%}

    {{ arr  + ns.obj + '], "card_param": "cards"}'}}

Do you have any advice how can I achieve a solution for this problem?
Thanks!

Hi guys.

Got an weird issue with auto-entities in combination with mushroom cards.
It is not auto sorting for some kind of weird reason.

type: custom:auto-entities
show_empty: false
card:
  type: horizontal-stack
  cards:
    - type: custom:mushroom-entity-card
      entity: sensor.afvalwijzer_gft
      layout: vertical
      icon_color: green
    - type: custom:mushroom-entity-card
      entity: sensor.afvalwijzer_plastic
      layout: vertical
      icon_color: orange
    - type: custom:mushroom-entity-card
      entity: sensor.afvalwijzer_papier
      layout: vertical
    - type: custom:mushroom-entity-card
      entity: sensor.afvalwijzer_restafval
      layout: vertical
      icon_color: grey
filter:
  include:
    - entity_id: sensor.afvalwijzer_gft
      options: {}
    - entity_id: sensor.afvalwijzer_plastic
      options: {}
    - entity_id: sensor.afvalwijzer_papier
      options: {}
    - entity_id: sensor.afvalwijzer_restafvalr
      options: {}
  exclude: []
sort:
  attribute: year_month_day_date
  method: attribute

image
The order needs to be:
GFT, Plastic, Restafval and Papier.

What could be wrong here?

You are using auto-entities in a wrong way.
Read this.

1 Like

hi, would you mind sharing your code? Iā€™m trying to do exactly the same, thanks!

I canā€™t get the attribute to work here

    {% for DEVICE in states.sensor |
                         selectattr("attributes.network_speed_up","defined") |
                         sort(reverse=false,attribute='name') -%}
    {% set switch_name = 'switch.'+ (DEVICE.entity_id).split('.')[1]  -%}            
      {{
              {
                'type': 'custom:multiple-entity-row',                
                'entity': switch_name,
                'secondary_info': state_attr(DEVICE.entity_id, 'status'),
                'entities':
                  [
                    {
                      'name': 'cpu',
                      'attribute': 'cpu_percentage'
                    },
                    {
                      'name': 'status',
                      'attribute': state_attr(DEVICE.entity_id, 'status')
                    }
                  ],
              }
            }},
    {%- endfor %}
[
  {
    "type": "custom:multiple-entity-row",
    "entity": "switch.docker_bazarr",
    "secondary_info": "Up 5 hours",
    "entities": [
      {
        "name": "cpu",
        "attribute": "cpu_percentage"
      },
      {
        "name": "status",
        "attribute": "Up 5 hours"
      }
    ]
  },
  {
    "type": "custom:multiple-entity-row",
    "entity": "switch.docker_deconz",
    "secondary_info": "Exited (143) 6 days ago",
    "entities": [
      {
        "name": "cpu",
        "attribute": "cpu_percentage"
      },
      {
        "name": "status",
        "attribute": "Exited (143) 6 days ago"
      }
    ]
  },

See picture for card config

what am I doing wrong? :slight_smile:

1 Like

I want to archive the following:

  • Combining auto-entities as an input for multiple-entity-row
  • multiple-entity-row should display different entities like
sensor.pulsemeter_38_power
sensor.pulsemeter_38_energy_total
sensor.pulsemeter_38_energy_hourly
sensor.pulsemeter_38_energy_daily
...

Ifā€™ve tried to use the replace command to modify the ā€œTotalā€ entity, but unfortunately not working:

type: custom:auto-entities
card:
  type: entities
  title: "Multiple energy counter"
filter:
  include:
    - entity_id: sensor.pulsemeter_*_power
      options:
        type: custom:multiple-entity-row
        secondary_info: last-changed
        entities:
          - entity: this.entity_id
            name: Power
            format: precision1
          - entity: this.entity_id.replace("power", "energy_total")
            name: Total
            format: precision3

image

What is the magic hack to make the replace command up and running?

Use a ā€œtemplateā€ option. Find here examples for multiple-entity-row

Iā€™ve tried to use a template option like the following but s not working:

type: custom:auto-entities
card:
  type: entities
  title: StromkreiszƤhler
unique: entity
show_empty: true
filter:
  template: |
    {% for state in states.sensor -%}
      {%- if state.entity_id | regex_match('sensor.pulsemeter_.*._power',ignorecase=False) -%}
        {{
          { 'entity': state.entity_id,
            'name': '032.1.1_Strommonitor',
            'secondary_info': 'last-changed',
            'state_color': 'true',
            'type': 'custom:multiple-entity-row',
            'entities':,
              - 'entity': state.entity_id,
                'name': 'Power',
                'format': 'precision1'
          } }},
      {%- endif -%} 
    {%- endfor %}
sort:
  method: friendly_name
  numeric: true