thomasloven / lovelace-auto-entities

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

attributes filter 'entity_id' doesn't work (on domain light) #267

Closed Mariusthvdb closed 2 years ago

Mariusthvdb commented 2 years ago

trying to select all light groups (light entities that contain an attribute 'entity_id' I tried the straightforward filter but is doesnt work:

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          include:
            - domain: light
              attributes:
                entity_id: '*'
Schermafbeelding 2022-03-31 om 09 52 12

this is surprising because a straight copy of that for domain scene and attribute 'group_name' works just fine:

          - type: custom:auto-entities
            card:
              type: entities
            filter:
              include:
                - domain: scene
                  attributes:
                    group_name: '*'

What is working, is this template filter:

      - type: custom:auto-entities
        card:
          type: entities
        filter:
          template: >
            {{states.light|selectattr('attributes.entity_id','defined')
              |map(attribute='entity_id')|list}}
Schermafbeelding 2022-03-31 om 09 50 57

please have a look why this doesnt work, and if it can be fixed. It would allow for much easier configuration in the options....

Maybe related? https://github.com/home-assistant/core/issues/68836 was fixed in https://github.com/home-assistant/core/pull/68875

in dev tools state:

Schermafbeelding 2022-03-31 om 09 49 37

for testing purposes I did:

          include:
            - attributes:
                entity_id: '*'

and then becomes apparent that only a mere fraction (20) of the (121) states with attribute 'entity_id' get selected.

Schermafbeelding 2022-03-31 om 09 59 45

what's more, trying to use option on a template config like:

        filter:
          template: >
            {% for l in states.light|selectattr('attributes.entity_id','defined') %}
            {{
              {
              'type': 'custom:slider-entity-row',
              'entity': l.entity_id
              }
            }}
            {%- endfor %}

which shows the list correctly in dev tools template, again shows an empty card in the frontend, and no errors in console

Mariusthvdb commented 2 years ago

Missed the section on Stringification https://github.com/thomasloven/lovelace-auto-entities#stringification:

this works:

  - type: custom:auto-entities
    card:
      type: entities
      title: Group lights auto
    filter:
      include:
        - domain: light
          attributes:
            entity_id: '$$*'
          options:
            type: custom:slider-entity-row
            toggle: true

closing, with an apology for reading not closely enough... thanks for an ever so great card!