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

in this particular case: do you need the browser_mod light entities in the first place? if not you can prevent the creation of them using

      disable:
        - light

in the browser_mod configuration

Hi,

is there a way of mapping filtered entities to cards instead of entities. For instance if youā€™d like to auto populate a horizontalt-stack?

type: custom:auto-entities
card:
   type: horizontal-stack
[....]

Hello everyone,

First of all, thanks for this cool feature! :blush:

I have many zones and want to know how long I have been in this zone for the intervals month, week and day. For this I have calculated the values with history stats.

I want to use auto-entities with multiple-entity row. The main reason I want to use auto-entities is the sorting function, which multiple-entity-row does not have.
Now instead of creating multiple cards in my lovelace dashboard for each of the time intervals I thought I could use multiple-entity row, but for my solution I need the following things:

  • Replace the name of the entity because the name of the sensor is ā€œStatistic Zone ZONENAME Monthā€ and I want to see only ZONENAME in the card.
  • Replace ID of entity for multiple entity line because I want to see the other intervalls of the zone statistics.

I have pseudo-coded my request below. I hope you understand what I mean and that my request is possible.

type: 'custom:auto-entities'
show_empty: false
card:
  type: entities
  title: Zones
filter:
  include:
    - entity_id: sensor.statistic_zone*_month
      options:
        type: 'custom:multiple-entity-row'
        name: {{ this.entity_name|replace("Statistic Zone ", "")|replace(" month", "") }}
        state_header: Month
        entities:
          - entity: {{ this.entity_id|replace("month", "day") }}
            name: Day
          - entity: {{ this.entity_id|replace("month", "week") }}
            name: Week
sort:
  method: state
  reverse: true
  numeric: true

The result should look something like this:

Can you please help me?

I cannot understand why I have duplicates in my auto-entities list in case of using card-mod.

Here is a small example:

  1. Without card-mod:
    Here we have a list of sensor.battery_* entities, and two of them are placed on the top of the list (i.e. ā€œstatic elementsā€):
type: 'custom:auto-entities'
card:
  type: entities
  title: example
entities:
  - type: section
    label: static elements
  - entity: sensor.battery_cleargrass_2
  - entity: sensor.battery_life360_papa
  - type: section
    label: auto elements
unique: true
show_empty: true
filter:
  include:
    - domain: sensor
      entity_id: sensor.battery_*
      options:
        secondary_info: last-changed
      sort:
        method: state
        reverse: false
        ignore_case: false
        attribute: null
        first: 0
        count: 1000
        numeric: true

  1. Now letā€™s apply style to the 1st static element:
type: 'custom:auto-entities'
card:
  type: entities
  title: example
entities:
  - type: section
    label: static elements
  - entity: sensor.battery_cleargrass_2
    style: |
      :host {
        color: red;
      }
  - entity: sensor.battery_life360_papa
  - type: section
    label: auto elements
unique: true
show_empty: true
filter:
  include:
    - domain: sensor
      entity_id: sensor.battery_*
      options:
        secondary_info: last-changed
      sort:
        method: state
        reverse: false
        ignore_case: false
        attribute: null
        first: 0
        count: 1000
        numeric: true

Great, the style works fine!
But now we have a duplicate:

Is it a bug?

Guys Iā€™d really appreciate some help. Iā€™m new to this so please excuse any stupidity on my part!

Iā€™m unable to get any card working with Auto-entities. Iā€™m running HassOS 4.16.

I followed instructions to download raw file to my config\www folder and have installed in resources tab.


I then try to add a card, either a manual card or using a pre-defined one but as soon as I add custom:auto-entities I get the following error.

If I try to add a resources section via the raw configuration editor Iā€™m given a message that this shouldnā€™t be here any longer and should be in the configuration panel.

Very confusing, any help appreciated.

Edit: Sorted - was issue in both Edge & Safari, windows & iOS but switching to chrome fixed it

In the previous release on GitHub it was noticed for ā€œtemplatesā€ that if a state of some processed entity changes then it will not affect the presence/absense of the entity in the list.
Now for the current release this note was excluded.
Does that mean that currently the ā€œtemplateā€ feature will reflect all entitiesā€™ changes?

I am using the layout-card with auto-entities as suggested and it is working mostly great. The one thing Iā€™m trying to do is get a title for the group of cards.
In the example below, I am showing buttons for all light groups that are ā€˜onā€™, Iā€™d like to have a title appear above all of the buttons that says ā€œTurn Offā€. Is that possible?

type: 'custom:auto-entities'
show_empty: false
card:
  type: 'custom:layout-card'
  title: Turn Off
  column_num: 2
filter:
  include:
    - entity_id: group.*lights*
      options:
        type: 'custom:button-card'
  exclude:
    - state: 'off'

look at device class

https://www.home-assistant.io/integrations/binary_sensor/

https://www.home-assistant.io/docs/configuration/customizing-devices/

Iā€™m trying to get 1 individual mini-graph for each CO2 sensor i have using auto-entities but receive error

this is my code

- type: custom:auto-entities
  show_empty: false
  card:
    type: grid
    columns: 2
    square: false
  card_param: cards              
  filter:
    include:
        - entity_id: sensor.*_co2
          options:
               type: custom:mini-graph-card
               hour24: true
               hours_to_show: 24
               font_size: 72
               show:
                  extrema: false
                  fill: true
                  labels: false      

Is it even possible and if so anyone knows whats wrong with the code ?
error i get in the card is ā€œCannot read property ā€˜lengthā€™ of undefinedā€

It does not appear formatted correctly.
Here is what I do for temperature; I donā€™t use a grid card, so I canā€™t say there.

type: vertical-stack
cards:
  - type: 'custom:auto-entities'
    sort:
      method: entity_id
      numeric: true
    card:
      type: 'custom:bar-card'
      severity:
        - color: '#800080'
          from: '-20'
          to: '10'
        - color: '#0000FF'
          from: '10'
          to: '40'
        - color: '#008080'
          from: '40'
          to: '67'
        - color: '#40bf40'
          from: '67'
          to: '74'
        - color: '#bf9540'
          from: '74'
          to: '85'
        - color: '#ff0000'
          from: '85'
          to: '120'
      min: '-20'
      max: '120'
      icon: ''
      decimal: 1
      show_header_toggle: false
      title: ''
    show_empty: false
    filter:
      include:
        - entity_id: '*temp*'
      exclude:
        - entity_id: '*govee*'
        - entity_id: '*fire*'
        - entity_id: '*trap*'
        - state: unavailable
  - type: 'custom:auto-entities'
    sort:
      method: entity_id
      numeric: true
    card:
      type: 'custom:mini-graph-card'
      unit: F
      name: Temperature (2 Weeks)
      icon: 'mdi:thermometer'
      show:
        fill: false
        legend: true
        labels: false
        name: true
        points: false
        name_adaptive_color: true
        icon_adaptive_color: true
        show_legend: false
      font_size: 75
      line_width: 3
      points_per_hour: 1
    hours_to_show: 336
    show_empty: false
    filter:
      include:
        - entity_id: '*temp*'
      exclude:
        - entity_id: '*trap*'
        - entity_id: '*govee*'
        - entity_id: '*fire*'
        - state: unavailable

Thanks for your example
My bad my simplified question was not well thought off, Infact I have a details page for each room will all sensors for that room. I want to show the environment sensors for each room dynamicly ā€¦ some room only have temperature, other have CO2 and humidity and others have even moreā€¦ I donā€™t want them in the same ā€œcustom:mini-graph-cardā€ as the units are diffrent per sensor. For all other elements on page i use the auto-entities successfullyā€¦ the pages themselves are generated by a sh script.

To support this i added a room attribute to all environment sensors. the detailed pages are generated by a .sh so i can mass update them easierā€¦

sorry if I missed it in the above, but can we sort on state, and within that, on last changed? or does the state filter already do that by default (doesnt seem that way tbh)

  - type: custom:auto-entities
    card:
      type: entities
      title: Bluetooth devices
    show_empty: false
    filter:
      include:
        - entity_id: device_tracker.*_bt
          sort:
            method: state

needs to sort the trackers by state on/off, and when change occurs, list that as the top tracker.
using this https://github.com/thomasloven/lovelace-auto-entities#sorting-entities but doesnā€™t sort on state at all right now, so I am somewhat confusedā€¦
editā€¦ sorry about that.

Look at above example: your sort is indented to far, it is not a sub of include it a sub of cards directly.

No, its indented ok now, and sorts on state alright. Only thing wanted is the last-changed ordering

Hello, I could need some help with this.

I try to toggle between to cards to either show battery level for all battery entities, and a card that only shows those with level below 25 %.

The auto-entities cards work fine as they are, as long as they not part of the state-switch card. But as sone as I make them a part of a state-switch card it returns an error says: No card type configured.

This is the card that gives the error:

      - type: vertical-stack
        cards:
        - type: entities
          entities:
            - entity: input_boolean.low_battery
          title: Battery level
          show_header_toggle: false
        - type: 'custom:state-switch'
          entity: input_boolean.low_battery
          states:
            "on":
              - type: 'custom:auto-entities'
                card:
                  type: entities
                filter:
                  include:
                    - entity_id: "*battery*"
                      state: "< 25"
                sort:
                  method: state
            "off":
              - type: 'custom:auto-entities'
                card:
                  type: entities
                filter:
                  include:
                    - entity_id: "*battery*"
                sort:
                  method: state

This is the code iā€™m trying using a grid

- type: custom:auto-entities

                     show_empty: false

                     card:

                          type: grid

                          columns: 2

                          square: false

                     card_param: cards                  

                     filter:

                          include:

                              - entity_id: sensor.livingroom_co2

                                options:

                                    type: custom:mini-graph-card

                                    hour24: true

                                    hours_to_show: 24

                                    font_size: 72

                                    show:

                                      extrema: false

                                      fill: true

                                      labels: false

This is the error i get
image

I made the same mistake.
You need to exclude >25.
Example below that I use:

type: 'custom:auto-entities'
sort:
  method: state
  numeric: true
card:
  type: 'custom:bar-card'
  severity:
    - color: '#bf4040'
      from: 0
      to: 30
    - color: '#bf9540'
      from: 30.1
      to: 70
    - color: '#40bf40'
      from: 70.1
      to: 100
  show_header_toggle: false
  title: Batteries to Replace/Charge Now
filter:
  include:
    - entity_id: '*battery_level*'
  exclude:
    - state: '>30.1'
    - name: '*State*'
    - name: '*Health*'

another:

type: 'custom:auto-entities'
sort:
  method: state
  numeric: true
card:
  type: 'custom:bar-card'
  severity:
    - color: '#bf4040'
      from: 0
      to: 30
    - color: '#bf9540'
      from: 30.1
      to: 70
    - color: '#40bf40'
      from: 70.1
      to: 100
  show_header_toggle: false
  title: Batteries to Watch
unique: true
filter:
  include:
    - entity_id: '*battery_level*'
  exclude:
    - state: '>70'
    - state: <30.1
    - state: unavailable
    - name: '*State*'
    - name: '*Health*'

and another:

type: 'custom:auto-entities'
sort:
  method: state
  numeric: true
card:
  type: 'custom:bar-card'
  severity:
    - color: '#bf4040'
      from: 0
      to: 30
    - color: '#bf9540'
      from: 30.1
      to: 70
    - color: '#40bf40'
      from: 70.1
      to: 100
  show_header_toggle: false
  title: Batteries in Good Shape
filter:
  include:
    - entity_id: '*battery*'
  exclude:
    - state: <70.1
    - state: unavailable
    - name: '*State*'
    - name: '*Health*'
    - state: unknown

Sorry, but it did not make much difference using exclude ā€œ>25ā€ instead of using include ā€œ<25ā€.

From my point of view, it looks like the problem comes when I use the combination of the ā€œauto-entitiesā€ and the ā€œstate-switchā€ cards.

Using auto-entities together with the standard ā€œconditionā€ card works ok. I will use that one instead.

Hello sylviepipi,

mini-graph-card needs entities. auto-entities (with card_param: cards) creates an entitiy.

Here is a workaround:

...
filter:
  include:
    - entity_id: "*device_temp"
      options:
        type: custom:mini-graph-card
        entity:
        entities:
          - this.entity_id
...
4 Likes

Thanks Minzel for the example, works like a charm