Template not working as trigger

Hi,
I am currently working on a seemingly simple blueprint to turn off climate entities when a window is opened. I have everything neatly organized in areas in home assistant so i am trying to use them to dynamically pass the entities to the automation via the area name. The only thing that does not work yet is the trigger of the automation. Here is the Blueprint:

blueprint:
  name: Climate Pause 
  description: Automatically pauses the thermostats in an area when windows/doors are open and resumes when closed, based on the selected area.
  domain: automation
  input:
    area:
      description: Select the area where the climate entities and window sensors are located.
      name: Area
      selector:
        area: {}

    pause_delay:
      description: Time to wait before pausing the heating.
      name: Pause Delay
      default:
        hours: 0
        minutes: 0
        seconds: 30
      selector:
        duration: {}

    resume_delay:
      description: Time to wait before resuming the heating.
      name: Resume Delay
      default:
        hours: 0
        minutes: 2
        seconds: 0
      selector:
        duration: {}


variables:
  area: !input area
  climate_entities: >
    {{
      expand(states.climate)
      | selectattr('entity_id', 'in', area_entities(area))
      | map(attribute='entity_id')
      | list
    }}
  doors_windows: >
    {{
      expand(states.binary_sensor)
      | selectattr('entity_id', 'in', area_entities(area))
      | selectattr('attributes.device_class', 'eq', 'window')
      | map(attribute='entity_id')
      | list
    }}
  name_id:
    '{{ area |lower |replace('' '',''_'')
    | regex_replace(find=''[^\w]'', replace='''') ~ ''_climate_snapshot'' }}'

mode: single

trigger:
  - platform: template
    value_template: >-
      {{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}

action:
  - service: scene.create
    data:
      scene_id: "{{ name_id }}"
      snapshot_entities: "{{ climate_entities }}"

  - service: climate.set_temperature
    target:
      entity_id: "{{ climate_entities }}"
    data:
      temperature: 12
      hvac_mode: heat

  - wait_for_trigger:
    - platform: template
      value_template: >-
        {{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length == 0}}
    continue_on_timeout: false

  - service: scene.turn_on
    target:
      entity_id: "{{ 'scene.' ~ name_id }}"
  
  - service: scene.delete
    metadata: {}
    data: {}
    target:
      entity_id: "{{ 'scene.' ~ name_id }}"

Using the template editor in the dev tools i can validate that my template is working as intended. When any window is open in the area the template is true:

{%- set area = 'G182_Raum_208' -%}
{%- set doors_windows = 
      expand(states.binary_sensor)
      | selectattr('entity_id', 'in', area_entities(area))
      | selectattr('attributes.device_class', 'eq', 'window')
      | map(attribute='entity_id')
      | list 
-%}
{{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}

The only way i found to get the trigger to work is to hard code the sensors into the trigger into the blueprint, defeating the purpose of a blueprint:

trigger:
  - platform: template
    value_template: >-
      {%- set doors_windows = [
          'binary_sensor.raum_208_f1', 
          'binary_sensor.raum_208_f2', 
          'binary_sensor.raum_208_f3'
      ] -%}
      {{ expand(doors_windows) | selectattr('state', 'eq', 'on') | list | length > 0}}

I am happy about every hint

variables are resolved after triggers, not before. If you want to pass information to triggers, you need to use trigger_variables, which are very limited. In your case, most of your variables cannot be transferred to trigger_variables because they all access the state machine. Read up on limited templates. The only variable that is transferable to trigger_variables is name_id.

TLDR: What you’re trying to do is not possible.

As a sidenote, your templates that do access the state machine are performing unnecessary looping and as a result are throttled. To avoid throttling, start with a known list instead of using states or states.<domain>.

  entities: "{{ area_entities(area) }}"
  climate_entities: >
    {{ entities | select('search', '^climate.') | list }}
  doors_windows: >
    {{ entities | select('search', '^binary_sensor.') | select('is_state_attr', 'device_class', 'window') | list }}

Oh no, too bad. That means I have to create a template sensor for each room that shows me whether a window is open or not. Then at least I still have the advantage that if a sensor is replaced or added, it is dynamic and I don’t have to edit the automation.
Not having to loop through all binary_sensor’s is a good addition tho. Thanks