Hi, i would try to make an train delay script with the dutch railway NS integration. when i execute the script i get an error message:ValueError: Template error: strptime got invalid input 'unknown' when rendering template '{{ (strptime(actual_time, "%H:%M") - strptime(planned_time, "%H:%M")).total_seconds() / 60 }}' but no default was specified
i have tried to add now() to the actual_time and planned_time but with no succes can somebody help me to made this script work when there is an train delay? the default message is working correct.
here is my script:
alias: Train delay
sequence:
- variables:
planned_time: >-
{{ states("sensor.train",
"departure_time_planned") }}
actual_time: >-
{{ states("sensor.train",
"departure_time_actual") }}
delay: >-
{{ (strptime(actual_time, "%H:%M") - strptime(planned_time,
"%H:%M")).total_seconds() / 60 }}
- choose:
- conditions: "{{ delay > 0 }}"
sequence:
- service: notify.mobile_app_iphone_van_willem
data:
message: The train is delayed by {{ delay }} minutes
data:
push:
sound:
name: default
critical: 1
volume: 1
- if:
- condition: state
entity_id: person.willem
state: Thuis
then:
- service: sonos.snapshot
data:
with_group: true
entity_id: media_player.studeerkamer
- service: media_player.volume_set
data:
volume_level: 0.11
target:
entity_id: media_player.studeerkamer
- service: tts.cloud_say
data:
cache: false
entity_id: media_player.studeerkamer
language: nl-NL
message: >-
De Trein heeft een vertraging van {{states('delay')}}
minuten
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- service: sonos.restore
data:
with_group: true
entity_id: media_player.studeerkamer
default:
- service: notify.mobile_app_iphone_van_willem
data:
message: The train is on time and leaves on {{ actual_time }}
mode: single