Template to create 2 sensors from attribute of another sensor?

Hi community.
I use this custom component https://github.com/Emilv2/stib_mivb to get a sensor named sensor.delta_line_5 with the following attributes :

attribution: Data provided by opendata.stib-mivb.be
stop_id: '8231'
stop_name: DELTA
line_name: ERASME - HERRMANN-DEBROUX
line_type: subway
line_color: F6A90B
line_text_color: FFFFFF
messages:
  - >-
    Sommet EU. Du 21/10 10h au 22/10, SCHUMAN ouvert (côté gare SNCB). 21-22/10,
    bus 12 21 36 56 60 79 à MAELBEEK.
next_passages:
  - next_passing_time: '2021-10-19T18:58:00+02:00'
    next_passing_destination: ERASME
    waiting_time: 2
    line_number: '5'
    line_name: ERASME - HERRMANN-DEBROUX
    messages:
      - >-
        Sommet EU. Du 21/10 10h au 22/10, SCHUMAN ouvert (côté gare SNCB).
        21-22/10, bus 12 21 36 56 60 79 à MAELBEEK.
    line_type: subway
    line_color: F6A90B
    line_text_color: FFFFFF
  - next_passing_time: '2021-10-19T19:04:00+02:00'
    next_passing_destination: ERASME
    waiting_time: 8
    line_number: '5'
    line_name: ERASME - HERRMANN-DEBROUX
    messages:
      - >-
        Sommet EU. Du 21/10 10h au 22/10, SCHUMAN ouvert (côté gare SNCB).
        21-22/10, bus 12 21 36 56 60 79 à MAELBEEK.
    line_type: subway
    line_color: F6A90B
    line_text_color: FFFFFF
friendly_name: DELTA line 5
icon: mdi:subway
device_class: timestamp

I like to create one sensor with the waiting_time for the first passing metro and another one with the waiting_time for the second passing metro.
I try with this template but it don’t works:

sensor:
  - platform: template
    sensors:
      stib_line_5_delta_hdebroux_next:
        friendly_name: 'Time Line 5 Delta direction H-Debroux'
        value_template: "{{ state_attr('sensor.delta_line_5', 'waiting_time') }}"

The information you are trying to get are sub-attributes. You need to identify the key of the attribute you are looking under (i.e. “next_passages”), then the index number (where in the list of lists to look, starting at 0) and then the key of the sub-attribute. Also, you are using the legacy format for template sensors which will work, but it is best to use the current format.

template:
  sensor:
    - name: stib_line_5_delta_hdebroux_next
      unit_of_measurement: minutes
      state: "{{ state_attr('sensor.delta_line_5', 'next_passages')[0].waiting_time }}"
    - name: stib_line_5_delta_hdebroux_second
      unit_of_measurement: minutes
      state: "{{ state_attr('sensor.delta_line_5', 'next_passages')[1].waiting_time }}"

Thanks for your help.
With your config I get this error message in log:

Logger: homeassistant.config
Source: config.py:464
First occurred: 20:38:24 (1 occurrences)
Last logged: 20:38:24
Invalid config for [template]: expected dictionary for dictionary value @ data['sensors']. Got [OrderedDict([('name', 'stib_line_5_delta_hdebroux_next'), ('unit_of_measurement', 'minutes'), ('state', "{{ state_attr('sensor.delta_line_5', 'next_passages')[0].waiting_time }}")]), OrderedDict([('name', 'stib_line_5_delta_hdebroux_second'), ('unit_of_measurement', 'minutes'), ('state', "{{ state_attr('sensor.delta_line_5', 'next_passages')[1].waiting_time }}")])]. (See /home/homeassistant/homeassistant/configuration.yaml, line 170). 

Sorry about that… I left the “s” on “sensors” when it needs to be “sensor” in the current format.

Fixed in the post above.