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

Hmmm, works with history-graph but not yet with ApexCharts. Still seem to have something wrong

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  include:
    - entity_id: sensor.eq_3_temperature*
      options:
        type: custom:apexcharts-card
        series:
          - entity: this.entity_id

Gives error: /// apexcharts-card version 1.10.1-dev.1 /// value.entity is extraneous
But series needs to be specified, otherwise error that series is missing.

The generated card is:
image
What you can do is:

  • either open an issue for auto-entities - ā€œgenerated card includes extraneous lineā€;
  • or open an issue for apexcharts-card - ā€œallow extraneous optionsā€

Update:

Unfortunately, auto-entities still gives unstable results with map.
Sometimes this card does not show a map:

type: vertical-stack
cards:
  - type: entity
    entity: sun.sun
  - type: custom:auto-entities
    card:
      type: map
    show_empty: false
    filter:
      include:
        - entity_id: device_tracker.life360*
          options:
            default_zoom: 14

When it does:

I used to have a auto-entities card with the types of waste that are going to be picked up (GitHub - pippyn/Home-Assistant-Sensor-Afvalbeheer: Provides Home Assistant sensors for multiple Dutch and Belgium waste collectors). It worked great until two days ago. I have an empty card with only the title.
I donā€™t know if it was the update to HA 2021.12 or just after that. The individual sensors are working if I look them up. I did not make any changes to the card. Does anyone have an idea what goes wrong?

type: custom:auto-entities
card:
  show_header_toggle: false
  type: entities
  title: Afvalkalender
filter:
  include:
    - attributes:
        Days-until: < 14
      options:
        secondary_info: Nog [[ {entity}.attributes.Days-until ]] dag(en)
        type: custom:secondaryinfo-entity-row
      entity_id: sensor.meerlanden*
  show_empty: false
sort:
  method: attribute
  attribute: Days-until
  numeric: true

Hi, how can i hide entities with some state (where are unavailable) ?
exp.

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*sensor.washmaschine*'
      not:
        state: '*unavailable*'
  exclude: []

put the filter under exclude not include since your goal is to EXCLUDE unavailable entities. Itā€™s explained in the ReadMe in Github pretty well. Did you bother to check there? Like this example there:

type: custom:auto-entities
show_empty: false
card:
  type: entities
  title: Lights on
  show_header_toggle: false
filter:
  include:
    - domain: light
  exclude:
    - state: "off"
    - state: "unavailable"
1 Like

Thank you, I tried the examples in the first place only in a stupid way I tried to filter out the unavailable state in Polish instead of English and it didnā€™t work.

type: custom:auto-entities
card:
  type: entities
filter:
  include:
    - entity_id: '*sensor.pralka*'
  exclude:
    - state: "off"
    - state: "niedostępny"

works very well in English :slight_smile:

Surely since Polish values are only for UI, internally the state is ā€œunavailableā€.

1 Like

Solved: the attribute Days-until has been altered to Days_until apparently. Changed that in the code and itā€™s working again :slight_smile:

1 Like

Now that HA provides a button to trigger the OTA update for Shelly devices I thought is was time to add a card to my maintenance dashboard that shows me what device have an update pending.

image

type: custom:auto-entities
card:
  type: entities
  title: Shelly OTA Updates
filter:
  template: |
    {% for sensor in states.binary_sensor -%}
      {% if 'firmware_update' in sensor.entity_id and sensor.state == 'on' %}
        {{ sensor.entity_id | regex_replace('^binary_sensor.([a-z0-9_]+)_firmware_update$','button.\\1_ota_update') }}, 
      {% endif %}
    {%- endfor %}

To get this to work make sure you are on HA 2021.12, use the official Shelly integration and have the firmware sensor of your Shelly devices enabled.

@thomasloven tnx for this great card

2 Likes

Hi hope someone can help me with this.
I would like a card for birthdays. So far so good.

The problem is, I need 2 filters because of different attributes I want to show in the card and for one filter 1 need 2 states: > 0 and < 20.
But I donā€™t get that to work.

Here is the code:

type: custom:auto-entities
card:
  type: entities
  title: 'Verjaardagen'
filter:
  include:
    - entity_id: sensor.anniversary*
      options:
        type: custom:multiple-entity-row
        entity: this.entity_id
        entities:
          - attribute: years_at_next_anniversary
            unit: jaar
      state: '< 20'
    - entity_id: sensor.anniversary*
      options:
        type: custom:multiple-entity-row
        entity: this.entity_id
        entities:
          - attribute: current_years
            unit: jaar
      state: '= 0'
sort:
  method: state
  numeric: true
show_empty: false

Hi All,
Iā€™ve been using this card for a while now and created quite a comprehensive list of warnings. Iā€™ve a new challenge and I canā€™t think how to solve it.
Iā€™ve created enhanced sensors for local river level sensors, adding their maximum ā€˜normalā€™ level (and locations for showing on a map).
Iā€™ve set a filter group for sensors containing the word ā€œfloodā€ but of course I get all the flood sensors regardless of their level. I want them to only appear when their state value exceeds this attribute value, Iā€™m having a mental block and canā€™t sus how to express this in a filter.

Can anyone help?

Thanks

Post a simplified code for your attempts for auto-entities-card containing your sensors.
Have you tried this?

Thatā€™s not quite what Iā€™m trying to achieve, here is some code that doesnā€™t work:


    - domain: sensor
      entity_id: /flood/
      state: ā€˜> this.entity_id.maximum_normalā€™

I know itā€™s wrong but Iā€™m not thinking clearly as to what it should be

Is it an attribute?
What possible values does it have? Are they [0ā€¦9, 10ā€¦99, 100ā€¦999], [0ā€¦9], [10ā€¦99] or ā€¦?
Also, what do you want to display - this attribute or a state?

Hi yes an attribute.
Itā€™s variable, ie flood level sensor specific and is measure in metres. It seems to vary from about 0.7 to 2.5. I only want to show flood sensors that are above the maximum normal figure that is applicable to that entity.

Maximum normal: 0.85m which is an attribute of sensor.any_Flood_level and is fixed for each sensor but different for each sensor.
Sensor.any_Flood_level: 0.75
And sensor does not showin my auto list.
Sensor.any_Flood_level: 1.1
The sensor shows in my auto list. It can just shown an icon, or the state, not bothered, but did assume it would show a state if it could be done

As far as I understood:

  1. There are some sensors.
  2. Every sensor has an attribute my_attr.
  3. There is an Entities card with these sensors.
  4. Some sensor must be displayed in the card if its state <= its attribute my_attr (or >=, whatever).

If I got your idea right - then try to adapt this code for your case:

    filter:
      template: >
        {% set GROUP = 'group.my_sensors' -%}
        {%- set MY_SENSORS = expand(GROUP) -%}
        {% for my_sensor in MY_SENSORS | sort(attribute="attributes.my_attr") -%}
          {%- set STATE_VALUE = states(my_sensor.entity_id) -%}
          {%- set ATTR_VALUE = state_attr(my_sensor.entity_id,"my_attr") -%}
          {%- if STATE_VALUE|float(default=0) <= ATTR_VALUE|float(default=0) -%}
            {{my_sensor.entity_id}},
          {%- endif -%}
        {%- endfor %}

The group.my_sensors must contain all your sensors.
This code was verified for another case, then I changed it for your case and then was not able to verify it again.

Note that sort(..) may give wrong results like ā€œ1,10, 111, 2, 3, 31, 4ā€.
But if values are like ā€œ0.4, 0.45, 0.7, 1.1, 2.3ā€ - I think that sorting will be OK.

1 Like

Hello,

itā€™s possible to attribute severity color of custom:bar-card according to an attribute sensor ?

Sorry, but how is it related to auto-entities?
Severity color is supposed to be defined for different ranges ā€œfromā€¦ toā€¦ā€ in bar-card.

1 Like

Yep i didnā€™t use Severity but style :
I try this but itā€™s not working :confused:

direction: up
type: custom:auto-entities
style: |
  ha-card {
    box-shadow: none !important;
  }
card:
  type: custom:bar-card
  title: Filaments
  show_header_toggle: false
  direction: up
  height: 709px
  stack: horizontal
  icon: mdi:printer-3d-nozzle
  attribute: state_percent
  unit_of_measurement: '%'
  positions:
    name: inside
    icon: inside
  style: |-
    bar-card-title {
      text-shadow: none;
    }
    ha-icon {
      color: white;
    }
    bar-card-card {
      text-shadow: none;
      color: white;
    }
    bar-card-currentbar {
      border-radius: 10px;
    }
sort:
  method: domain
filter:
  include:
    - entity_id: sensor.filament_*
      options:
        type: custom:bar-card
        name: test
        style: |-
          bar-card-currentbar {
            --bar-color: #FF0000 !important;
          }
          bar-card-value{         
            color: black;
          }
  exclude:
    - entity_id: sensor.filament_select
view_layout:
  grid-area: filament

EDIT : when i use color attribute itā€™s work
But if you use state_attr it doesnā€™t work :confused:

image

It is not loaded correctly :confused:

EDIT 2 : I have found solution :

  template: |
    {% for state in states.sensor -%}
      {%- if state.entity_id | regex_match('sensor.filament_',ignorecase=False) -%}
      {%- set NAME = state_attr(state.entity_id,"friendly_name") -%}
      {%- set COLOR = state_attr(state.entity_id,"color") -%}
        {{
          { 'entity': state.entity_id,
            'name': NAME,
            'color': COLOR
          } }},
      {%- endif -%} 
    {%- endfor %}