How do I write parameters/fields for automation script

Hi,

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

This is what I have:

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

  sequence:
    # get the current position
    - service: cover.get_position
      entity_id: "{{ X }}"
      data:
        # 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:
      condition:
        # Check the requested position
        condition: numeric_state
        entity_id: "{{ X }}"
        attribute: position
        below: "{{ target_position }}"
        above: "{{ target_position }}"
      action:
        # 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 bard.google.com 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.