Control light based current weather throws error

Hi,

I’m trying to control a light’s color based on the current weather. Based upon an earlier question asking about the same (here: Light color based on weather - #2 by jocnnor) I came up with this automation:

- id: "1705835746525"
  alias: Weather Light
  variables:
    weather:
      rainy:
        color: blue
      sunny:
        color: yellow
      clear-night:
        color: navy
      cloudy:
        color: maroon
      fog:
        color: yellowgreen
      partlycloudy:
        color: indianred
      windy:
        color: darkorange
      snowy:
        color: green
      snowy-rainy:
        color: limegreen
      pouring:
        color: teal
      lightning:
        color: red
      hail:
        color: aquamarine
      windy-variant:
        color: lightsalmon
      lightning-rainy:
        color: crimson
    current_weather: "{{ state_attr('weather.home', 'forecast') }}"
  trigger:
    platform: state
    entity_id: weather.home
  condition:
    condition: template
    value_template: "{{ current_weather in weather }}"
  action:
    - service: light.turn_on
      data:
        color_name: "{{ weather[current_weather].color }}"
      target:
        entity_id: light.outdoor_light_level_light_color_on_off

However, running the automation throws this error:

Executed: October 17, 2023 at 14:04:53
Error: Error rendering data template: UndefinedError: dict object has no element [{'condition': 'partlycloudy', 'datetime': '2023-10-17T10:00:00+00:00', 'wind_bearing': 83.3, 'temperature': 13.3, 'templow': 8.0, 'wind_speed': 18.4, 'precipitation': 0.0, 'humidity': 59}, {'condition': 'cloudy', 'datetime': '2023-10-18T10:00:00+00:00', 'wind_bearing': 90.8, 'temperature': 16.7, 'templow': 7.0, 'wind_speed': 22.0, 'precipitation': 9.4, 'humidity': 58}, {'condition': 'cloudy', 'datetime': '2023-10-19T10:00:00+00:00', 'wind_bearing': 194.6, 'temperature': 20.2, 'templow': 13.3, 'wind_speed': 23.0, 'precipitation': 8.9, 'humidity': 78}, {'condition': 'rainy', 'datetime': '2023-10-20T10:00:00+00:00', 'wind_bearing': 65.5, 'temperature': 14.6, 'templow': 6.2, 'wind_speed': 28.4, 'precipitation': 16.0, 'humidity': 79}, {'condition': 'rainy', 'datetime': '2023-10-21T10:00:00+00:00', 'wind_bearing': 89.0, 'temperature': 7.1, 'templow': 4.5, 'wind_speed': 25.6, 'precipitation': 18.9, 'humidity': 93}, {'condition': 'partlycloudy', 'datetime': '2023-10-22T10:00:00+00:00', 'wind_bearing': 245.5, 'temperature': 11.2, 'templow': 5.4, 'wind_speed': 22.7, 'precipitation': 0.2, 'humidity': 72}]

And this seems to happen in the step ‘light.turn_on’. Anybody having an idea what I’m doing wrong?