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

I agree that this would be a nice new feature, but since the addon is someoneā€™s side project, I donā€™t expect it to be released soon. So if you are in need of a solution you should pick any workaround with the least friction. Which workaround that is, is a personal preference.

1 Like

I tested my assumption: I was right. Having

  • group containing
  • other groups
  • which contain entities

and using the root group as include filter (group: binary_sensor.root_group) will only list the root groupsā€™ entities - which are the other groups. Not getting the grandchildren that way. So that workaround is a dead end.

Iā€™ve got around 20 Ring security sensors and they each have 4-5 entities each:

  • state
  • tamper status,
  • battery level,
  • ā€œinfoā€,
  • bypass mode.

Iā€™m to use auto-entities to do a device filter for *Ring*Sensor* and get all the entitiesā€¦ but Iā€™m getting 80-100 individual entities which is a bit intense.

Is there a way to use this Lovelace plugin to fetch all Ring sensor entities AND group entities from the same device into one row/item? Maybe using multiple-entitity-row?

I can understand @e-raser s thought on it belonging to the functionality already, given Thomasā€™ own documentation on GitHub - thomasloven/lovelace-auto-entities: šŸ”¹Automatically populate the entities-list of lovelace cards

Any filter option can use * as a wildcard for string comparison

Given that, I suppose an Issue on the repo is in order, maybe Thomas can explain, or fix.

on expanding the nested groups: FR: Add expand on nested groups (lights, switches etc) Ā· Issue #268 Ā· thomasloven/lovelace-auto-entities Ā· GitHub

1 Like

@luisleonardo.pt Could you share your code? Iā€™m interested in doing the same thing?

As a side note, I found the interface choking on entering direct YAML for my card (specifically on the regex).

I wrote the code up in a separate editor, copy-pasta-ed into the field and saved it. The same exact thing that I keyed into the interface and did not work, now works without a problem.

Auto-entities card displaying battery status:


type: custom:auto-entities
card:
  type: entities
  title: Button cell battery status
filter:
  include:
    - name: /.*?[Ss](ensor|witch)\d.*?([Pp]ower|[Bb]attery)/
sort:
  method: state
  reverse: false
  numeric: true
show_empty: true

Does anybody know of a way to simply create a vertical list of areas with any of the stock cards?

image

The left most column should simply list the areas nameā€™s rather than the full sensor name (here just as place holder a glance card).

type: horizontal-stack
cards:
  - type: custom:auto-entities
    card:
      type: glance
      show_state: false
      show_icon: false
      columns: 1
    filter:
      include:
        - entity_id: sensor.eq3_temp*
      exclude: []
  - type: custom:auto-entities
    card:
      type: glance
      show_name: false
      show_icon: false
      columns: 1
    filter:
      include:
        - entity_id: sensor.eq3_temperature*
      exclude: []
  - type: custom:auto-entities
    card:
      type: glance
      show_name: false
      show_icon: false
      columns: 1
    filter:
      include:
        - entity_id: sensor.xiaomi_temperature*
      exclude: []
  - type: custom:auto-entities
    card:
      type: glance
      show_name: false
      show_icon: false
      columns: 1
    filter:
      include:
        - entity_id: sensor.xiaomi_humidity*
      exclude: []

Meanwhile I found it !
For people looking for an example of mushroom integration, he is mine :

type: vertical-stack
cards:
  - type: custom:mushroom-title-card
    subtitle: Batteries
  - type: custom:auto-entities
    sort:
      method: state
      numeric: true
    card:
      type: entities
    filter:
      include:
        - entity_id: '*battery_level*'
        - attributes:
            device_class: battery
            state_class: measurement
          options:
            type: custom:mushroom-template-card
            primary: '{{ states[''this.entity_id''].attributes.friendly_name }}'
            secondary: '{{ states[''this.entity_id''].state }}%'
            icon: >-
              {% set battery_level = states['this.entity_id'].state |float(0) %}
              {% set battery_round = (battery_level / 10) | int(0) * 10 %} {% if
              (battery_round >= 100) %}
                {{ 'mdi:battery' }}
              {% else %}
                {% if (battery_round > 0) %}
                  {{'mdi:battery-' ~ battery_round}}
                {% else %}
                  {{ 'mdi:battery-alert' }}
                {% endif %}
              {% endif %}
            icon_color: >-
              {% set battery_level = states['this.entity_id'].state |int(0) %}
              {% set battery_round = (battery_level / 10) | int(0) * 10 %} {% if
              (battery_level >= 50) %}
                {{ 'green' }}
              {% else %}
                {% if (battery_level > states('input_number.number_batterij_drempel') |int(0)) %}
                  {{'orange'}}
                {% else %}
                  {{ 'red' }}
                {% endif %}
              {% endif %}
            tap_action:
              action: none
            double_tap_action:
              action: none
      exclude:
        - attributes:
            friendly_name: '* Battery Level'
      sort:
        method: state
        numeric: true

2 Likes

why use the icon template? youā€™ve selected the device_class: battery, which does that for you
or doesnt the mushroom card show the core device_class? (asking since I dont use the Mushroom cards)

If you donā€™t specify an icon in a mushroom template card, none will be displayed

I see, thatā€™s not good :wink:

though I believe custom:card-button doesnt follow device_class either. pity really.

Did you figure out a way to hide hidden entities? As far as my research goes, there is still no template option (Access hidden entity status from template? - #5 by giorgos).

My workaround so far: I created a group with the hidden elements and excluded this within the auto-entities card.

No, I havenā€™t done anything with hidden entities - do not have them.
Your solution with a group seems to be OK. If the group may be created automatically - then it would be great.
Is there any way to determine the ā€œhiddenā€ flag in templates?

Is it possible to use auto-entities with Mushroom Chips cards? The mushroom chip card expects a single entity parameter rather than a list of entities. Auto entities would have to create a separate card for each entity in the list.

Looking for some help - I want a card to show if any devices are playing plex. This is what I have so far.
Things I am looking to add. Sort in order by device name, test implementing with mini media player, Title of movie/show playing. Or looking for what others are doing for this.

type: custom:auto-entities
card:
 type: entities
filter:
 include:
  - entity_id: media_player.plex_*
   state: /playing|paused|'on'/

Canā€™t help with the rest, not using media_player, but there is a sort option for auto-entities.
options - sort:

@all:
Can anybody think of a way of checking how many entities are being auto created by auto-entities? I would like to make some cards conditional on the amount of entities to be displayed.
Auto-entities does seem to have an internal counter that can be used for count: but I cannot see how to access it in Javascript.

I have problems wrapping my head around this simple task. Instead of displaying ā€œstateā€ in the Glance-card, I want to display the ā€œshow_last_changedā€ or ā€œlast-changedā€ (custom:auto-entities) for all entities showing up in the card.
Any ideas?

type: custom:auto-entities
show_empty: false
sort:
  method: name
card:
  type: glance
  show_state: false
filter:
  include:
    - entity_id: binary_sensor.window_sensor*_access_control
      state: 'on'
    - entity_id: light.dimmer_*
      state: 'on'
#      options:
#        secondary_info: last-changed ???
    - entity_id: binary_sensor.smoke_detector*_smoke_alarm_smoke_detected
      state: 'on'
    - entity_id: binary_sensor.flood_sensor*_water_alarm_water_leak_detected
      state: 'on'

If filterering is done by using a ā€œtemplateā€ option, then a count of filtered items may be calculated.

  1. Remove ā€œshow_state: falseā€ - it prevents displaying ā€œlast-changedā€.
  2. If you need a ā€œlast-changedā€ displayed for every item (not only ā€œlightā€) then the ā€œoptionsā€ must be specified for each item.
  3. Use ā€œshow_last_changed: trueā€ instead of what you wrote (it is unsupported).
1 Like

Filtering is done using include/exclude.