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

You can specify entity_ids: that cause an update with

style: |
  :host {
      ..etc..
  }
entity_ids:
  - input_boolean.my_thing

But thatā€™s a static list.
If not specified, itā€™s set to entity:.

Your problem is that plant-status is a Card, but the entities card expects Rows.
This can help.

yea, I feared as muchā€¦ I donā€™t want to list all that, there are way to many to listā€¦ and, it takes away the beauty of the auto-entities card. It would have to be something like this:

{{trigger.event.data.entity_id in state_attr('group.github_repo_updates','entity_id')}}

if any of these entity_idā€™s would change it would have to update the sensor listed in the card made by the auto-entities card.

If thatā€™s not possible, now, or in the future, it might be best off with this automation I already have, and ad an extra service to that, updating the sensor with the object_id of the triggering entity_id:

  - alias: 'GitHub boolean updates sensor'
    id: 'GitHub boolean updates sensor'
    trigger:
      platform: event
      event_type: state_changed
    condition:
      condition: template
      value_template: >
        {{trigger.event.data.entity_id in state_attr('group.github_repo_updates','entity_id')}}
    action:
      service: homeassistant.update_entity
      entity_id: sensor.github_repo_updates

add

  service: homeassistant.update_entity
  data_template:
    entity_id: >
     sensor.{{trigger.event.data.new_state.object_id}}

or

  service: homeassistant.update_entity
  data_template:
    entity_id: >
      {{'sensor.' + trigger.event.data.new_state.object_id}}

?
they both throw errors btw, but they do workā€¦, no they dont, it was because I switched views, from the log back to the view again, and it rerendered the auto-entitiesā€¦ canā€™t an automation trigger the re-rendering of that card? if must the view maybe?

never-mind, i found the solution. vera imported two duplicates.

hi everyone,

can you guys look at my code to help identify why i have duplicate entities?

cards:
  - cards:
      - color: var(--disabled-text-color)
        color_type: label-card
        name: Batteries
        template: button-card-headers
        type: 'custom:button-card'
      - card:
          column_width: 26%
          justify_content: left
          layout: horizontal
          min_columns: 4
          type: 'custom:layout-card'
        filter:
          include:
            - attributes:
                battery_level: < 90
              options:
                color: var(--disabled-text-color)
                color_type: label-card
                icon: |
                  [[[
                    var battery_level = states['this.entity_id'].attributes.battery_level;
                    var battery_round = parseInt(battery_level / 10) * 10;
                    if (battery_round >= 100) return 'mdi:battery';
                    else if (battery_round > 0) return 'mdi:battery-' + battery_round;
                    else return 'mdi:battery-alert';
                  ]]]
                label: |
                  [[[
                    var bri = states['this.entity_id'].attributes.friendly_name;
                    return bri  ;
                  ]]]
                layout: vertical
                name: |
                  [[[
                    var bri = states['this.entity_id'].attributes.battery_level;
                    return bri  + '%';
                  ]]]
                show_icon: true
                show_label: true
                styles:
                  card:
                    - background-color: var(--disabled-text-color)
                  icon:
                    - color: maroon
                  label:
                    - font-size: 10px
                  name:
                    - font-size: 12px
                type: 'custom:button-card'
        type: 'custom:auto-entities'
    type: vertical-stack
layout: horizontal
type: 'custom:layout-card'

Hi!

Iā€™m using this card, it works great!

I have my cameraā€™s motion sensors displaying when thereā€™s movement and I was wondering if there is a chance to set the tap-action for certain entities to, instead of showing the more info box of the motion sensor, show the actual camera.

Thanks!

since I am looking for a way to color the icons, based on a template in (card-mod) style, did you do so here? or are these colored by custom-ui in the backend.

My battery sensors will al be the default grey after updating to HA 110ā€¦ since the way custom-ui uses icon_color is no longer working from hat HA version.

Thomas, is it possible to use a template in the auto-entities that works for all entities in that card? I ask because since the earlier success here doesnt seem to work in this auto-entities card using:

  - type: custom:auto-entities
    card:
      title: Philips light level (lux) sensors
      type: entities
    filter:
      include:
        - entity_id: sensor.*_sensor_light_level_raw
          options:
            style: |
              :host {
                --paper-item-icon-color:
                 {% if states(config.entity)|float < 1 %} maroon
                 {% elif states(config.entity)|float < 300 %} firebrick
                 {% elif states(config.entity)|float < 10000 %} orange
                 {% elif states(config.entity)|float < 17000 %} green
                 {% elif states(config.entity)|float < 22000 %} gold
                 {% elif states(config.entity)|float < 25500 %} teal
                 {% elif states(config.entity)|float < 28500 %} dodgerblue
                 {% elif states(config.entity)|float < 33000 %} lightskyblue
                 {% elif states(config.entity)|float < 40000 %} lightblue
                 {% elif states(config.entity)|float < 40000 %} lightcyan
                 {% else %} azure
                 {% endif %}
                 ;
               }

or using the options for the style. I canā€™t get it to show the entities, let alone colored, using the style: . Without that, the listing is fine.

the bottom example here https://github.com/thomasloven/lovelace-card-mod/blob/1105f6f1c3f3d91a389f810c96826f0d816e1df5/src/example.yaml should be quite alike?
please have a look? thanks.

edit

overnight the cache seems to have healed allā€¦ This is suddenly showing correctly now. Sorry to bother.

gave me the opportunity to cleanup the template a bit:

  - type: custom:auto-entities
    card:
      title: Test auto coloring light level (lux) sensors
      type: entities
    filter:
      include:
        - entity_id: sensor.*_sensor_light_level_raw
          options:
            style: |
              :host {
                --paper-item-icon-color:
                 {% set level = states(config.entity)|float %}
                 {% if level == 0 %} black
                 {% elif level < 1 %} maroon
                 {% elif level < 300 %} firebrick
                 {% elif level < 10000 %} orange
                 {% elif level < 17000 %} green
                 {% elif level < 22000 %} gold
                 {% elif level < 25500 %} teal
                 {% elif level < 28500 %} dodgerblue
                 {% elif level < 33000 %} lightskyblue
                 {% elif level < 40000 %} lightblue
                 {% elif level < 40000 %} lightcyan
                 {% else %} azure
                 {% endif %}
                 ;
               }

too bad more-info isnā€™t set by this, but that would be a card-mod question. Iā€™ll hop over to that thread

This plugin is awesome!
Is it also possible to filter for a specific length?

I have a some list of fuel prices from nearby recognize with ocr only sometimes it miss the last part. So is it possible only show entinties with 2 decimals.

With a regex, perhaps?

state: /\d+\.\d{2,}/ (untested)

General: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
\d: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes
{2,}: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Quantifiers

First of all what a fantastic card!

Iā€™ve been using it to show my playing Sonos zones (which I use mini-media-player to interact with).

I posted over in that thread, but Iā€™m not sure if itā€™s mini-media-player or auto-entity causing a small issue.

Here is how Iā€™m using the card:

card:
  show_header_toggle: false
  title: Music Playing
  type: entities
filter:
  exclude:
    - state: paused
    - state: idle
    - state: unavailable
  include:
    - domain: media_player
show_empty: false
type: 'custom:auto-entities'

It works perfectly, but I decided I didnā€™t want the family messing with the zone in my office so I added one player, my office, in the exclude section

- entity_id: media_player.myoffice

Though it worked perfectly in not showing my playing zone, every 2-5 minutes the zone would pause all on itā€™s own. The log simply showed that the zone was paused, but no user associated with the pause, nor was there any automations or events or scenes that even referenced this player.

I went and deleted the exclude and I havenā€™t had a pause in 45 minutes. I add it back and it starts pausing again.

Not sure what would cause this? If anyone has ideas Iā€™d love to hear them. Iā€™ll keep testing to see if I can figure something out.

G

1 Like

Is there a way to use macroā€™s together with auto-entities? In the template I want to include different templates of the button-card, depending on the name of the entity.

THis is giving an ā€œunknown errorā€:

# lovelace_gen

{% macro button(entity) -%}
type: custom:button-card
template: 
  - default
  - light_circle
entity: entity
{%- endmacro %}

type: vertical-stack
cards:
  - !include
      - 'header.yaml'
      - content: {{title}}
  - type: horizontal-stack
    cards:
      - type: custom:button-card
        template: border_spacer
      - type: custom:auto-entities
        filter:
          include:
            - group: {{ group }}
              options:
                {{ button(this.entity_id) }}

        sort:
          method: name
          numeric: true
        card:
          type: custom:layout-card
          column_num: 3
          justify_content: start
          layout: horizontal
          column_width: 33%
      - type: custom:button-card
        template: border_spacer

  

Sorry. Iā€™ve read it over and over again, but I missed it. Thanks again ! :pleading_face:

1 Like

Hi there,

Fantastic system and I love it. One quick question: I have also integrated HA with a smartthings hub (for now) since some of my zwave are still on it. I have assigned each device to an area but when I use auto-entities it only brings the entities that are non-smartthings. for example I have a thermnostat and a lock in the same area but only the thermostat shows up and not the lock managed by smartthings. Here is the code I used:

card:
  show_header_toggle: true
  title: Entrance Hallway
  type: entities
filter:
  include:
    - area: Entrance Hallway
type: custom:auto-entities

any idea ?

Solved! for some reason auto-entities cards would also not show on iPhone App. I changed the resource statement from:

/hacs/lovelace-auto-entities/auto-entities.js

to

/local/community/lovelace-auto-entities/auto-entities.js

and it solved both problems

So following the instructions worksā€¦ who knew?

1 Like

Yep, some of us, even with well written documentation are still finding ways to mess it up :slight_smile:

2 Likes

I wanted a way to show Parcels in transit using the 17 track plugin,
however it has a limiting feature that it does not automatically add new parcels to Lovelace.
Thanks @thomasloven for this feature i have now got a plugin that displays all the parcels when added to 17track,
I then wanted to have the status reflected in the icon, i am not very good with templates and struggled to find a way to do that, so used multiple filters to show each status with a set icon,
let me know if there is a better way to do it , and the code here might help somebody else.

cards:
  - entities:
      - entity: sensor.seventeentrack_packages_in_transit
      - entity: sensor.seventeentrack_packages_not_found
      - entity: sensor.seventeentrack_packages_undelivered
      - entity: sensor.seventeentrack_packages_returned
    title: Shipping Overview
    type: entities
  - card:
      title: Packages
      type: entities
    filter:
      include:
        - entity_id: sensor.*track_package_*
          state: In Transit
          options:
            secondary_info: last-changed
            icon: 'mdi:truck'
        - entity_id: sensor.*track_package_*
          state: Not Found
          options:
            secondary_info: last-changed
            icon: 'mdi:alert-circle-outline'
        - entity_id: sensor.*track_package_*
          state: Returned
          options:
            secondary_info: last-changed
            icon: 'mdi:keyboard-return'
        - entity_id: sensor.*track_package_*
          state: Undelivered
          options:
            secondary_info: last-changed
            icon: 'mdi:alert-outline'
    type: 'custom:auto-entities'
type: vertical-stack
1 Like

Did you check out this previous post:

I saw this in the other topic, and meant to say that I think this is a beautiful solution.

(I didnā€™t say that there, because that topic was necro-d from more than a year ago IIRC, and thatā€™s generally discouragedā€¦)

What does the ā€œsecondary_infoā€ tag do? I see it above and see one reference in github but no descriptions or references to what it does. I tried like

filter:
  include:
    - entity_id: sensor.birthday.*
      options:
        secondary_info: years

Thinking it would list next to or under the entity name the age they will be but it doesnā€™t do anything or complain.

I do get something if I put in last-changed but not years so not sure how this works. For example, my entities contains years:

image

Also if I wanted the display for the state to show Today instead of 0 days when the value of the state is 0 could I do that somehow thru a style?