thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.24k stars 113 forks source link

Skip first 'X' does not work without count #291

Closed steven-hack closed 1 year ago

steven-hack commented 2 years ago

Hi,

I would like to display everything except the first X entries, but it seems the first parameter does not work without the count parameter. (As i don't know what the total amount is, I can't fill in a Count). Ofcourse a work-around for this is to just add count: 999999 but it would be nice if first would work like a skip when not using count.

Below example will display the two entities (of the two available):

  - type: custom:auto-entities
    filter:
      include:
        - entity_id: sensor.prullenbak_*
          sort:
            method: attribute
            attribute: days
            numeric: true
            reverse: false
            first: 1
    card:
      type: entities

afbeelding

The following will correctly skip the first one and only display one entity:

  - type: custom:auto-entities
    filter:
      include:
        - entity_id: sensor.prullenbak_*
          sort:
            method: attribute
            attribute: days
            numeric: true
            reverse: false
            first: 1
            count: 999
    card:
      type: entities

afbeelding

ildar170975 commented 2 years ago

Have to confirm the issue. The first option does not work if the count option is not set. Test code (used sun.sun entity):

type: vertical-stack
cards:
  - &ref_card
    type: custom:auto-entities
    card:
      type: entities
    filter:
      template: |-
        {% set SENSOR = 'sun.sun' -%}
        {%- for attr in states[SENSOR].attributes -%}
          {{
            {
              'type': 'attribute',
              'entity': SENSOR,
              'attribute': attr,
              'name': attr
            }
          }},
        {%- endfor %}
  - <<: *ref_card
    sort:
      count: 6
  - <<: *ref_card
    sort:
      first: 2
      count: 6
  - <<: *ref_card
    sort:
      first: 2

image