I have this list of json objects I’m pulling from an external api. Pulling the entire list gives me a max character error. Which is fine, cause all I’m interested are in two fields of each of the objects. Been beating my head over the keyboard trying to figure out the correct jinja2 to iterate over this and grab the fields. Any help would save my keyboard from a bloody death.
I can get this to work in the template tool
{% set json_val = {list of json below here} %}
{% for cp in json_val%}
{{ cp['name'] }}{{" "}}{{ cp['value'] }}
{% endfor %}}
Here is the list.
{
".id":"1",
"name":"speed3",
"type":"R",
"value":"0"
},
{
".id":"2",
"name":"speed4",
"type":"R",
"value":"20"
},
{
".id":"3",
"name":"b-temp",
"type":"C",
"value":"34"
},
{
".id":"4",
"name":"p-val1",
"type":"V",
"value":"26.5"
},
{
".id":"5",
"name":"p-val2",
"type":"V",
"value":"52.8"
},
{
".id":"6",
"name":"p-cur1",
"type":"C",
"value":"110"
},
{
".id":"7",
"name":"p-cur2",
"type":"C",
"value":"0.2"
}
The error the yaml check is giving me:
Invalid config for [sensor.rest]: invalid template (TemplateSyntaxError: expected token ':', got '}') for dictionary value @ data['value_template']. Got '< {%- for cp in [{ value_json }]-%} {{ cp[\'name\'] }}{{" "}}{{ cp[\'value\'] }} {%- endfor -%}'. (See ?, line ?).```

