thomasloven / lovelace-auto-entities

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

Add support for service responses #444

Open IDmedia opened 1 month ago

IDmedia commented 1 month ago

Similar to this request: https://github.com/custom-cards/flex-table-card/pull/131

Would it be possible to add support for service responses so we could pull data from a service such as todo.get_items and iterate over the response?

For the moment I'm doing something like this, but the problem is that it requies a template sensor and an automation to get data from the service and store it in the attribute-field. With support for service responses it would be nice to be able to drop the automation and sensor template.

 - type: custom:vertical-stack-in-card
    title: HA Tasks
    card_mod:
      style:
        $: |
          .card-header { padding: 12px 16px 4px 16px !important; }
    cards:
      - type: custom:auto-entities
        card:
          type: grid
          columns: 1
          square: false
        card_param: cards
        filter:
          template: >-    
            {% set items = state_attr("sensor.home_todo_list", "items") | list -%}
            {%- for i in items -%}
              {% set task_due = i.due or '' -%}
              {% set task_description = i.description or '' -%}
              {{
                  {
                    'type': 'custom:button-card',
                    'name': i.summary,
                    'template': 'todo_item',
                    'variables': {
                      'task_uid': i.uid,
                      'task_name': i.summary,
                      'task_description': task_description,
                      'task_status': i.status,
                      'task_due': task_due,
                      'task_entity': 'todo.home'
                    }
                  }
                }},
            {%- endfor %}