How do I write parameters/fields for automation script


Sorry for this noob question, i’m strugling how to configure the formal parameters of a automation script.

This is what I have:

  alias: set Cover X at position Y
      description: The cover
      type: entity_id
      description: The requested position
      type: integer

    # get the current position
    - service: cover.get_position
      entity_id: "{{ X }}"
        # get the current value of `position`
        position: &position "{{ value }}"

    # Set the position of the cover
    - service: cover.set_position
      entity_id: "{{ X }}"
      position: "{{ target_position }}"

    # wait till position is reached (wifi problems, electricity problems,...)
    - while:
        # Check the requested position
        condition: numeric_state
        entity_id: "{{ X }}"
        attribute: position
        below: "{{ target_position }}"
        above: "{{ target_position }}"
        # Set the position of the cover
        service: cover.set_position
        entity_id: "{{ X }}"
        # Wait 5 seconds
        delay: 00:00:05

The only thing I get is an error when I try to save the automation script:
Message malformed: extra keys not allowed @ data[‘fields’][‘X’][‘type’]
I’ll find several solutions and they are all different. I used but it was so helpfull to say that I had to post the question here.

Don’t… the LLM AI’s are mostly horrible at HA configuration. Their datasets are often very old by HA standards and are probably at least 50% based on people posting incorrect configurations to forums like this one…

The message is telling you that type is not a valid configuration key for fields. You can find the supported configuration keys for fields in Scripts documentation. I’m guessing that you are trying to set up a Selector.