Cover/Blind Script with a value template

I have blinds that I’m using a script to automate. Since I have moved my automation model to use the Chooser the automation runs more often now. This is expected and is not the problem.

The problem is that when the automation runs again, perhaps with a Home Assistant restart etc (I have this as a trigger) the blind does a little jig.

The script makes a request to the blind to set position at 50 (example). When the blind is done moving it might end up with a current_position of 51.

So then the next time the automation runs it does a little jig as the blind tries to move from 51 to 50. It never makes it to 50 for some reason so all day long my blinds are doing little jigs.

I thought I could put some logic in there so that it doesn’t try to change the level if it is within 2 of the desired level.

I can’t come up with how to do this that works.

Here is how I cam calling my blinds to move

action:
  - choose:
    - conditions:
      - condition: state
        entity_id: input_select.house_mode
        state:  Breakfast
      sequence:
        - service: script.master_bedroom_blind_pct_individual
          data: 
            blind_pct: 50
            blind_entity_id: cover.master_bedroom_left_blind_level
        - delay: 00:00:02
        - service: script.master_bedroom_blind_pct_individual
          data: 
            blind_pct: 0
            blind_entity_id: cover.master_bedroom_middle_blind_level
        - delay: 00:00:02
        - service: script.master_bedroom_blind_pct_individual
          data: 
            blind_pct: 0
            blind_entity_id: cover.master_bedroom_right_blind_level

and here is blind_individual_pct.yaml

master_bedroom_blind_pct_individual:
  alias: Master Bedroom Blind Percent Individual
  description: Master Bedroom Blind Percent Individual
  mode: single
  fields:
    blind_pct:
      description: The percentage OPEN for the blind. 0 is Closed.
      example: "0"
    blind_entity_id:
      description: The blind entity_id
      example: cover.master_bedroom_left_blind_level

  sequence:
    - service: cover.set_cover_position
      data:
        position: "{{ blind_pct }}"
        entity_id: "{{ blind_entity_id }}"

I’m not sure where or how to put this >= desired -2 and <= desired +2

Thanks for any assistance

I’m thinking if I could add a condition here it would work for me

sequence:
    - service: cover.set_cover_position
      data:
        position: "{{ blind_pct }}"
        entity_id: "{{ blind_entity_id }}"

The condition would be current_position attribute of input field blind_entity_id being within 2 of the desired input field blind_pct. I can’t get the syntax to work for me.