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

[[ P.S. I love that you Have an ā€œArrakisā€ light. What does it do exactly? :slight_smile: ]]

Iā€™m trying to get an action to work that uses an attribute of the entities but nothing ever happens. This is my card code, which does populate correctly

type: custom:auto-entities
filter:
  include:
    - integration: twitch
      state: streaming
      options:
        type: horizontal-stack
        cards:
          - type: tile
            show_entity_picture: true
            entity: this.entity_id
            state_content: game
          - type: button
            tap_action:
              action: call-service
              service: androidtv.adb_command
              data:
                command: >-
                  am start -a android.intent.action.VIEW -d twitch://stream/{{state_attr(this.entity_id, 'friendly_name') }}
              target:
                entity_id: media_player.android_tv_living_room
            icon: mdi:sofa
            icon_height: 35px
card_param: cards
card:
  type: vertical-stack

I know that the command works if I give it a value manually, so the specific problem is that the {{state_attr(this.entity_id, 'friendly_name') }} isnā€™t working.

And not supposed to work since a standard button card does not support templates.

Hi all,

Tried searching and didnā€™t see anything, so apologies if I missed this. Recently when Iā€™ve tried to update one of my auto-entities cards it has caused Home Assistant to crash. I do have a ton of entities, so perhaps this is why? Is there anything I should be doing differently to avoid this?

Hereā€™s my card yaml:

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          template: |
            {% for sensor in states.sensor %}
              {% if (sensor.state|int(0) - states('sensor.average_temperature')|int)|abs > 10 and state_attr(sensor.entity_id,'device_class') == 'temperature' %}
              {{ sensor.entity_id}},
            {% endif %}
            {% endfor %}
          exclude:
            - name: Outside*
            - name: Garage*
            - name: OpenWeatherMap*
            - name: Filtered*
            - name: Processor*
            - name: '*Vibration*'
            - name: '*Device temperature*'
            - name: '*Owlet*'
            - state: unavailable
            - state: unknown
            - name: '*Meat*'
            - name: '*Freezer*'
            - name: '*Fridge*'
            - name: '*Pixel*'
            - name: '*Forecast*'

Cannot use these 2 filter options together.
Either:
ā€“ include
ā€“ include + exclude
ā€“ template

1 Like

Ah, thank you for pointing that out! I swapped it out with the Custom Button Card and itā€™s working perfectly now.

hello i am new to this hoping you can give me some advice

i want to hide/show an entity based on a different entity (sensor) status:

  • ā€œmedia_player.androidā€ should only be displayed when
  • ā€œsensor.lg_tv_power_stateā€ is ā€œonā€

this is probably pretty simple with templates but i am struggling with the syntax. maybe somebody can give me a code example of a similar scenario working (i.e. an auto-entity card filtering an entity based on another entityā€™s status)

thank you!

If Iā€™m understanding correctly then you donā€™t even need the auto-entity card; you can just this with a conditional card. Is this what youā€™re wanting?

type: conditional
conditions:
  - condition: state
    entity: sensor.lg_tv_power_state
    state: 'on'
card:
  type: media-control
  entity: media_player.android

2 Likes

im sorry yes forgot to report back. managed it meanwhile with the condition card which proved to be the better way of doing this anyway. thanks

Templated Gauge card.
post

1 Like

Hi! First, i love this card!

I am triying to automatically create popups with buble card, each of one has inside another autoentites card to create a grid with mushroom template card.

I have been triying many ways but not luck. I donā€™t even know if this is possible.

Is there any chance that you give a hand?

Million thanks!

This would be the schema:

Is it possible that only the light group is displayed and not the individual lamps in the group. Havenā€™t found anything about this yet.

With exclude: and group: I can exclude the lamps from the group, but I then have to enter this for each group.

I tried with a wildcard but this works, does anyone know why? Iā€™ve already tried with " ".

type: custom:auto-entities
show_empty: false
card:
  show_name: true
  show_icon: true
  show_state: false
  type: glance
  title: Lichter an
  state_color: true
  columns: 2
filter:
  include:
    - domain: light
      state: 'on'
      options:
        tap_action:
          action: toggle
    - type: ''
  exclude:
    - name: AU_Wand
    
    - group: light. *
    
    
  sort: null
  method: friendly_name

how can i set between each friendlyname missmatch a divider?

type: custom:auto-entities
card:
  type: entities
  title: Proxmox LXC
  state_color: true
filter:
  include:
    - device_model: LXC
      entity_id: '*status'
      options: {}
    - entity_id: '*cpu_auslastung'
      options: {}
  exclude: []
sort:
  method: friendly_name
  reverse: true
  ignore_case: false
  numeric: false
  ip: false

Can anybody help me please? I canā€™t get this combination of cards to work.

The idea is to have a card that only shows up when thereā€™s an update. If itā€™s an update from HACS, it shows witch update it is (instead of only having a number of how many updates HACS has). The updates from within home assistant are already specified, so they show up as well)

Hereā€™s the code:

type: custom:auto-entities
show_header_toggle: false
card:
  type: entities
  title: Add-on & Integratie Updates
  show_header_toggle: false
  filter:
    include:
      - domain: update
        state: 'on'
      - entity_id: sensor.hacs
        state: '! 0'
  show_empty: false
  sort:
    method: last_triggered
- type: markdown
  title: HACS Updates
  content: |-
    {%- if is_state('sensor.hacs','0') -%}
      <b><font color=green>No updates</font></b>
    {%- else -%}
      <table width=100%>
      {%- set hacs_updates = state_attr('sensor.hacs','repositories') -%}
      {%- for hacs_update in hacs_updates -%} 
        <tr><td><b><font color=red>{{[hacs_update][0]['display_name']}}</b></font></td><td>{{[hacs_update][0]['installed_version']}}</td><td>{{[hacs_update][0]['available_version']}}</td></tr>
      {%- endfor -%}
      </table>
    {%- endif -%}

Ofcourse it doesnā€™t need to be a markdown card at the bottom, if anybody can figure out how to show the attributes in the entities card part, itā€™s cool to. I just want it to show me the specifications of the updates from HACS, when there are updates.

I think i found it, but if anybody has a batter way of doing this, i would like to hear it.

This is what i have now:

type: custom:auto-entities
filter:
  include:
    - domain: update
      state: 'on'
    - entity_id: sensor.hacs
      state: '! 0'
show_empty: false
sort:
  method: last_triggerd
card:
  type: custom:stack-in-card
  title: Add-on & Integratie Updates
  mode: vertical
  cards:
    - type: custom:auto-entities
      card:
        type: entities
        show_header_toggle: false
      filter:
        include:
          - domain: update
            state: 'on'
      show_empty: false
      sort:
        method: last_triggerd
    - type: custom:auto-entities
      card:
        type: markdown
        content: |-
          {%- if is_state('sensor.hacs','0') -%}
            <b><font color=green>No updates</font></b>
          {%- else -%}
            <table width=100%>
            {%- set hacs_updates = state_attr('sensor.hacs','repositories') -%}
            {%- for hacs_update in hacs_updates -%} 
              <tr><td><b><font color=red>{{[hacs_update][0]['display_name']}}</b></font></td><td>{{[hacs_update][0]['installed_version']}}</td><td>{{[hacs_update][0]['available_version']}}</td></tr>
            {%- endfor -%}
            </table>
          {%- endif -%}
      filter:
        include:
          - entity_id: sensor.hacs
            state: '! 0'
      show_empty: false
      sort:
        method: last_triggerd

Hi, some time has passed since the last message, but now Iā€™m back on my card and I would like to fix it permanentlyā€¦
Have you found a new (working) way to monitor all the devices on the network
Thanks

Hi, yes I have a way of monitoring all my network devices. But it involves my unifi network devices. Never got back to using nmap. Since the unifi integration does enough for me.

Hi,

I was hoping that i could get some help. I am looking for two things.

I borrowed some of a script from this thread to show all my devices that are lights/on. I have a kasa power strip setup with my cable modem so I can reboot it. However it always is on & needs to be on. The script below shows everything but i cant seem get the exclusion to work.

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: light.*
      state: 'on'
      options:
        type: custom:mushroom-update-card
        entities:
          - this.entity_id
        tap_action:
          action: call-service
          service: homeassistant.turn_off
          service_data:
            entity_id: this.entity_id
  exclude:
    - device: TP-LINK_Smart Plug_3BFF


While this does work - the cable modem which is the device above - still shows up. I also tried the entity but that doesnt work either.

2nd question:

How can I setup an auto-entities based on an integration?

For example I use the Lutron integration - how can i get it working?

`type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - device_manufacturer: lutron
      device: lutron
  exclude: []
`

This for some reason doesnt work. Any ideas?

Hi i have a question: is it possible to fill vertical stacks + child items from one auto entities card?

I try something like this:

    type: custom:auto-entities
    show_empty: false
    card:
      type: custom:layout-card
      layout_type: custom:grid-layout
    filter:
      template: >-
        {%- set area = 'Wohnzimmer'-%}
        {%- set domains = states | selectattr('entity_id',
        'in',area_entities(area)) | map(attribute='domain') | unique | list -%} 
        {%- for domain in domains  -%}
        {% set entities = states   | selectattr('entity_id',
        'in',area_entities(area))  | selectattr('domain', 'eq', domain) 
         | list -%}  
           {{{ 'type': 'vertical-stack',
               'title': domain,
               'cards':
               [{'type': 'entity', 
                 'entity': 'light.bad'}]}}},
           {%- for entity in entities  -%}
               {{{ 'type': 'entity',            
                   'entity': entity.entity_id, }}},
           {%- endfor %}{%- endfor %}

This gives me a vertical stack for every domain i have. The only entity in the stack is ā€œlight.badā€ which i manually put in there. The other loop gives me all other entities but there are single cards not put into the vertical stack.

any way to achieve every domain + entities of that domain go into a vetical stack?

PS: i have a working example but with two auto entities card. so one creates another and i think this slows down the generating

how can i count all entities through this nested loop?

      {%- set areas = states.light | selectattr('state','eq', 'on') |
      map(attribute='entity_id') | map('area_name') | unique | reject('none')  |
      list -%}  {%- for area in areas  -%}   {%- set entity_filter = ''
      %}          {% set entities = states.light   | selectattr('state','eq',
      'on') | selectattr('entity_id', 'in', area_entities(area)) |
      rejectattr('entity_id', 'in', entity_filter) | list -%}       
           {{entities | length }}         
         {%- for entity in entities  -%}
         {%- endfor %}{%- endfor %} 

gives me the output
image

how to ged 6 instead of 5 and 1?