Icon template + script + "if/elif" in "if/elif"

Hi!
I can’t figure what is wrong with that :slight_smile:

What’s in the sensors.yaml

- platform: template
  sensors:
    tagtertemp1:
      friendly_name: "Chaud - T°"
      unit_of_measurement: '°C'
      value_template: '{{ (states.sensor.tertemp1.state.split("/")[1] | replace("°C","")) }}'
      icon_template: '{{%- if is_state("switch.terrarium", "on") -%}script.temp_ter_1_jour{%- elif is_state("switch.terrarium", "off") -%}script.temp_ter_1_nuit{%- else -%}mdi:alert-circle-outline{%- endif -%}}'

What’s in my scripts.yaml

temp_ter_1_jour:
  sequence:
    - entity_id: sensor.tagtertemp1
      icon_template: '{{%- if states.sensor.tertemp1.state|int < 30 -%}mdi:arrow-down-bold-circle{%- elif states.sensor.tertemp1.state|int <= 40 -%}mdi:thumb-up-outline{%- elif states.sensor.tertemp1.state|int > 40 -%}mdi:arrow-up-bold-circle{% else %}mdi:sync-alert{% endif %}}'
  
temp_ter_1_nuit:
  sequence:
    - entity_id: sensor.tagtertemp1
      icon_template: '{{%- if states.sensor.tertemp1.state|int < 20 -%}mdi:arrow-down-bold-circle{%- elif states.sensor.tertemp1.state|int <= 25 -%}mdi:thumb-up-outline{%- elif states.sensor.tertemp1.state|int > 25 -%}mdi:arrow-up-bold-circle{% else %}mdi:sync-alert{% endif %}}'

So I want to change an icon base on the temperature of the sensor AND ALSO base on the period of the day (hot point temperature day/night min/max for a lizard terrarium)

Note : The value (##.#) is displaying correctly when I remove the icon_template… line
Note2 : The template “simulator” in HA gives me that error : Error rendering template: TemplateSyntaxError: unexpected '%'

If you have any idea… Or if there is a simplier way to do that !

///Pretty new to all that but I have to say HA is really amazing!