🔹 Auto-entities - Automatically fill cards with entities

What auto-entities does is it takes any lovelace card, and populates the entities parameter of it.

Eg:

type: custom:auto-entities
filter:
  include:
    - domain: light
card:
  type: entities
  title: My lights

will turn into

type: entities
title: My lights
entities:
  - entity: light.all
  - entity: light.your
  - entity: light.lights

And the options are added to each entity that matches that filter, such that:

type: custom:auto-entities
filter:
  include:
    - domain: light
      options:
        icon: mdi:gear
card:
  type: entities
  title: My lights

is turned into

type: entities
title: My lights
entities:
  - entity: light.all
    icon: mdi:gear
  - entity: light.your
    icon: mdi:gear
  - entity: light.lights
    icon: mdi:gear
1 Like

hey,
loving the card, just created a great little card to show me “alerts” including anythnig that is “open” (doors/windows), lights that are “on”, rooms with high/low temps, ink that is low on the printer, batteries below 20% etc…
its a very useful snapshot!

I had a question around groups.

i have a group that contains some specific plugs (TP Link ones).
is it possible to have a card that displays the entries from a group, which are on?
so it needs to explode out all the values in the group, then do thee filter

sorry, had a look and a good play but couldnt work it out.

type: 'custom:auto-entities'
card:
  type: glance
filter:
  include:
    - domain: group
      name: "*all_tp_link_plugs*"

sorry, another question, any way to do “group by” option?

eg. show me all the lights in my house, but rather then “sort” you could do a “group by” on the “area” they are in?

making it easier to see all the “kitchen” lights together, then the “living room” lights together etc…

ive thrown this together but not very dynamic if you add new areas?

type: 'custom:auto-entities'
card:
  type: entities
  title: House Lights
filter:
  include:
    - label: Jamie Office Lights
      type: section
    - domain: light
      area: Jamie Office
    - label: Bedroom Lights
      type: section
    - domain: light
      area: Bedroom
    - label: Kitchen Lights
      type: section
    - domain: light
      area: Kitchen
    - label: Bar Lights
      type: section
    - domain: light
      area: Bar
    - label: Garden Lights
      type: section
    - domain: light
      area: Garden Front
    - domain: light
      area: Garden Rear
    - label: Hallway Lights
      type: section
    - domain: light
      area: Hallway Downstairs
    - domain: light
      area: Hallway Upstairs
    - label: Downstairs Toilet Lights
      type: section
    - domain: light
      area: Downstairs Toilet
    - label: Ensuite Lights
      type: section
    - domain: light
      area: Ensuite
    - label: Gym Lights
      type: section
    - domain: light
      area: Gym
    - label: Porch Lights
      type: section
    - domain: light
      area: Porch
    - label: Workshop Lights
      type: section
    - domain: light
      area: Workshop

How often do you add new rooms to your house?

1 Like

Yeah, fair point

hey @thomasloven - ive added a few different auto-entities cards to my lovelace and im curious about any kind of performance issues, im getting pretty bad page load times, so i wondered if there is a way to debug somehow and work out if one of the cards is causing this maybe?

1 Like

Love this card and use it for many different things!

I would like to view all devices that have a certain unit_of_measurement-value, for example every entity that have

unit_of_measurement: lx

or

unit_of_measurement: °C

Is this possible? How?

You can do it like this, which selects anything that has a unit_of_measurement equal to °C

      - card:
          show_header_toggle: false
          title: All Temperature Sensors
          type: entities
        filter:
          include:
            - attributes:
                unit_of_measurement: '°C'
        sort:
          method: state
          numeric: true
          reverse: true
        type: 'custom:auto-entities'

Alternately, if your sensors have a device_class attribute, you can select them based on their value such as temperature or illuminance

      - card:
          show_header_toggle: false
          title: All Light Sensors
          type: entities
        filter:
          include:
            - attributes:
                device_class: 'illuminance'
        sort:
          method: state
          numeric: true
          reverse: true
        type: 'custom:auto-entities'
1 Like

Excellent! Thank you!

I don’t see this in HACS, but if I try to add the repo manually, it says it’s already in the store. What am I doing wrong?

It is in HACS. Use search to find it

Hi All,

Im trying to add auto-entities into a combines list.
I don’t get errors. But it won’t show me the output. Tried many things but I can’t get it work.
Can someone help me?

cards:
  - entities:
      - input_select.system_other_state_select_switch
    show_header_toggle: false
    title: System Modules
    type: entities
  - default: Device Trackers
    entity: input_select.system_other_state_select_switch
    states:
      AdGuard:
        entities:
          - sensor.adguard_average_processing_speed
          - sensor.adguard_dns_queries
          - sensor.adguard_dns_queries_blocked_ratio
          - switch.adguard_filtering
          - switch.adguard_parental_control
          - sensor.adguard_parental_control_blocked
          - switch.adguard_protection
          - switch.adguard_safe_browsing
          - sensor.adguard_safe_browsing_blocked
          - switch.adguard_safe_search
          - sensor.adguard_safe_searches_enforced
        show_header_toggle: false
        type: entities




      Asus WRT:
        type: "custom:auto-entities"
        card:
          title: Asus WRT Devices
          type: entities
          filter:
            exclude:
              - entity_id: '*geofency*'
              - entity_id: device_tracker.1717fe36_3c70_4599_963c_b70b6ee95eba
              - entity_id: device_tracker.e7b5aad4_fc4c_4ee8_98fd_2337da788a0f
              - entity_id: device_tracker.peter_iphone
            include:
              - domain: device_tracker
            sort:
              method: name




      Device Trackers:
        cards:
          - entities:
              - binary_sensor.sensor_manual_family_home
            show_header_toggle: false
            type: entities
          - entities:
              - binary_sensor.manual_kay_home
              - device_tracker.kay_iphone_geofency
              - device_tracker.e7b5aad4_fc4c_4ee8_98fd_2337da788a0f
            show_header_toggle: false
            type: entities
          - entities:
              - binary_sensor.manual_peter_home
              - device_tracker.peter_iphone_geofency
              - device_tracker.1717fe36_3c70_4599_963c_b70b6ee95eba
            show_header_toggle: false
            type: entities
        type: vertical-stack
      External IP:
        entities:
          - sensor.external_ip
          - sensor.local_ip
          - sensor.dsmr_ext_ip
          - sensor.ssl_certificate_expiry
          - binary_sensor.imac_peter
        show_header_toggle: false
        type: entities
      Google Drive Snapshots:
        entities:
          - binary_sensor.snapshots_stale
          - sensor.snapshot_backup
        show_header_toggle: false
        type: entities
      HP Printer:
        entities:
          - sensor.hp_printer_ink_black
          - sensor.hp_printer_ink_cyan
          - sensor.hp_printer_ink_magenta
          - sensor.hp_printer_ink_yellow
          - sensor.hp_printer_printer
          - sensor.hp_printer_scanner
          - sensor.hp_printer_status
          - binary_sensor.hp_printer_status
        show_header_toggle: false
        type: entities
      Home Assistant Update:
        entities:
          - binary_sensor.update_available
          - sensor.latest_version
          - sensor.current_version
          - sensor.hacs
          - sensor.ssl_certificate_expiry
        show_header_toggle: false
        type: entities
      ITHO:
        cards:
          - entities:
              - sensor.itho_speed
              - sensor.itho_tijd
            show_header_toggle: false
            type: entities
          - customTheme: false
            entity: fan.afzuiging_badkamer
            name: MBR Fan Not Custom
            type: 'custom:fan-control-entity-row'
        type: vertical-stack
      Milight Hub:
        entities:
          - binary_sensor.milight_hub
          - sensor.milight_free_heap
          - sensor.milight_arduino_version
          - sensor.milight_reset_reason
          - sensor.milight_version
          - sensor.milight_variant
          - sensor.milight_dropped_packets
          - sensor.milight_length
        show_header_toggle: false
        type: entities
      RDW Toyota:
        entities:
          - binary_sensor.toyota_aygo_insured
          - sensor.toyota_aygo_expdate
          - sensor.toyota_aygo_recall
        show_header_toggle: false
        type: entities
      Speedtest:
        entities:
          - entity: sensor.speedtest_ping
          - entity: sensor.speedtest_download
          - entity: sensor.speedtest_upload
        show_header_toggle: false
        type: entities
    transition: slide-left
    transition_time: 5
    type: 'custom:state-switch'
type: vertical-stack

When I try this:

      Asus WRT:
        cards:
          - type: entities
            entities:
              - sensor.adguard_average_processing_speed
            show_header_toggle: false
          
          - type: 'custom:auto-entities'
            card:
              title: Asus WRT Devices
              type: entities
              filter:
                exclude:
                  - entity_id: '*geofency*'
                  - entity_id: device_tracker.1717fe36_3c70_4599_963c_b70b6ee95eba
                  - entity_id: device_tracker.e7b5aad4_fc4c_4ee8_98fd_2337da788a0f
                  - entity_id: device_tracker.peter_iphone
                include:
                  - domain: device_tracker
                sort:
                  method: name
        type: vertical-stack

I only see the Adguard entity. The rest is not showing

Due to, I believe, incorrect indentation.

Starting with the line containing filter to the line with method, shift them all to the left by two spaces.

1 Like

I found it. I’m ignorant.

thanks… that did the trick!

Nah… they can be sorted in HACS in a non intuitive order and some have lovelace in the name unexpectedly. Search always makes it easier.

is it possible to also list the entities found in one or more indirect referenced group(s)- in this case listing the entities found in the ‘manual_windows’ group.
(I reference the ‘group.alarm_zones_night’ in the lovelace section. which in turn has a reference to another group.) group in groups :slight_smile:

I could not find a way of doing this.
I guess it requires some recursive coding here :slight_smile:

examples is as follows.

lovelace:

- type: custom:auto-entities        
        card:
            title: Alarm zoner for NIGHT
            type: entities
            show_header_toggle: false
        show_empty: false
        filter:
          include:
            - group: group.alarm_zones_night
          exclude:
            - state: "off"
            - state: "unavailable"

------------------ groups.yaml example ---------------------

manual_windows:  
  entities:
    - binary_sensor.bedroom_window_sensor_on_off    
    - binary_sensor.livingroom_window_sensor_on_off

    
alarm_zones_night:
  name: Alarm zoner for natten
  entities:
    - binary_sensor.door_sensor_hall_on_off
    - binary_sensor.livingroom_garden_door_sensor_on_off        
    - binary_sensor.door_sensor_scullery_on_off
    - group.manual_windows´

I am trying to create a custom:auto-entities card to show all zigbee2mqtt devices, that are currently not connected to the network and/or don’t report.

This is my attempt

- type: "custom:auto-entities"
  show_empty: false
  sort:
    method: name
  card:
    type: entities
    title: "Nicht Verfügbar"
  filter:
    # exclude: [{}]
    include:
      - entity_id: "climate.*"
        attributes:
          state: "unknown"
      - entity_id: "binary_sensor.*_tuer_contact"
        attributes:
          state: "unavailable"
      - entity_id: "binary_sensor.*_fenster*"
        attributes:
          state: "unavailable"

I thought this would report either

  • climate entities that state is equal to unknown
  • door sensors (anything that contains “_tuer_contact”, as I named all zigbee reed sensors like this on purpose) that states are equal to “unavailable”
  • window sensors (“fenster”) that states are equal to “unavailable”

However, this does not work, as it will not display the card at all. When I comment out the

# attributes:
#    state: "unknown"

part (plus equivalents), it will show the card, but, of course, show all those entities, not just the once that are having some sort of issue.

Would somebody please tell me how I need to modify my code in order to only display climate.* entities with a state value of unknown? If I get that right, I can adapt the other entities from there.

Thank you for your help :slight_smile:

Please give me some suggestions.

In my config there are sensors for battery_level & battery_charging for EVERY DEVICE:

binary_sensor:
  - platform: template
    sensors:
      battery_charging_life360_mama:
        friendly_name: 'battery_charging: life360_mama'
        icon_template: ''
        value_template: "{% .... %}"
        device_class: battery_charging

sensor:
  - platform: template
    sensors:
      battery_life360_mama:
        friendly_name: 'battery: life360_mama'
        unit_of_measurement: '%'
        icon_template: ''
        value_template: "{{ ... }}"
        device_class: battery

These properties are registered as sensors to provide automatically changing icons which is provided by “device_class”:

  • icon for battery_level - depending on level;
  • icon for battery_charging - depending on “charging / not charging”.

There is no problems with listing all battery_level or battery_charging by auto-entities-card:

type: 'custom:auto-entities'
card:
  type: entities
  title: Battery state
unique: false
show_empty: true
filter:
  include:
    - entity_id: sensor.battery*
      options:
        secondary_info: last-changed
      sort:
        method: name
        reverse: 'false'
        ignore_case: false
        attribute: null
        first: 0
        count: 100
        numeric: false

type: 'custom:auto-entities'
card:
  type: entities
  title: Battery state
  state_color: true
unique: false
show_empty: true
filter:
  include:
    - entity_id: '*sensor.battery_charging*'
      sort:
        method: name
        reverse: 'false'
        ignore_case: false
        attribute: null
        first: 0
        count: 100
        numeric: false
      options:
        secondary_info: last-changed

But now I would be happy to have both battery_level & battery_charging on ONE card with multiple-entity-card.
Without auto-entities-card it works fine - see below for ONE device:

type: entities
state_color: true
entities:
  - type: 'custom:multiple-entity-row'
    entity: binary_sensor.battery_charging_life360_mama
    entities:
      - entity: sensor.battery_life360_mama
        name: level
        unit: ''
      - entity: sensor.battery_life360_mama
        name: false
        icon: true
        unit: ''
    name: Battery state
    unit: ''
    icon: ''
    toggle: false
    show_state: false
    state_header: ''
    state_color: true

1

But I wonder how to use auto-entities-card for this since these sensors must be automatically selected in loop.
Below there is my first try:

type: 'custom:auto-entities'
entities:
  - type: section
    label: 1st sample row
card:
  type: entities
  title: Some title
unique: false
show_empty: true
filter:
  include:
    - entity_id: binary_sensor.battery*
      options:
        type: 'custom:multiple-entity-row'
        entities:
          - entity: sensor.battery_life360_mama
            name: level
            unit: ''
          - entity: sensor.battery_life360_mama
            icon: true
            name: false
            unit: ''
        unit: ''
        icon: ''
        toggle: false
        show_state: false
        state_header: ''
        state_color: true
        secondary_info: last-changed
      sort:
        method: name
        reverse: 'false'
        ignore_case: false
        attribute: null
        first: 0
        count: 100
        numeric: false

Look - here there is a battery_level for ONE SAME sensor.
I do not know how to show a corresponding sensor inside a loop.

Of course I can use battery_level & battery_charging as attributes of some entity like it was discussed above (🔹 Auto-entities - Automatically fill cards with entities).
But I would be happy to use these data as SENSORS because of automatically changing icons (“device_class”).

Is it possible to implement this?

Update:
Now I see one simple way:

  • keep battery_level as a sensor with “device_class: battery”;
  • use battery_charging as an attribute of battery_level sensor.
    But in this case there is no way to change an icon of battery_charging automatically (at least without config-template-card).

Update 2:
Seems no way I can use config-template-card.
The “this.entity_id” variable cannot be used inside template “${ …}” with “states[…]” expressions.
So sad.

Got one more question.
Here is a code:

type: entities
entities:
  - sensor.asuswrt_download
  - sensor.asuswrt_upload
  - type: 'custom:auto-entities'
    card:
      type: entities
    unique: false
    show_empty: true
    filter:
      include:
        - entity_id: sensor.asus*
          sort:
            method: name
            reverse: false
            ignore_case: false
            attribute: null
            first: 0
            count: 100
            numeric: false
  - sensor.asuswrt_download
  - sensor.asuswrt_upload

Here we have “auto-entities” INSIDE “entities card”.
Look at the pic:
изображение

Entities’ names and states which are auto-enumerated are shifted from the left & right margins.
This happens if auto-entities is used inside entities card.

Compare with another case:

type: 'custom:auto-entities'
card:
  type: entities
unique: false
show_empty: true
filter:
  include:
    - entity_id: sensor.asus*
      sort:
        method: name
        reverse: false
        ignore_case: false
        attribute: null
        first: 0
        count: 100
        numeric: false

изображение

Is that shift a normal behaviour?