For_each attribute action in automation

I want to iterate trough the series of attributes of the weather.openweathermap sensor.
Goal is to send the forecast info to a Beckhoff ADS device.
This is what I came up with:

- id: beckhoff_dagtemperatuur
  alias: 'Stuur dagtemperaturen naar Beckhoff'
  trigger:
    - platform: state
      entity_id: weather.openweathermap
  action:
    repeat:
      for_each:
        -  states.weather.openweathermap.attributes["forecast"]
      sequence:
        - service: ads_custom.write_data_by_name
          data_template:
            adsvar: gvlHomeAssistant.stForecast[{{ repeat.index }}].Temperature
            adstype: real
            value: {{ repeat.item.temperature }}

Problem is that the automation gives me the error that temperature is no item of the for loop.
From this I’m concluding that there is a problem with the for_each part of the automation.
I think it has something to do that I don’t provide a needed index:

{{ states.weather.openweathermap.attributes["forecast"][INDEX].temperature}}

Problem is that I don’t know how to achieve this.
Tnx.

If you are using states.weather.openweathermap.attributes["forecast"] to generate the list for the repeat, you need to wrap it in "{{ }}", and you need " " around you value template:

- id: beckhoff_dagtemperatuur
  alias: 'Stuur dagtemperaturen naar Beckhoff'
  trigger:
    - platform: state
      entity_id: weather.openweathermap
  action:
    repeat:
      for_each: "{{states.weather.openweathermap.attributes["forecast"]}}"
      sequence:
        - service: ads_custom.write_data_by_name
          data_template:
            adsvar: gvlHomeAssistant.stForecast[{{ repeat.index }}].Temperature
            adstype: real
            value: "{{ repeat.item.temperature }}"