Script for Roller Blinds

Hello everyone,
I’m currently working on a YAML script for Home Assistant but have encountered an error that I can’t seem to resolve. I would greatly appreciate it if someone could help me identify and fix the issue.
I always get the Message malformed: extra keys not allowed @ data[‘trigger’]?

alias: "Sends stop command to roller blinds"
description: "stops roller blinds after time delay"
fields:
  entity_id:
    description: "Entity-ID of Blind"
    example: "cover.rl_mqtt_cover"
  time_in_seconds:
    description: "time delay"
    example: 23
variables:
  entity_id: "{{ entity_id }}"
  time_in_seconds: "{{ time_in_seconds }}"
trigger:
  - platform: state
    entity_id: "{{ entity_id }}"
    to: opening
    for:
      seconds: "{{ time_in_seconds }}"
  - platform: state
    entity_id: "{{ entity_id }}"
    to: closing
    for:
      seconds: "{{ time_in_seconds }}"
action:
  - service: cover.stop_cover
    target:
      entity_id: "{{ entity_id }}"
mode: single

Hello renneburger,

That is a bit messed up.
Scripts don’t have triggers.
Automations don’t have fields.
You have both…
variables cannot be used in triggers, as the variables do not exist until after the trigger. you would need trigger_variables for that.

I don’t know what you are planning, but I suggest trying it first in the UI editor (there is a script one and an automation one) and getting the hang of how they look and work. Then try other things.