Dynamic limit for input_number?

Is it possible to have a dynamic limit for an input_number?

For example, I have some temperatures that can be selected in the UI (I’ll pick one set for simplicity) and then I have automations and templates that “choose” which set of temperatures to push to my thermostat:
Vacation/Away Heating Temp
Vacation/Away Cooling Temp

I want to be able to tweak them without going into the code so I used an input-number but also I need to make sure it can’t bet set where the heating temp is greater than the cooling temp (e.g. heat to 80, cool to 70) at the same time.

Is there some way to “interlock” the max/min? Like the “max” for heating is whatever “cooling” is set to; the “min” for cooling is whatever “heating” is set to?

When I attempted to put a template in the max: line it didn’t like that.

  downstairs_hvac_requested_away_heat:
    name: Downstairs HVAC Away Heat
    icon: hass:fire
    # initial: 67
    min: 65
    max: 80
  downstairs_hvac_requested_away_cool:
    name: Downstairs HVAC Away Cool
    icon: hass:snowflake
    # initial: 76
    min: 65
    max: 80

image

But with one wrong accidental swipe, this isn’t actually possible to set a thermostat to:
image

You will need to use a Template Number entity rather than an Input number helper. Make sure to include default values in your templates or they will likely not load due to errors.

Is there a way to have the default remember the last set value?

I see that also requires an action to run on change, what’s the best way to handle that not actually running anything but just being a state which exists?

The “last set value” of what?

If you want the state to be persistent you need to use the action to save it somewhere…

template:
  - number:
      - name: A Great Number
        state: "{{ states('input_text.example') }}"
        set_value:
          - service: input_text.set_value
            data:
              value: "{{ value }}"
            target:
              entity_id: input_text.example
        step: 0.1
        min: "{{ states('input_number.the_minimum') | float(-100) }}"
        max: "{{ states('input_number.the_maximum') | float(100) }}"
        availability: "{{ states('input_text.example') | is_number }}"