Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for service responses #444

Open
IDmedia opened this issue May 24, 2024 · 2 comments
Open

Add support for service responses #444

IDmedia opened this issue May 24, 2024 · 2 comments

Comments

@IDmedia
Copy link

IDmedia commented May 24, 2024

Similar to this request: custom-cards/flex-table-card#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 %}
@VEspling
Copy link

Following!

I would like to try something like that for listing search results from calling music-assistant search.

@ildar170975
Copy link

Compare a template sensor & trigger-based template sensor.
The "simple" template sensor only resolves a template(s) to determine a state (and/or attributes).
The trigger-based template sensor can perform some ACTIONS before resolving templates - and these actions are performed after a trigger executed.
Here in auto-entities card you propose to add some kind of "actions" which are supposed to be performed before applying a filter (defined inside a template option, for instance). What is supposed to be a "trigger" here? A page refresh? Opening a view? "Every minute" tick?
With my all respect, for me this FR seems to be a complication; since there are standard ways to achieve the same - no need to incorporate it to a this card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants