Unable to pass a template float to an action

Hi,

I’m so close to make my thermostats behave the way I want. Now the following doesn’t work in the action part:

  action:
  - data:
      temperature: '{% if is_state(''binary_sensor.workday_sensor'',''on'') %} 22 {% else %} 21 {% endif %}'
    entity_id: climate.neviweb130_climate_martin
    service: climate.set_temperature

I get:

2020-01-12 09:11:10 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.a_test. Invalid data for call_service at pos 1: expected float for dictionary value @ data['temperature']

If I put only temperature: 22, it works so I know the problem is there. The same string as a value for a message in notify works so the template syntax is fine.

I tried the following

temperature: '{% if is_state(''binary_sensor.workday_sensor'',''on'') %} {{22.0 | float}} {% else %} {{ 21.0 | float}} {% endif %}'

and

temperature: '{% if is_state(''binary_sensor.workday_sensor'',''on'') %} {{float(22.0)}} {% else %} {{ float(21.0)}} {% endif %}'

and even just temperature: '{{20.0 | float}}' or temperature: '{{float (20.0)}}'

And nothing works :frowning:

How do you pass template values as a float in action? I’m at lost, help please :slight_smile:

Well, after all that trouble shooting, I had data: instead of data_template: :frowning: It’s now fixed :slight_smile: