Help with template cover passing data for tilt

I’m trying to create a template cover which calls scripts for the various actions which check if the windows are open before performing said actions.

I have this template cover:

cover:
  - platform: template
    covers:
      dining_room_blind:
        friendly_name: "Dining Room Blind"
        set_cover_position:
          service: script.dining_room_blind_set_cover_position_if_windows_closed
          data:
            position: "{{ position }}"
        set_cover_tilt_position:
          service: script.dining_room_blind_set_cover_tilt_position_if_windows_closed
          data:
            tilt_position: "{{ tilt_position }}"
        position_template: "{{ state_attr('cover.blind_1', 'current_position') }}"
        tilt_template: "{{ state_attr('cover.blind_1', 'current_tilt_position') }}"
        icon_template: "{{ state_attr('cover.blind_1', 'icon') }}"

sending a cover.set_cover_position command from the UI and dev tools (call service) works fine.

however, sending cover.set_cover_tilt_position raises the following complaint:

Dining Room Blind: Error executing script. Invalid data for call_service at pos 1: expected int for dictionary value @ data[‘tilt_position’]
20:56:32 – (ERROR) helpers/script.py - message first occurred at 20:49:25 and shows up 3 times

Dining Room Blind: Set cover tilt position if windows closed: If at step 1: Error executing script. Invalid data for call_service at pos 1: expected int for dictionary value @ data[‘tilt_position’]
20:56:32 – (ERROR) Scripts - message first occurred at 20:49:25 and shows up 6 times

What’s going on?

My Script looks like this:

alias: 'Dining Room Blind: Set cover tilt position if windows closed'
sequence:
  - if:
      // removed for brevity
    then:
      - service: cover.set_cover_tilt_position
        data_template:
          tilt_position: '{{tilt_position}}'
        target:
          device_id: XXX
mode: restart
icon: mdi:blinds

Calling my script like this, works

service: script.dining_room_blind_set_cover_tilt_position_if_windows_closed
data: 
  tilt_position: 50
  1. How do I debug this for myself?
  2. whats actually going on, how do I make this work?

Thanks

The issue was that the template cover passes a tilt property called tilt and not tilt_position, sigh.

So i wanted something more like this:

cover:
  - platform: template
    covers:
      dining_room_blind:
        friendly_name: "Dining Room Blind"
        set_cover_tilt_position:
          service: script.dining_room_blind_set_cover_tilt_position_if_windows_closed
          data:
            tilt_position: "{{ tilt }}"