price: null
ontime: true
departure: 12:20
arrival: 13:01
next: 12:44
next_on: 13:09
friendly_name: A to B
products: S
delay: 0
transfers: 0
icon: mdi:train
time: 0:41
Automation:
- alias: "Notify on S-Bahn delay. Home -> Work"
trigger:
- platform: template
value_template: "{{ states.sensor.a_to_b.attributes.ontime }}"
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
# how to add the condition of more than 5 minutes delay here?
action:
- service: notify.notify
data:
title: "S-Bahn is late"
message: "S-Bahn currently has x minutes delay" # how to add the value of delay here?
Thank you so much, now I get it. I also added some other conditions now to be only notified during certain time frames and when I am at home or at work:
- alias: "Notify on S-Bahn delay. Home -> Work"
trigger:
- platform: template
value_template: "{{ states.sensor.a_to_b.attributes.delay | int > 5 }}"
condition:
- condition: time
after: '06:30:00'
before: '08:30:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: device_tracker.my_iphone
state: home
action:
- service: notify.xxx
data:
title: "Zug um {{ states.sensor.a_to_b.attributes.departure }} nach XXX +{{ states.sensor.a_to_b.attributes.delay }} min."
message: "Nächste S-Bahn: {{ states.sensor.a_to_b.attributes.next }} Uhr"
- alias: "Notify on S-Bahn delay. Work -> Home"
trigger:
- platform: template
value_template: "{{ states.sensor.b_to_a.attributes.delay | int > 5 }}"
condition:
- condition: time
after: '15:30:00'
before: '18:30:00'
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: device_tracker.my_iphone
state: work
action:
- service: notify.xxx
data:
title: "Zug um {{ states.sensor.b_to_a.attributes.departure }} Uhr nach Hause +{{ states.sensor.b_to_a.attributes.delay }} min."
message: "Nächste S-Bahn: {{ states.sensor.b_to_a.attributes.next }} Uhr"
Manually triggering resulted in notifications alread, let’s see what the time brings
Hey,
thanks for the example. Is there a way to check for a specific type of train in the search. I found the attribute ‘product’ but this is only linked to the next train. If I’m only taking the RB then this will be blocked by an IC that is departing 2 minutes earlier and my delay notification is to late.
Any idea?
Can anyone post the entire config for this plugin? I can’t get it working, even with the posts in this thread. The documentation on the docs page is not so useful…
Just want to display the delay for a 9:00h clock train from Münster(Westf)Hbf to Salzbergen