Passing an action to a seqence in a script? [ expected dictionary @ data - Got '{' ]

having an issue with a script i am writing that gets disabled in HA with this error:

Script with alias 'BETA - UNIFIED NOTIFICATION SCRIPT' could not be validated and has been disabled: expected dictionary @ data['sequence'][13]['choose'][0]['sequence'][0]. Got '{'

the error happens at this sequence step where i am triggering selected actions based on response from the notification:

# SEQUENCE 13
    - alias: "Run the actions"
      default: []
      choose:
        - alias: "Trigger: Timeout"
          conditions:  "{{ user_response.result == 'timeout' }}"
          sequence: "{{ timeout_actions }}"
        - alias: "Trigger: first_option"
          conditions: "{{ user_response.result == 'option_one' }}"
          sequence: "{{ option_one_actions }}"
        - alias: "Trigger: second_option"
          conditions: "{{ user_response.result == 'option_two' }}"
          sequence: "{{ option_two_actions }}"
        - alias: "Trigger: third_option"
          conditions: "{{ user_response.result == 'option_three' }}"
          sequence: "{{ option_three_actions }}"

the actions are fields defined in the script like:

    confirm_action:
      name: "Option 1 - Action"
      description: "Action for Opt 1"
      default: []
      selector:
        action:

and i have a check to see if they are empty in some building blocks in the sequence that set them to an empty dictionary if nothing is chosen:

# SEQUENCE 6
    - alias: Option 1 Settings
      variables:
        option_one_actions: "{{ iif(confirm_action is defined, confirm_action, {}) }}"

am i missing something obvious on how to pass an action to the sequence?

There’s your problem… using templates to build YAML config in situ like that is not supported.

As it stands, the Action selector is really only set up for use in Blueprints where the !input YAML tag handles merging the selected actions into the automation or script’s action sequence. Even in Blueprints the Action selector can require some “hacky” workarounds.

https://community.home-assistant.io/t/how-to-using-action-selectors-in-blueprints/573280

1 Like

thank you, that pointed me in the right direction…

# SEQUENCE 13
    - alias: "Run response actions"
      default: []
      choose:
        - alias: "Trigger: Timeout"
          conditions:  "{{ user_response.result == 'timeout' or user_response.result == 'notification_cleared' }}"
          sequence: 
          - repeat:
              for_each: "{{ timeout_actions }}"
              sequence:
                - choose:
                  - conditions: "{{ repeat.item.target is defined and repeat.item.data is defined }}"
                    sequence:
                      - service: "{{ repeat.item.service }}"
                        target: "{{ repeat.item.target }}"
                        data: "{{ repeat.item.data }}"
                  - conditions: "{{ repeat.item.target is defined }}"
                    sequence:              
                      - service: "{{ repeat.item.service }}"
                        target: "{{ repeat.item.target }}"
                  - conditions: "{{ repeat.item.data is defined }}"
                    sequence:              
                      - service: "{{ repeat.item.service }}"
                        data: "{{ repeat.item.data }}"
                  default:
                      - service: "{{ repeat.item.service }}"

...