thomasloven / lovelace-auto-entities

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

Possible to use with multiple-entity-row? #418

Open Milinator opened 8 months ago

Milinator commented 8 months ago

Hey there,

I've been trying to sort the following entity list (originally using multiple-entity-row): `type: entities entities:

But I'm not sure if it even is possible? Could someone help me out? I want to sort it by the attribute "remaining", but I just can't get it to work. image

Best regards,

Milan

austin20202020 commented 8 months ago

i too have been trying to get this work

jb1228 commented 4 months ago

There might be another way to do this, but I have been using the template filter to return a list of objects instead of just a list of entity IDs.

Here is an example:

type: custom:auto-entities
card:
  type: entities
filter:
  template: |
    {% set ns = namespace(list=[]) %}

    {% for light in states.light %}
      {% if light.state == "on" %}

        {% set ns.list = ns.list + 
          [
            {
              'type': 'custom:multiple-entity-row',
              'entity': light.entity_id,
              'name': light.attributes.friendly_name,
              'state_color': true,
              'show_state': false,
              'entities': [
                {
                  'entity': light.entity_id,
                  'name': 'Lights',
                  'toggle': true
                },
                {
                  'entity': light.entity_id,
                  'attribute': 'brightness',
                  'name': 'Brightness'
                }
              ]
            }
          ] 
        %}

      {% endif %}
    {% endfor %}

    {{ ns.list }}