Using helpers in automations

I am trying to adjust my automation that i use to switch my esp32 thermostat to night mode to take input helper values instead of fixed values.

So i set the automation action like this:

service: climate.set_temperature
data:
  target_temp_high: {{ states('input_number.heating_night_high') }}
  target_temp_low: {{ states('input_number.heating_night_low') }}
target:
  entity_id: climate.heating_thermostat

However after saving and opening the automation again the section looks likes this:

What am I doing wrong?

Wrap the single-line templates in double-quotes.

service: climate.set_temperature
data:
  target_temp_high: "{{ states('input_number.heating_night_high') }}"
  target_temp_low: "{{ states('input_number.heating_night_low') }}"
target:
  entity_id: climate.heating_thermostat

Reference: Important Template Rules


Or you can use a line-continuation character like this:

service: climate.set_temperature
data:
  target_temp_high: >
    {{ states('input_number.heating_night_high') }}
  target_temp_low: >
    {{ states('input_number.heating_night_low') }}
target:
  entity_id: climate.heating_thermostat
2 Likes