Climate.set_temperature with a input_number value?

Hello
I want to set the target temperature of a climate unit with the value taken from an input_number
I wrote this script:

alias: Comfort thermostat
sequence:
   - service: climate.set_temperature
     target:
       entity_id: climate.heating
     data_template:
       temperature: states.input_number.tempconfort | float
   - service: input_select.select_option
     target:
       entity_id: input_select.statothermostat
     date:
       option: Comfort
mode: single

but it gives me these errors

Comfort thermostat: Error executing script. Invalid data for call_service at pos 1: expected float for dictionary value @ data [‘temperature’]
Comfort thermostat: Error executing script. Error for call_service at pos 1: Error rendering data template: Result is not a Dictionary

Can anyone explain to me where am I wrong?
Thanks

alias: Comfort thermostat
sequence:
   - service: climate.set_temperature
     target:
       entity_id: climate.heating
     data:
       temperature: "{{ states('input_number.tempconfort')| float(0) }}"
6 Likes

Thank you so much, I was losing sleep
I’ll have to study the templates better

It’s pretty light on detail but there’s this:

And as it uses jinja to construct the templates there is this reference too:

https://jinja.palletsprojects.com/en/3.0.x/

Thank you :pray:

I have the gazoodle/geckolib integration and I can see and set the temprature manually.
entity_id: climate.rask_spa_heater

I need to set this temperature from outside from another independent machine via something.
Is that possible with the rest API or with intents or what shall I do?
I have tried with the rest api but I only manage to set parameters/states in the entity but nothing happens (no update sent to the SPA)
Ideas?

Hi
I did manage to find the API to change this.

url = "http://192.168.86.15:8123/api/services/climate/set_temperature"
token = "token"
headers = {
    "Authorization": "Bearer " + token,
    "content-type": "application/json",
}
service_data = '{"entity_id":"climate.rask_spa_heater","temperature":38}'

response = post(url, headers=headers,data = service_data)

This solution works great in an automation or a script, but when I try to use it on a tap_action of a button card in a dashboard, I have the following error :

expected float for dictionary value @ data['temperature']

Here, my button card code :

type: button
tap_action:
  action: call-service
  service: climate.set_temperature
  target:
    entity_id: climate.salon
  data:
    temperature: '{{ states(''input_number.temperature_eco_nuit'')| float(0) }}'

Do you have an idea of how to fix this error ?

You can’t use templates in most core Dashboard cards.

Call a script with your action in it.

Thanks, it’s works !

I share the solution, may be it could help someone:

type: button
tap_action:
  action: call-service
  service: script.allumer_un_chauffage
  data:
    climate_id: climate.salon
    input_temp: input_number.temperature_confort

And the script:

alias: Allumer un chauffage
sequence:
  - service: climate.set_temperature
    data:
      temperature: "{{ states(input_temp)| float(0) }}"
    target:
      entity_id: "{{ climate_id }}"
  - service: climate.turn_on
    data: {}
    target:
      entity_id: "{{ climate_id }}"
mode: parallel
icon: mdi:radiator
1 Like