Trigger variable is empty in template sensor

I would like to create a simple template sensor which updates the state based on by what it was triggered. According to the documentation, there should be a variable trigger and trigger.idx should give me the trigger index.

However, this variable is empty. The resulting text is always “No mail yet today (Debug, triggered by )”
regardless of the trigger.

What am I doing wrong?

template:                                                                                                                                                                        
  - trigger:                                                                                                                                                                     
    - platform: state                                                                                                                                                            
      entity_id:                                                                                                                                                                 
        - binary_sensor.letter_box_contact                                                                                                                                       
      to: "off"                                                                                                                                                                  
    - platform: time                                                                                                                                                            
      at: "00:00:00"                                                                                                                                                                                                                                                                                 
    sensor:                                                                                                                                                                      
      - name: Mailbox                                                                                                                                                            
        state: >-                                                                                                                                                                
          {%- if trigger.idx == 0 -%}                                                                                                                                            
          Received:{{ states.binary_sensor.letter_box_contact.last_changed }}                                                                                                    
          {%- else -%}                                                                                                                                                           
          No mail yet today (Debug, triggered by {{ trigger.platform }} )                                                                                                                              
          {%- endif -%}

Hello,

I had the same issue, the correct syntax is :

{%- if trigger.idx == '0' -%}

Regards