Problem using Helpers in automations

Hi,

i try to set the temerature of my thermostat to a value that is in an input_number helper:

alias: Automate Heizung Dachgeschoss
description: ""
trigger:
  - platform: state
    entity_id:
      - device_tracker.notebook
    to: home
action:
  - service: climate.set_temperature
    data:
      temperature:
        {{ states("input_number.komfort_temperatur_dachgeschoss") }}
    target:
      area_id: dachgeschoss
mode: single

I can query this number using the developer Template Section.

But after saving it is autmatically changed to this:

[...]
  - service: climate.set_temperature
    data:
      temperature:
        "[object Object]": null
    target:
      area_id: dachgeschoss
[...]

I am not sure, what is wrong there?

      data:
        temperature: "{{ states('input_number.komfort_temperatur_dachgeschoss') | default(19.5) | float}}"

If you put the template on the same line as the option, you must wrap the template in quotes. The outer quotes should be different from the inner quotes. In the following example, the outer quotes are single quotes and the inner quotes are double quotes.

    data:
      temperature: '{{ states("input_number.komfort_temperatur_dachgeschoss") }}'

If you put the template on the next line after the option, you must put a line-continuation character after the option. Typically one uses a > or a | character for this purpose. In addition, the temple must be indented with respect to the option. The template should not be wrapped in quotes.

    data:
      temperature: >
        {{ states("input_number.komfort_temperatur_dachgeschoss") }}

Reference: Important Template Rules

1 Like

Thank you, i wasn’t aware of that :wink:

1 Like