You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I would like to be able to modify the background color based on an entity that tells me the price of electricity. The idea would be to do something like this, only this code doesn't work.
Is there any way to do it correctly?
Thank you very much.
style_card_content: | background-color: {%- set period = states.sensor.precio_kwh.attributes.Period %} {%- if period == 'P3' %} #00ff000a {%- elif period == 'P2' %} #ffb40010 {%- elif period == 'P1' %} #ff00000a {%- else %}#006400 {%- endif %}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I would like to be able to modify the background color based on an entity that tells me the price of electricity. The idea would be to do something like this, only this code doesn't work.
Is there any way to do it correctly?
Thank you very much.
style_card_content: |
background-color:
{%- set period = states.sensor.precio_kwh.attributes.Period %}
{%- if period == 'P3' %} #00ff000a
{%- elif period == 'P2' %} #ffb40010
{%- elif period == 'P1' %} #ff00000a
{%- else %}#006400
{%- endif %}
Beta Was this translation helpful? Give feedback.
All reactions