Input_select.set_options with variable options possible?

This part to set the options of a select field works perfectly, however I want to replace 'type = 1 with the ‘type’ variable and I am struggling to find the right syntax. The method itself works in cards like “markdown” and " entities" but is it here possible? Perhaps/Likely the devil is in the syntax.

Guidance appriciated.

actions:
  - variables:
      type: "{{ states['input_select.my_contact_type'].state[:1] | int }}"
  - action: input_select.set_options
    data:
      options: |
        {{ states.binary_sensor
          | selectattr('attributes.last_advert', 'defined')
          | selectattr('attributes.type', 'eq', 1 )
          | map(attribute='name')
          | list
        }}
    target:
      entity_id: input_select.my_selection

I’m not completely sure I’m understanding your post, but I think what you want is:

actions:
  - variables:
      type: "{{ states('input_select.my_contact_type')[:1] | int }}"
  - action: input_select.set_options
    data:
      options: |
        {{ states.binary_sensor
          | selectattr('attributes.last_advert', 'defined')
          | selectattr('attributes.type', 'eq', type)
          | map(attribute='name')
          | list
        }}
    target:
      entity_id: input_select.my_selection

@Didgeridrew you understand me perfectly hence it was already in there, But for some :drop_of_blood:y reason I missed this worked and tried all the none working variations. clueless, thanks for your reaction and repointing to the proper solution.