Making a Template Cover to impose a min/max on Ikea Idasen Desk (or any cover)

I’m using the Ikea Idasen Desk integration successfully, but I really wanted to impose a min and max, and have Home Assistant treat them as 0 and 100%, so I created this Cover Template:

cover:
  - platform: template
    covers:
      office_desk_safe:
        unique_id: 5B2C0984-4083-48A8-8F53-077929A6A84C
        friendly_name: "Office Desk Safe"
        icon_template: mdi:desk
        open_cover:
          service: cover.set_cover_position
          target:
            entity_id: cover.office_desk
          data:
            position: 80
        close_cover:
          service: cover.set_cover_position
          target:
            entity_id: cover.office_desk
          data:
            position: 20
        stop_cover:
          service: cover.stop_cover
          data: {}
          target:
            entity_id: cover.office_desk
        set_cover_position:
          service: cover.set_cover_position
          target:
            entity_id: cover.office_desk
          data:
            position: "{{ (80 - 20) * (position / 100) + 20 }}"
        value_template: >
          {{ state_attr('cover.office_desk', 'current_position') >= 22 }}
        position_template: >
          {% set current_position = ( state_attr('cover.office_desk', 'current_position') - 20 ) / (80 - 20) * 100 %}
          {% if current_position > 100 %}
            100
          {% elif current_position < 0 %}
            0
          {% else %}
            {{ current_position }}
          {% endif %}

cover.office_desk is the Entity from the Ikea integration. My desired max is when that’s position is at 80, and my desired min is when it is at 20 (Replace all the 80s and 20s above with your desired mins and max if you use this).

I got the formulas for translating the range of 20-80 into 0-100 here:

percentage = (value - min) / (max - min)

And here’s the reverse (going from a percentage to a value):

value = ((max - min) * percentage) + min

Questions:

Is there a way I can set my min of 20 and max of 80 as variables, but with the scope of the entire Cover configuration, so that I don’t have to redefine them in each configuration variable that needs them?

Is this the best approach to impose a min/max on a Cover?

Are there improvements I can make?