Is it possible to use Jinja in Lovelace views? The goal is to have different picture urls, based on the sensor state. This one does not work.
- type: picture
image: >
{% if is_state('binary_sensor.test', 'on') %}
https://url-a.com/test.jpg
{% else %}
https://url-b.com/test.jpg
{% endif %}
As a alternative, can I overwrite the url in a automation?
petro
(Petro)
2
jinja is only supported in specific fields. None of them are in lovelace. There are custom cards that can do this. Do you have HACS?
I found a solution with conditional, no need for custom cards. Working fine.
- type: conditional
conditions:
- entity: binary_sensor.test
state: 'on'
card:
type: picture
image: !secret url_meteogram_day
- type: conditional
conditions:
- entity: binary_sensor.test
state_not: 'on'
card:
type: picture
image: !secret url_meteogram_night