Hi!
This drives me crazy. I am trying to master button-card, templating, java script function by using [[[ ]]].
I want to change the background color on a button-card based on if sensor.latest_available_version == sensor.installed_version or not.
This code works fine:
- type: "custom:button-card"
entity: sensor.latest_available_version
color_type: card
show_name: true
color: blue
styles:
card:
- background-color: >
[[[
if (1 == 1)
return "green";
return "blue";
]]]
but when I add the real if comparison it stops working.
- type: "custom:button-card"
entity: sensor.latest_available_version
color_type: card
show_name: true
color: blue
styles:
card:
- background-color: >
[[[
if (states('sensor.latest_available_version') == states('sensor.latest_available_version'))
return "green";
return "blue";
]]]
I have tested if {{ (states(‘sensor.latest_available_version’) == states(‘sensor.latest_available_version’)) }} in templating and it returns True so I cannot understand what makes it fail. Incorrect use of quotes " and ’ or comparison on wrong data type?