Sending Variables to a working script from a template cover, error message occurs

Hey Forum,

after you all helped me with this thread:

I was able to proceed to the next level. I would like to call the script from a template cover.

So this script is working in the linked setup (see link above):

testscript:
  alias: testscript
  sequence:
  - service: cover.set_cover_position
    data: 
      entity_id: cover.eg_ez_roll_esphome      
      position: "{{ states(position_var) | int or position_var | int }}"   
  mode: single

When I trigger the script from this template_cover by clicking the “lovelace cover buttons”:

  - platform: template
    covers:
      eg_ez_roll_fe:
        device_class: blind
        friendly_name: "EG_EZ_Roll_FE"
        position_template: "{{ state_attr('cover.eg_ez_roll_esphome','current_position') }}"
        open_cover:
          service: script.testscript
          data:         
            position_var: 100
        close_cover:      
          service: script.testscript
          data:         
            position_var: 0
        stop_cover:
          service: script.roll_stop

it does not work and I get this error message:

Fehler beim Aufrufen des Diensts cover/open_cover. ‘int’ object has no attribute ‘lower’

I am stuck again :frowning: . Any ideas on how I can resolve this?

Nevermind, I worked around it …