How do i correctly use a variable in a condition?

Hi, apricate if someone can help me with one of my scripts here. I have a script the “warms the floor” which gets triggered when the heating is on and the floor temp drops below a set point (under floor heating)

The idea of the script is to raise the temperature of the floor to 25c, by increasing the setpoint of the thermostat by 1 degree. Once the floor reaches 25c i set the thermostat temperature back to what ever it was before, unless the set temp has already been changed. This could be by me manually or when when the schedule changes.

The bit that isn’t working for me is the condition that checks if the set temp has changed, i can not seem to use the variable correctly.

I’m assuming the new_set_temp variable should display its value here…

image

Here’s my script…

alias: Warm Floor
variables:
  old_set_temp: '{{ states.climate.living_room.attributes.temperature | float }}'
  new_set_temp: >-
    {{ ((states.climate.living_room.attributes.current_temperature) + 1) |
    round(0,"ceil") }}
sequence:
  - service: climate.set_temperature
    target:
      entity_id: climate.living_room
    data_template:
      temperature: '{{ new_set_temp }}'
  - wait_for_trigger:
      - platform: numeric_state
        above: '25'
        entity_id: climate.living_room
        attribute: floor_temperature
        for:
          hours: 0
          minutes: 5
          seconds: 0
    timeout: '01:00:00'
  - condition: state
    entity_id: climate.living_room
    attribute: temperature
    state: '{{ new_set_temp }}'
  - service: climate.set_temperature
    target:
      entity_id: climate.living_room
    data:
      temperature: '{{ old_set_temp }}'
mode: single

Any help would be greatly apricated, or advice on a better way to deal with detecting if the set temperature had changed since being set by HA.

Cheers

It fails to work because a State Condition doesn’t accept templates.

Replace it with a Template Condition:

  - condition: template
    value_template: "{{ is_state_attr('climate.living_room', 'temperature', new_set_temp) }}"

What @123 said… also, it’s best not to use state objects and you are missing a couple default args that are require since 2021.12.

variables:
  old_set_temp: '{{ state_attr('climate.living_room', 'temperature') | float(0) }}'
  new_set_temp: >-
    {{ (state_attr('climate.living_room', 'current_temperature')|float(0) + 1) |
    round(0, "ceil", 0) }}

Thanks both for the help and explanation.