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

Hi there,
Iā€™m trying to use auto-entities,layout-card and the button card to show lights as buttons if they are on.

It works like a charm but I like to put a header over the buttons (e.g. markdown card). I set the parameter show_empty:false in auto-entities-card. If there are no lights on, the auto-entities-card is not shown. But how could I hide a the header?

Example:

- type: vertical-stack
  cards:
          - type: markdown
            content: '#### Eingeschaltete Lampen'
          - type: custom:auto-entities
            show_empty: false
            filter:
              include:
                - domain: light
                  state: "on"
                  options:
                     type: custom:button-card
                     entity_id: this.entity_id
            card:
              type: custom:layout-card
              layout: horizontal
              min_columns: 3

struggling with the exclude of an attribute to be unavailable, please help me how I should code it in the auto-entities config:

  - type: custom:auto-entities
    card:
      type: entities
      title: Multiple lights
      show_header_toggle: false
    filter:
      include:
        - domain: light
          options:
             type: custom:multiple-entity-row
             entity: this.entity_id
             toggle: true
             primary:
               entity: this.entity_id
               attribute: brightness
               name: Bri
               unit: '%'
             secondary:
               entity: this.entity_id
               attribute: color_temp
               name: Color
             tertiary:
               entity: this.entity_id
               attribute: rgb_color
               name: Rgb
             info:
               entity: this.entity_id
               name: Rgb
               attribute: rgb_color
      exclude:
        - attributes:
            color_temp: unavailable

everything works, up to the excludeā€¦ Shows all of my lights, with the 3 attributes.

Of course I will create two configs, 1 for color_temp and one for rob_color, but for now this is an exercise.

I can use the template filter to do this:

    {%- for light in states.light %}
      {%- if light.state == "on" and light.attributes.color_temp != unavailable %}
        {{ light.entity_id}},
      {%- endif %}
    {%- endfor %}

but because of the mentioned caveat (no auto reload) I donā€™t wat to use that.

Please have a look what I should do? thanks!

update

once you know what to look for, things get nice:

  - type: custom:auto-entities
    card:
      type: entities
      title: Multiple lights
      show_header_toggle: false
    filter:
      include:
        - domain: light
          state: 'on'
          attributes:
            rgb_color: '! none'
          options:
             type: custom:multiple-entity-row
             toggle: true
             secondary_info: last-changed
             primary:
               entity: this.entity_id
               attribute: brightness
               name: Bri
               unit: '%'
             secondary:
               entity: this.entity_id
               attribute: rgb_color
               name: Rgb

        - domain: light
          state: 'on'
          attributes:
            color_temp: '! none'
          options:
             type: custom:multiple-entity-row
             toggle: true
             secondary_info: last-changed
             primary:
               entity: this.entity_id
               attribute: brightness
               name: Bri
               unit: '%'
             secondary:
               entity: this.entity_id
               attribute: color_temp
               name: Color

thanks Thomas and @benct for creating 2 magical cards working together!

8 Likes

Hi! Is it possible to support expanding a light group in to the component entities? Liek you do with group, but with light group.

Thank you,

James

No. For all intents and purposes a light group is a light. There are no ways for the frontend to extract itā€™s constituents.

OK; thanks. Thatā€™s a shame. Currently have to specify the groups twice (as light groups to use them as lights and as group groups!) in order to tidy up my lovelace.yaml and use the group card.

building on my post above excluding the entities color_temp: ā€˜! noneā€™ I am now trying the opposite, and only show lights with color_temp: 'none', or automations with last_triggered: 'none' bit that fails completely.

Canā€™t we filter on a not set attribute?

Found a solution by myself. I wrap it in a conditional card. Only problem is that I need a group with all lights to handle the condition (auto-entities filters the same group than). Thatā€™s not the perfect way because new lights need to be added to the group but it works.

Is it possible to use Jinja2 templates in attributes filter?

something like this:

filter:
  include:
    - attributes:
      last_seen: "< {{(as_timestamp(now())-3600)}}"

or it is needed to use the template filter with the mentioned restriction?

Edit: And if the template filter is used is it possible to set the options for another card like include filter?

1 Like

One of the last updates to this card has stopped working correctly with geo_location entities that can come and go. I am getting the dreaded yellow bar error when an entity is no longer available instead of it just disappearing. When I refresh it disappears. This was always automatically handled but one of the latest updates has stopped.
image

1 Like

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

I finale found the way to do soā€¦:

  - type: custom:auto-entities
    card:
      type: entities
      title: Lights only brightness
      show_header_toggle: false
    filter:
      exclude:
        - domain: light
          attributes:
            rgb_color: '! none'
        - domain: light
          attributes:
            color_temp: '! none'
      include:
        - domain: light
          attributes:
            brightness: '! none' # filter browser_mod
          state: 'on'
          options:
             type: custom:multiple-entity-row
             toggle: true
             secondary_info: last-changed
             primary:
               entity: this.entity_id
               attribute: brightness
               name: Bri
               unit: '%'

what surprised me was I needed to declare the exclusions almost completely double, and could not ad both attributes under the same exclusion. anyways, this give me exactly what I hoped for, (next to the other auto-entities lights cards, explicitly Including the rgb_color and color_temp lights)
nice!

Turns out this is actually a problem with fold-entity-row, which is fixed in release 12.

1 Like

I have two questions. First, how can I specify a list to the name filter? For example, I would only like to only display entities that have friendly names of ā€œ550ā€, ā€œ231Nā€, ā€œ235ā€, ā€œ235Nā€ or ā€œ553Kā€.

Secondly, the documentation says that one can nest auto-entities. Iā€™m not exactly sure if that is the same thing that is done on multiple cards on the example image (for example, the card ā€œBasic filtersā€ has multiple sections with different auto-entities). I tried to replicate this, but did not get it working. If possible, could you post a example configuration of a card that has multiple section of different auto-entities.

Thank you as always, your work with these custom cards is phenomenal.

Easiest way is to add one filter for each name:

include:
  - name: "550"
  - name: "231N"
  - name: "235"
  ...

Of course, if thereā€™s a regularity to the names, you might be able to match them with a regular expression like:

include:
  - name: /[0-9]{3}[NK]?/

Nesting auto-entities means to put one auto-entities inside another, like

type: custom:auto-entities
  card:
    type: custom:auto-entities

As I say, it can be done, but I donā€™t see any reason to do it.

The cards in the picture uses section rows to divide different filtered parts, like in the 5th example in the readme on github.

1 Like

@thomasloven I am using this card. Config:

          - type: entities
            entities: 
              - type: custom:auto-entities
                card:
                  type: custom:fold-entity-row
                  head:
                    type: section
                    label: Current Incidents
                  open: true
                filter:
                  include:
                    - entity_id: "geo_location.nsw_fire_service_feed_*"
                    - entity_id: "geo_location.lightning_strike_*"
                  exclude:
                    - state: unknown
                show_empty: true
                sort:
                  method: state

Set to sort by state but this happens:

image

Obviously sorting alphabeticallyā€¦ is there any way to sort by the numeric value of the state?

Yes.

1 Like

Thanks. Missed that option. Cheers.

1 Like

Is it possible to change the name of an entity with auto-entities?

Like in type: entities

entity: sensor.rain
name: Rainsensor

This doesnā€™t work:

            - type: custom:auto-entities
              show_empty: false      
              card:
                type: entities
                show_header_toggle: false  
              filter:
                include:
                  - entity_id: sensor.rain
                    name: Rainsensor

options:

1 Like

Great, thanks.

Just one more question. One of my sensors reports seconds and it would be better to see the information in minutes. Is there a way to do that calculation directly in lovelace without adding a template sensor for each sensor that should transformed?

1 Like