Error with template coding - please help!

Hi everyone - I have been trying for a few days to code some templates to conditionally format some badges on an elments card and one of the templates works as expected and the other does not - I have read endless forum posts but cant figure it out.

The template that works is this following

          {% if states('sensor.hvac_dhw_actual_temp') | float >=65 %}
          --my-dhwstate-color: red;
          {% elif states('sensor.hvac_dhw_actual_temp') | float >=40 and states('sensor.hvac_dhw_actual_temp') | float <65 %}
          --my-dhwstate-color: orange;
          {% elif states('sensor.hvac_dhw_actual_temp') | float <40 %}
          --my-dhwstate-color: blue;
          {% endif %}

The results in the developer tools template testing is as expected for the sensor value --my-dhwstate-color: red;

The template that does not work and gives me errors is the following

          {% if states('sensor.hvac_cirwaterout_temp') | float =<15 %}
          --my-outstate-color: blue;
          {% elif states('sensor.hvac_cirwaterout_temp') | float >15 and states('sensor.hvac_cirwaterout_temp') | float <30 %}
          --my-outstate-color: lime;
          {% elif states('sensor.hvac_cirwaterout_temp') | float >=30 and states('sensor.hvac_cirwaterout_temp') | float <40 %}
          --my-outstate-color: orange;
          {% elif states('sensor.hvac_cirwaterout_temp') | float >=40 %}
          --my-outstate-color: red;
          {% endif %}

This template gives me the following error in the developer test area

TemplateSyntaxError: expected token ‘end of statement block’, got ‘=’

and in the system logs

  • Error while processing template: Template<template=(:host { {% if states(‘sensor.hvac_cirwaterout_temp’) | float =<15 %} --my-outstate-color: blue; {% elif states(‘sensor.hvac_cirwaterout_temp’) | float >15 and states(‘sensor.hvac_cirwaterout_temp’) | float <30 %} --my-outstate-color: lime; {% elif states(‘sensor.hvac_cirwaterout_temp’) | float >=30 and states(‘sensor.hvac_cirwaterout_temp’) | float <40 %} --my-outstate-color: orange; {% elif states(‘sensor.hvac_cirwaterout_temp’) | float >=40 %} --my-outstate-color: red; {% endif %} }) renders=98>

The actual sensor value is between 25 and 30

Any help would be highly appreciated - I am reaching the end of my patience :frowning:
Thank you

Vas

Try changing float =<15 to float <=15

2 Likes

Thank you so much - I can’t believe I didn’t see this

I went code blind

Thank you

No worries, we’ve all done it!

1 Like