How to use templates with picture-elements card?

Hi,

I start playing with the “picture-elements”.
I would like to change dynamically the background-color when the “humidity” of one sensor is above 50% (visual feedback, kind of alerting).

I am back to even a more basic question: is templating supported in this card ?
As an example below, I simply try to have the “Title” being displayed dynamically without success

But when reopening the editor (in lovelace), the row

{{ states(‘counter.presence_hall’)}}
has been replaced by
’[object Object]’: null

Any idea or alternive for my main objective (change background-color when sensor above a given numeric value) ?

    cards:
      - elements:
          - entity: sensor.zigate_00158d00034f8c03_temperature
            style:
              left: 25%
              top: 57.5%
            title: température
            type: state-label
          - entity: sensor.zigate_00158d00034f8c03_humidity
            style:
              left: 25%
              top: 59.2%
            title: {{ states('counter.presence_hall')}}
            type: state-label
        image: local/Thines3.jpg
        type: picture-elements

Templates are jinja syntax. Cards are javascript.

It would take a custom card to be able to render a jinja template. It would have to make a service call into home assistant with the template and get a response, then render the response in javascript. Such cards do exist…but these aren’t it.

Just create a template sensor and use that template sensor as the card background. Have the template sensor output whatever static states you want. Then use these as the states filter.

for example

value_template: "{{ 'light' if states('sensor.humidity') | float < 50.0 else 'heavy'}}"

Then in your card, look at the template sensor for ‘light’ or ‘heavy’ state.

1 Like

when I search this page, no template is found so I presume the answer is No.
there are many custom cards available, have a look here or here

there are cards that support JS templates - button-card, for example

from what I gathered recently, because of that Jinja card rendering I wouldn’t recommend custom cards with Jinja templates, especially if you have a lot of them as it will slow down your viewing device.

1 Like

Clear. I will try that tomorrow. Thank you!

1 Like