Skip to content

Data from rest_command appears double #145

@KTHconsult

Description

@KTHconsult

Im using the rest_command to get a json data array. Rest_command add this response to a dictionary where data as json is kept in the item called content alongside the item status that has the response status code.
For easy reproduction i added a script with hardcoded result that shows the issue.

Flex Table Card configuration

type: custom:flex-table-card
title: Recipes from script
service: script.recipes
entities: []
columns:
  - name: Id
    data: content
    modify: x.id
  - name: Name
    data: content
    modify: x.name

Output from flex-table-card

Recipes from script

Id | Name

1 | Production Sprint of Painkiller Syringe
2 | Final Sprint of Association Council
3 | Final Testing of Association Syringe
1 | Production Sprint of Painkiller Syringe
2 | Final Sprint of Association Council
3 | Final Testing of Association Syringe

I would expect to only see 3 rows instead of 6

Script that reproduces rest_command wrapping logic

alias: Recipes
sequence:
  - variables:
      recipes: |
        {% set myrecipes = {"content": [ 
          {
            "name": "Production Sprint of Painkiller Syringe",
            "description": "a",
            "id": 1,
            "created": "2024-09-30T09:15:19.203"
          },
          {
            "name": "Final Sprint of Association Council",
            "description": "b",
            "id": 2,
            "created": "2024-09-30T09:15:19.417"
          },
          {
            "name": "Final Testing of Association Syringe",
            "description": "c",
            "id": 3,
            "created": "2024-09-30T09:15:19.64"
          }
        ] , "status":200} %} {{ myrecipes }}
  - stop: All done
    response_variable: recipes

Result from rest_command action

content:
  - name: Production Sprint of Painkiller Syringe
    description: >-
      a
    id: 1
    created: "2024-09-30T09:15:19.203"
  - name: Final Sprint of Association Council
    description: >-
      b
    id: 2
    created: "2024-09-30T09:15:19.417"
  - name: Final Testing of Association Syringe
    description: >-
      c
    id: 3
    created: "2024-09-30T09:15:19.64"
status: 200

How can I configure the flex-table-card to only render 3 rows and thereby reflect the actual data result from the content section?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions