Help with quick thermostat temperature preset script

Hi everyone!

I’m trying to create a script that can be triggered with a Button to set the target thermostat temperature to a specific value, in whatever current Hvac mode it’s in.

For example: Pressing button [22°C] executes the script that does the following:

  • If thermostat is in Cool mode, set target cooling temp to 22°C
  • If thermostat is in Heat mode, set target heating temp to 22°C

I created a simple script that (in my HA newbie thinking brain) is supposed to check what HVAC state the thermostat is currently in (heat or cool) and then set the target temperature to the predefined value in that given Hvac state.

The problem is, the script does not seem to trigger any action. I have tried the same syntax in an automation, and it does execute the first condition block but then exits.

I was wondering if anyone could point me in the right direction? I’m pasting the script below. Thank you :slight_smile:

# Set the thermostat temperature to 22C in the currently selected HVAC mode
alias: '-Test-Temp_Preset_to_22C'
sequence:
  - choose:
      - conditions:
          - condition: state
            entity_id: climate.thermostat
            state: cool
        sequence:
          - service: climate.set_temperature
            target:
              device_id: 1fd200229a2abbf611da089f3840d8
              entity_id: climate.thermostat
            data:
              temperature: 22
              hvac_mode: cool
      - conditions:
          - condition: state
            entity_id: climate.thermostat
            state: heat
        sequence:
          - service: climate.set_temperature
            data:
              temperature: 22
              hvac_mode: heat
            target:
              device_id: 1fd200229a2abbf611da089f3840d8
              entity_id: climate.thermostat
    default: []
mode: single

I’ll answer my own question as it seems that the culprit is the “hvac_mode” call for each condition. I thought I needed it to make sure the thermostat sets its target temperature in the correct Hvac mode, but it seems it’s not necessary and all is working as expected.