Occasionally there are issues like this when switching between the visual editor and the yaml editor. However, what you created in the yaml editor was not a valid entry because you didnât define your temperature variable and templates need to be enclosed in quotes or a multi-line quote symbol (> or |).
alias: 'Switch: Airco x op graden'
variables:
temperature: '{{ states("input_number.desired_temp")}}'
sequence:
- device_id: 67455609e3c9d29e44adb86b16e0e855
domain: climate
entity_id: climate.airco_gang
type: set_hvac_mode
hvac_mode: heat
- service: climate.set_temperature
data:
temperature: '{{ temperature }}'
target:
entity_id: climate.airco_gang
mode: single
Sorry, about that⌠I misunderstood what you were trying to do.
When creating scripts that accept variables, it is usually a good idea to set up the fields to make it easy to test using the Services tool.
If you want to be able to use different entity_ids (as you set it up in your most recent example), you should not use a device action, instead use a call service so you donât have to worry about all the device variables.
alias: 'Switch : Airco x op y graden'
description: ' Set airco mode to heat and set temperature'
fields:
temperature:
description: "The temperature to set the airco at"
default: 25
example: "21.2"
entity_id:
description: "The climate entity you want to control"
default: "climate.airco_gang"
example: "climate.airco_gang"
sequence:
- service: climate.set_temperature
target:
entity_id: "{{ entity_id }}"
data:
temperature: "{{ temperature }}"
hvac_mode: heat
mode: single
Thank you very much, Iâm beginning to understand the concept
type: button
tap_action:
action: call-service
service: script.switch_airco_x_op_y_graden
service_data:
temperature: '20'
entity_id: climate.airco_gang
target: {}
name: Airco x op y graden
alias: 'Switch : Airco x op y graden'
description: ' Set airco mode to heat and set temperature'
variables:
temperature:
description: The temperature to set the airco at
default: '25'
example: '21'
entity_id:
description: The climate entity you want to control
default: climate.airco_gang
example: climate.airco_gang
sequence:
- service: climate.turn_on
target:
entity_id: '{{ entity_id }}'
- service: climate.set_hvac_mode
target:
entity_id: '{{ entity_id }}'
data:
hvac_mode: heat
- service: climate.set_temperature
data:
temperature: '{{ temperature }}'
target:
entity_id: '{{ entity_id }}'
mode: single
Let say I want to modify the temperature of 2 aircons (climate.airco_living_links and climate.airco_living_rechts) with this button, how can I do that ?
Now I tried your suggestion of testing the script in the editor, but I get an error (Template rendered invalid entity IDs: {âdescriptionâ: âThe climate entity you want to controlâ, âdefaultâ: âclimate.airco_gangâ, âexampleâ: âclimate.airco_gangâ}) ?
And another thing : how can I easily see where a script is used (I have to replace the old script by this one) ?
alias: 'Switch : Airco x op y graden'
description: Set airco mode to heat and set temperature
fields:
temperature:
description: The temperature to set the airco at
default: '25'
example: '21'
entity_id:
description: The climate entity you want to control
default: climate.airco_gang
example: climate.airco_gang
sequence:
- service: climate.turn_on
target:
entity_id: '{{ entity_id }}'
- service: climate.set_hvac_mode
target:
entity_id: '{{ entity_id }}'
data:
hvac_mode: heat
- service: climate.set_temperature
data:
temperature: '{{ temperature }}'
target:
entity_id: '{{ entity_id }}'
- service: climate.set_fan_mode
data:
fan_mode: auto
target:
entity_id: '{{ entity_id }}'
mode: single
alias: 'Switch : Airco x op y graden'
description: Set airco mode to heat and set temperature
fields:
temperature:
description: The temperature to set the airco at
default: 25
example: 21
entity_id:
description: The climate entity you want to control
default: climate.airco_gang
example: climate.airco_gang
sequence:
- service: climate.turn_on
target:
entity_id: '{{ entity_id }}'
- service: climate.set_hvac_mode
target:
entity_id: '{{ entity_id }}'
data:
hvac_mode: heat
- service: climate.set_temperature
data:
temperature: '{{ temperature }}'
target:
entity_id: '{{ entity_id }}'
- service: climate.set_fan_mode
data:
fan_mode: auto
target:
entity_id: '{{ entity_id }}'
mode: single
Even when I copy / paste the code of your post, I get the error of entity_idâŚ
alias: 'Switch : Airco x op y graden'
description: ' Set airco mode to heat and set temperature'
fields:
temperature:
description: "The temperature to set the airco at"
default: 25
example: "21.2"
entity_id:
description: "The climate entity you want to control"
default: "climate.airco_gang"
example: "climate.airco_gang"
sequence:
- service: climate.set_temperature
target:
entity_id: "{{ entity_id }}"
data:
temperature: "{{ temperature }}"
hvac_mode: heat
mode: single
I donât understand why it suddenly doesnât work anymore ?
Meanwhile everything is OK, but for some reason sometimes it doesnât (aircon is still off).
So I want to execute the script a number of times till my aircon is on.
But I donât know what I have to set as condition (in bold) :
alias: 'Switch : Airco x op y graden'
description: Set airco mode to heat and set temperature
fields:
temperature:
description: The temperature to set the airco at
default: 22
example: '21'
entity_id:
description: The climate entity you want to control
default: climate.airco_gang
example: climate.airco_gang
sequence:
- repeat:
sequence:
- service: climate.turn_on
target:
entity_id: '{{ entity_id }}'
- service: climate.set_hvac_mode
target:
entity_id: '{{ entity_id }}'
data:
hvac_mode: heat
- service: climate.set_temperature
data:
temperature: '{{ temperature }}'
target:
entity_id: '{{ entity_id }}'
- service: climate.set_fan_mode
data:
fan_mode: auto
target:
entity_id: '{{ entity_id }}'
until:
- condition: template
value_template: '{{ not is_state(**entity_id**, 'off') or repeat.index >= 2 }}'
mode: single