I am not sure whether to continue this in this thread or if it would be better to move, but I am not sure which card thread would be the correct one
So, I have used your code to create a grid with mutliple, auto-generated charts (happy to share the full code in case anybody is interested!).
Now your code already uses jinja templating plus Python dictionary, if I understand correctly. At least those were the two syntaxes that seemed to work.
If I want to past a template to one of the dictionary values, can this somehow be done directly by using the template inside the dict or do I always have to create a variable outside the dict and then use the var inside?
Let’s say as a simple example I want to use a count as a value.
{{ states.sensor | selectattr('name','search','Sony.*ENERGY Power.*') | map(attribute='entity_id') | list | count }}
in
'header': {
'title': {{ states.sensor | selectattr('name','search','Sony.*ENERGY Power.*') | map(attribute='entity_id') | list | count }}
}
This is not working right now, but is it because I made a syntax mistake (e.g. mark as a template inside dictionary) or because it has to be passed into the dictionary from the outside?
I wanted to set it on the outside like
filter:
template: >-
{% set DECIMALS = (states.sensor | selectattr('name','search','Sony.*ENERGY Power.*') | map(attribute='entity_id') | list | count) %}
{% for ENTITY_ID in states.sensor | selectattr('name','search','Xiaomi
Humidity.*') | map(attribute='entity_id') | list -%} {{
{
'type': 'custom:apexcharts-card',
.
.
.
with
'decimals': DECIMALS,
but well… no luck.