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

Hello all,
Iā€™m strugling with list of tasmota devices.
it is possible to create hyperlink from list with ip?
image

tap_action:
  action: url
  url_path: this.entity_id

Happy Bew Year to you! Iā€™ll give it a go tomorrow. Thanks for your help

1 Like

only now starting with dark mode, I stumble upon this issue of not being able to set options for it using the auto-entities card with Map. Filed (edit: and closed, see below) an issue in the repo options not functional on Map card Ā· Issue #241 Ā· thomasloven/lovelace-auto-entities Ā· GitHub but thought it might be good to post/ask here too:

        - type: custom:auto-entities
          card:
            type: map
          show_empty: false
          filter:
            include:
              - domain: person
                options:
                  hours_to_show: 48
                  dark_mode: true
                not:
                  state: home

card works fine, with the exception of the options, which are simply not applied.

please have a look? thanks!

EDIT

o dear, how stupid of me. this is all there is to it:

        - type: custom:auto-entities
          card:
            type: map
            hours_to_show: 48
            dark_mode: true

nvm me.

Yes, these are card-wide options.

new challengeā€¦

replace:

        filter:
          include:
            - entity_id: sensor.*_actueel
              state: '>30'

with a state following an input_number.power_threshold

        filter:
          include:
            - entity_id: sensor.*_actueel
              state: '> input_number.power_threshold' # or states('input_number.power_threshold')

would be awesome ofc (like we can do with numeric state triggers, but I believe we need to use the template option, which is still a bit more complexā€¦

anyone with a quick fix, that doesnt iterate over all states|sensor ?

hi i try to make a card with a tap action. The tap action need a id that is in the attribute of the sensor.
{{state_attr("this.entity_id", "id")}}
how can i do this?
This code dont work - it works if i insert 1 instead of ā€˜{{state_attr(ā€œthis.entity_idā€, ā€œidā€)}}ā€™, but the id is different for every one of the sensores.

card:
  show_header_toggle: false
  title: Fryser
  type: entities
filter:
  include:
    - entity_id: sensor.*template_grocy_stk_*
      options:
        tap_action:
          action: call-service
          service: grocy.consume_product_from_stock
          service_data:
            product_id: '{{state_attr("this.entity_id", "id")}}'
            amount: 1
            transaction_type: CONSUME
  exclude:
    - state: unavailable
sort:
  method: state
  numeric: true
  reverse: true
type: custom:auto-entities

I do not think that product_id supports templates. Also, this.entity_id is not supposed to be used in quotes.

ok do you have any idea how i can do this with auto entities?

Use ā€œtemplateā€ option of the card.

i have tryed this and a lot more :slight_smile:

action: call-service
          service: grocy.consume_product_from_stock
          service_data:
            product_id:
              template: '{{state_attr("this.entity_id", "id")}}'
            amount: 1
            transaction_type: CONSUME

but this dont work. how would you do it?

Does the ā€œproduct_idā€ option has a ā€œtemplateā€ option?
I guess - NO.
Use only options accordingly to Docs.
Earlier I advised to use a ā€œtemplateā€ option of ā€œauto-entitiesā€ card. This option allows to specify lists by using jinjia.

maybe this is an option, but i dont know about jinjia. could you please help?

Is there a way to template options? Or anyone has any other idea?

Instead of changing my entity name, I only want to change the name, which is displayed.

image

So instead of ā€œabc Rssi Deviceā€ the rows should only display ā€œabcā€.

I thought about

      options:
        type: custom:multiple-entity-row
        secondary_info: last-changed
        show_state: false
        name: |
          {{ states('this.entity_id') }}
        entities:
          - entity: this.entity_id
            name: false

and then have some jinja2 instead of the states() above. This here was only for test purposes, if I can template, but this seems to be not the case?

Possible with auto-entities::template option.

Is there any documentation or example? Found only the filter template in docs.

Kind of this code
The template produces a list of records (entities + options).

Also, you may try (just a guess) with template-entity-row since you need to change names.

1 Like

One issue I am trying to solve is the issue with HA setting the last_changed value of all sensors on HA restart. I have a card that shows sensors that have changed in XX minutes and it works great EXCEPT after a server restart and all the sensors show back up. I would like to add an exclude filter like this:

{%- if as_timestamp(states('sensor.time_online')) < (as_timestamp(state.last_changed) - 60 ) -%}

Reason for the 60 is that the last_changed date does not match the time online exactly but they seem to always be within 60 seconds.
Since you can not use a template within the exclude, is there another way to accomplish this? Note I did just try make a filter template that does produce what I want but it seems to only update once or twice a minute which is a bit slow.

Aaah. No I thnik I understood it already better. I will template all this then including row-type, options. etc. Thought before, that I only template the entity list and everyting else apply as before if I would use include instead.

And after reading a lot of your posts in the past, I thing with that I will get the same sorting problems, etc. as you had before. So I will switch to template-entity-row in this usecase.

But some questions around another example from you above:

cards:
  - type: 'custom:auto-entities'
    card:
      type: entities
      title: Batteries
      style: |
        ha-card .card-content {
          padding-bottom: 0px !important;
        }
    entities:
      - type: button
        icon: 'mdi:blank'
        name: ' '
        action_name: Full list
        tap_action:
          action: navigate
          navigation_path: /lovelace/battery
    unique: entity
    show_empty: true
    filter:
      template: >
        {% set WARNING_LEVEL = states('input_number.battery_level_check')|float
        -%} {%- set batteries = expand('group.batteries') -%} {%- for battery in
        batteries -%}
          {%- set LEVEL = states(battery.entity_id)|float -%}
          {%- if LEVEL <= WARNING_LEVEL -%}
            {{
              { 'entity': battery.entity_id,
                'secondary_info': 'last-changed',
                'style': ':host { {%- if states(config.entity) == "unknown" -%}
                                  --paper-item-icon-color: brown;
                                  {%- elif states(config.entity)|float <= states("input_number.battery_level_critical") | float -%}
                                  --paper-item-icon-color: red;
                                  {%- elif states(config.entity)|float <= states("input_number.battery_level_warning") | float -%}
                                  --paper-item-icon-color: rgb(250,218,67);
                                  {%- else -%}
                                  --paper-item-icon-color: green;
                                  {%- endif %} }'
                } }},
            {%- endif -%}
        {%- endfor -%}
    sort:
      method: state
      reverse: false
      ignore_case: false
      attribute: null
      first: 0
      count: 1000
      numeric: true

There is still the sort part. Why?

Did you ever find a solution for this? I currently have the following card set up:

title: Docker
icon: mdi:docker
cards:
  - type: 'custom:vertical-stack-in-card'
    cards:
      - type: glance
        entities:
          - entity: sensor.docker_local_containers_total
            name: Containers
          - entity: sensor.docker_local_images
            name: Images
          - entity: sensor.docker_local_version
            name: Version
        title: Docker on NUC
      - type: custom:auto-entities
        card:
          type: entities
        entities:
          - type: section
            label: Not running
        filter:
          include:
            - entity_id: "sensor.docker_local_*"
              not:
                state: "running"
          exclude:
            - name: "Docker local *"
        show_empty: false
      - type: custom:auto-entities
        card:
          type: entities
        entities:
          - type: section
            label: High cpu usage
        filter:
          include:
            - entity_id: "sensor.docker_local_*"
              attributes:
                1cpu_percentage: ">= 5"
              options:
                type: custom:template-entity-row
                state: "{{ state_attr('this.entity_id', '1cpu_percentage') }} %"
        show_empty: false
        sort:
          method: attribute
          attribute: 1cpu_percentage
          reverse: true
      - type: custom:auto-entities
        card:
          type: entities
        entities:
          - type: section
            label: High memory usage
        filter:
          include:
            - entity_id: "sensor.docker_local_*"
              attributes:
                memory: ">= 1024"
              options:
                type: custom:template-entity-row
                state: "{{ state_attr('this.entity_id', 'memory') | int }} MB"
        show_empty: false
        sort:
          method: attribute
          attribute: memory
          reverse: true

This results in the following card:

I would like the empty sections to be hidden but show_empty: false doesnā€™t work, because the sections themselves make the cards not empty.

Not sure if this is the answer, but this is what I do:

          - type: custom:auto-entities
            show_empty: false
            card:
              type: entities
              title: Devices Down
              show_header_toggle: false