Python script not executing

Hi, i have made an automation that triggers an python script. Only in the log file i get that the actual_time and planned_time not are defined. what am I doing wrong?

Python script:

actual_time = data.get(actual_time)

planned_time = data.get(planned_time)

delay = (datetime.strptime(actual_time, '%H:%M') - datetime.strptime(planned_time, '%H:%M')).total_seconds() / 60

if delay > 0:
    message = f"The train is delayed by {int(delay)} minutes."
else:
    message = "The train is on time."

service_data = {
    'message': message,
}

hass.services.call('notify', 'notify.mobile_app_iphone', {service_data})

Automation:

alias: Notify train delay
description: ""
trigger:
  - platform: template
    value_template: "{{ states.sensor.train_delay.attributes.going}}"
condition: []
action:
  - service: python_script.notify_train_delay
    data:
      planned_time: |
        {{ states("sensor.train_delay", "departure_time_planned") }}
      actual_time: |
        {{ states("sensor.train_delay", "departure_time_actual") }}
mode: single

And you’ve added

python_script:

To your configuration.yaml file ?

Yes, i have enabled it in the configuration.yaml

It seem that the variables actual_time and planned_time are set but that data.get not works correctly i tink?