🔹 Auto-entities - Automatically fill cards with entities

The code is quite simple, I was overcomplicating things in my post before. I ended up using Auto entities, Mushroom card and Card mod. My final code code is:

type: custom:auto-entities
filter:
  include:
    - domain: update
      state: 'on'
      options:
        type: custom:mushroom-update-card
        show_buttons_control: true
        layout: horizontal
        card_mod:
          style:
            mushroom-state-info$: |
              .secondary {
                visibility: hidden;
              }
              .secondary:before {
                visibility: visible;
                content: "{{ state_attr(config.entity, 'installed_version')}} → {{ state_attr(config.entity, 'latest_version')}}";
              }
            .: |
              ha-card {
                --secondary-text-color: white;
              }
sort:
  method: friendly_name
card_param: cards
card:
  type: vertical-stack

It looks like this, and list vertically all current updates:
image

I am sorry. I read area and thought zone.

Please ignore :slight_smile:

How do you expect this to be shown?
An area is not an entity.
You may list entities belonging to an area.
You may list area-cards for all areas.

I’d like to do the same thing, after a lot of reading, now I’m trying to achieve this by using templating, but I’m stuck at the point where I’d add sub-entities to the row.
Current code:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {% for s in states.sensor -%}
      {%- set value = s.entity_id -%}
      {%- set pattern = '_node_status' -%}
      {%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
      {%- if res == pattern -%}
        {{-
          {
            'entity': s.entity_id,
            'secondary_info': 'last-changed',
            'type': 'custom:multiple-entity-row',
            'entities': '',
            '- entity': s.entity_id,
            '  name': s.name,
          }
        -}},
      {%- endif -%}
    {%- endfor %}

Of course it doesn’t work after adding the entities: part, so it seems my Jinja2 knowledge has reached it’s limit :slight_smile:
The part after entities: is intentionally '', at least this way the preview window displays how it would render the template code.
Any ideas?

Hi all.

I’m trying to use this to show sensors where the state is greater than one of its attribute values

I’ve tried

state: “< this.entity_id.maximum_normal”

Where the attribute is maximum_normal

But it’s obviously wrong, the particular sensor(s) never show, regardless of state value.

Can anyone help?

The enities needs to be a list of tuple.

Not sure this is complete, but try something like this:

    {% for s in states.sensor -%}
      {%- set value = s.entity_id -%}
      {%- set pattern = '_node_status' -%}
      {%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
      {%- if res == pattern -%}
        {{
          {
            'entity': s.entity_id,
            'secondary_info': 'last-changed',
            'type': 'custom:multiple-entity-row',
            'entities':
              [{'entity': s.entity_id,
               'name': s.name}],
          }
        }},
      {%- endif -%}
    {%- endfor %}
1 Like
1 Like

Thanks. I was expecting to just enter something in the visual editor. I’ll give it a go :blush:

@cavester

  1. I think that the previous posts were not addressed to you.
  2. You already asked a similar question here)). My answer - here.
  3. Another example:
  - type: custom:auto-entities
    card:
      type: entities
    filter:
      template: >-
        {% for SENSOR in
        states.sensor|selectattr('entity_id','search','threshold.*settings') -%}
          {%- if states(SENSOR.entity_id)|float(default=0) > SENSOR.attributes.some_attr|float(default=0) -%}
            {{
              {
                'type': 'custom:template-entity-row',
                'entity': SENSOR.entity_id,
                'name': 'xxx',
                'state': states(SENSOR.entity_id) + ' / ' + SENSOR.attributes.some_attr|string
              }
            }},
          {%- endif -%}
        {%- endfor %}

1 Like

My bad then.
Thanks for your help.

1 Like

yeah i was trying to find the areas to see if they ware an entity. The only reaosn i ask is that Mushroom strategy automatically creates the areas and i thought i could do the same, but i can just as easily do it manually.

Thanks, this was the missing piece! :pray:
Here’s the final version, if someone interested: (@darkson95)

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {% for s in states.sensor -%}
      {%- set value = s.entity_id -%}
      {%- set pattern = '_node_status' -%}
      {%- set res = value | regex_findall_index(pattern) if value is search(pattern) else "" -%}
      {%- if res == pattern -%}
        {%- set name = s.name.replace('Node status', '') -%}
        {%- set lvl = s.entity_id.replace(pattern, '_battery_level') -%}
        {%- set low = s.entity_id.replace('sensor.', 'binary_sensor.').replace(pattern, '_low_battery') -%}
        {{-
          {
            'type': 'custom:multiple-entity-row',
            'entity': s.entity_id,
            'name': name,
            'secondary_info': 'last-changed',
            'entities': [
              {'entity': lvl,
               'name': 'Battery',
               'format': 'precision0'},
              {'entity': low,
               'name': 'Level'},
            ],
          }
        -}},
      {%- endif -%}
    {%- endfor %}
1 Like

hey, im using this Code, someone can tell my why it shows me not only the “Severe” text? (the 4. Text only)
image

type: custom:auto-entities
card:
  type: grid
  square: false
  columns: 1
card_param: cards
filter:
  include:
    - domain: binary_sensor
      entity_id: '*warning_landshut*'
      state: 'on'
      options:
        type: entities
        style: |
          ha-card {
            background-color: rgba(255, 80, 80, 0.2);
            font-size: 14px;
          }
        entities:
          - type: attribute
            entity: binary_sensor.warning_landshut_1
            attribute: headline
            name: Landshut
            icon: mdi:alert-octagon
          - type: attribute
            entity: binary_sensor.warning_landshut_2
            attribute: headline
            name: Landshut
            icon: mdi:alert-octagon
          - type: attribute
            entity: binary_sensor.warning_landshut_3
            attribute: headline
            name: Landshut
            icon: mdi:alert-octagon
          - type: attribute
            entity: binary_sensor.warning_landshut_4
            attribute: headline
            name: Landshut
            icon: mdi:alert-octagon
          - type: attribute
            entity: binary_sensor.warning_landshut_5
            attribute: headline
            name: Landshut
            icon: mdi:alert-octagon
  exclude:
    - attributes:
        severity: Minor
    - attributes:
        severity: Moderate
sort:
  method: friendly_name
  reverse: false

You are using the card in a wrong way.
The “options” tells to show a card with fixed 5 rows.

can you tell me a liitle bit more about it?
with this info i dont know how i should fix it, my yaml knowledge ist not so good

i tried this too, without success

type: custom:auto-entities
card:
  type: grid
  square: false
  columns: 1
card_param: cards
filter:
  include:
    - domain: binary_sensor
      entity_id: '*warning_landshut*'
      state: 'on'
  exclude:
    - attributes:
        severity: Minor
    - attributes:
        severity: Moderate
sort:
  method: friendly_name
  reverse: false
options:
  - type: entities
    style: |
      ha-card {
        background-color: rgba(255, 80, 80, 0.2);
        font-size: 14px;
      }
    entities:
      - type: attribute
        entity: binary_sensor.warning_landshut_1
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_2
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_3
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_4
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_5
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon

Why do you use Grid for one card?

this was the only way i found to work :sweat_smile:

Take any example for Entities card from auto-entities repo as a basis.
You do not need Grid.

Like this? this is not working

type: custom:auto-entities
card:
  type: entities
  title: Test
card_param: cards
filter:
  include:
    - domain: binary_sensor
      entity_id: '*warning_landshut*'
      state: 'on'
  exclude:
    - attributes:
        severity: Minor
    - attributes:
        severity: Moderate
sort:
  method: friendly_name
  reverse: false
options:
  - type: entities
    style: |
      ha-card {
        background-color: rgba(255, 80, 80, 0.2);
        font-size: 14px;
      }
    entities:
      - type: attribute
        entity: binary_sensor.warning_landshut_1
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_2
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_3
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_4
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon
      - type: attribute
        entity: binary_sensor.warning_landshut_5
        attribute: headline
        name: Landshut
        icon: mdi:alert-octagon

From repo.