please have a look what I am not seeing… trying to add a card_mod to a template filter is always a bit tricky, but somehow I cant find the error, and the output in dev template seems ok too…
filter:
template: >
[{% set threshold = states('input_number.power_threshold')|float(0) %}
{% set ns = namespace(above_threshold=[]) %}
{% for s in states.sensor
|rejectattr('entity_id','search','solaredge')
|rejectattr('entity_id','eq','sensor.alle_schakelaars_samen_actueel')
|selectattr('entity_id','search','_actueel|_current_power')
if s.state|float(0) > threshold %}
{{
{
'entity': s.entity_id,
'options':
{'card_mod': '!secret power_color'}
}
}},
{%- endfor %}]
does create the correct list of filtered entities and shows those, but the card_mod option is not applied, meaning the icons aren’t colored as expected.
if I do a single entity like this:
- entity: sensor.vijverpomp_links_actueel
card_mod: !secret power_color
it does work properly ( icon is colored following state), and attaches the secret which I saved as
power_color:
style: |
:host {
--paper-item-icon-color:
{% set state = states(config.entity)|int(-5) %}
{% if state > 2000 %} purple
{% elif state > 1000 %} maroon
{% elif state > 450 %} darkred
{% elif state > 300 %} firebrick
{% elif state > 250 %} crimson
{% elif state > 150 %} darkorange
{% elif state > 70 %} orange
{% elif state > 10 %} lightsalmon
{% elif state > 0 %} gold
{% else %} var(--no-power-color)
{% endif %}
}
not sure what to check next. is it a dom path that changed because of the auto-entities, and should I change the mod itself? (Inspector seems to show the identical path…)
or, is it a syntax problem after all, and should I change the template filter.
the result is a list alright, as seen here:
and the output is like this:
[
{
"entity": "sensor.patchboard_zolder_actueel",
"options": {
"card_mod": "!secret power_color"
}
},
{
"entity": "sensor.vijverpomp_links_actueel",
"options": {
"card_mod": "!secret power_color"
}
}
]
tried it like this too:
filter:
include:
- entity_id: sensor.*_actueel
options:
card_mod: !secret power_color
which also works correctly showing all nicely colored icons.
So, my first bet would be the template filter has a syntax issue…
would appreciate a look, thanks
btw nevermind the namespace, it is a remnant of my other template, and does nothing in this config.
update
some progress… I should not use the option:
in the template filter…
I can. are things happen when spelling the mod out verbosely (and not inserting the secret)
template: >
[{% set threshold = states('input_number.power_threshold')|float(0) %}
{% for s in states.sensor
|rejectattr('entity_id','search','solaredge')
|rejectattr('entity_id','eq','sensor.alle_schakelaars_samen_actueel')
|selectattr('entity_id','search','_actueel|_current_power')
if s.state|float(0) > threshold %}
{{
{
'entity': s.entity_id,
'card_mod':
{'style':
':host {
--paper-item-icon-color:
{% set state = states(config.entity)|int(-5) %}
{% if state > 2000 %} purple
{% elif state > 1000 %} maroon
{% elif state > 450 %} darkred
{% elif state > 300 %} firebrick
{% elif state > 250 %} crimson
{% elif state > 150 %} darkorange
{% elif state > 70 %} orange
{% elif state > 10 %} lightsalmon
{% elif state > 0 %} gold
{% else %} var(--no-power-color)
{% endif %}
}'
}
}
}},
{%- endfor %}]
dont think we an import the !secret inside the template filter here…