Using User-Defined state in template_number to execute rest_command

Hi Community,

I have the following template number which I want to execute a rest command on change:

- unique_id: apsystems_ez1_max_power
  name: apsystems_ez1_max_power
  icon: mdi:lightning-bolt-circle
  availability: |-
    {{-
      is_state('sensor.apsystems_ez1_state', 'OK')
      and is_number(state_attr('sensor.apsystems_ez1_state', 'currentMaxPower'))
      and is_number(state_attr('sensor.apsystems_ez1_state', 'minPower'))
      and is_number(state_attr('sensor.apsystems_ez1_state', 'maxPower'))
    -}}
  state: "{{- state_attr('sensor.apsystems_ez1_state', 'currentMaxPower') | int -}}"
  set_value:
    - service: rest_command.apsystems_setmaxpower
      data:
        power: "{{- this.state -}}"
    - service: homeassistant.update_entity
      target:
        entity_id: sensor.apsystems_getMaxPower
  step: 1
  min: "{{- state_attr('sensor.apsystems_ez1_state', 'minPower') | int -}}"
  max: "{{- state_attr('sensor.apsystems_ez1_state', 'maxPower') | int -}}"

Problem is that this.state does not contain the new state set by a user, it contains the current state of the number :frowning:. Is there another variable that my contain the state set be the user?

image