šŸ„ Template card shows wrong icon color

Greetings. Our current template(s) cards are configured to change color based on input values/thresholds against a reported/current temperature/humidity value, but sometimes it shows properly and sometimes it doesnā€™t:
image
You can see above that 1) Input Number 2) States match yet the condition for ā€˜tempminā€™ is incorrectly shown on Template Card; see piece of code below:

...
icon_color: |-
  {% set state=states('sensor.sensorX_temperature') %}
  {% if state>=states('input_number.sensorX_tempmax') %}
  red
  {% elif state<=states('input_number.sensorX_tempmin') %}
  purple
  {% else %}
  green
  {% endif %}
...

Weā€™ve tried various things and nothing seems to work; what are we missing here? Fun facts: if we ā€˜raiseā€™ the ā€˜tempminā€™ threshold to ~60, it turns greenā€¦ also, some negative values turns the icon green, some redā€¦ last piece of info: the ā€˜notifyā€™ service does correctly notify (or not) based on values, so even when the iconā€™s color is incorrect, we get/not correctly the notificationsā€¦ Thanks. :red_circle:

Use |int(0) (or any other default) with all your entities.

1 Like

Thanks for the help! :red_circle: