Hi All,
Will it possible that this intergration will get a update so you can add a time space?
so you get trains after given time for example 30minutes
Maybe also with more results in a list.
Hi All,
Will it possible that this intergration will get a update so you can add a time space?
so you get trains after given time for example 30minutes
Maybe also with more results in a list.
This might be better in Feature Requests. But does sound useful.
Because youâre here, if you wanted, you can make your own template sensor that shows the ânextâ scheduled if time is less than 30 minutes of the current scheduled. But youâll lose all of the useful attributes as they only apply to the current scheduledâŚ
# Example configuration.yaml entry
sensor:
- platform: template
sensors:
# Template sensor to show the next train > 30 minutes from now from X to Y.
future_departure_x_y:
# Follows the nederlandse_spoorwegen sensor for X to Y
entity_id: sensor.X_Y
friendly_name: "Train from X to Y"
# For each update, if the next train is < 30 minutes (60*30 seconds) away, show the 'next' departure instead.
value_template: >-
{% if (as_timestamp(now()) - as_timestamp(states('sensor.X_Y')) < 60*30 %}
{{ state_attr('sensor.X_Y', 'next') }}
{% else %}
{{ states('sensor.X_Y') }}
Now you can use both sensors to make decisions. Oftentimes you really want the current train infoâŚespecially if youâre on your way to the train or are close by. But you want to make automations based on the next train you can actually catch. If you were to just search for all trains > 30 minutes, youâd lose all of the useful information for the train you are trying to catch and have to open a different app to find out the updated info. So with this approach, you can use both!
Thank you for the code. I will try this when iâm at home.
I will do a feature request on Github
Hi,
I get a error in the template (developer tool). I cant find it. blind for the error I guess⌠haha
Error rendering template: TemplateSyntaxError: unexpected â}â, expected â)â
{% if (as_timestamp(now()) - as_timestamp(states('sensor.asdz_utr')) < 60*30 %}
{{ state_attr('sensor.asdz_utr', 'next') }}
{% else %}
{{ states('sensor.asdz_utr') }}
Ah, I see. The sensor is returning just HH:MM time, not a timestamp. Well, that and syntax error with wrong number of parensâŚand no endifâŚ
Will have to do some dang conversions. Your favorite ones will doâŚIâm just going to use a ptime struct and math.
# Convert current time (ct) and next departure (nt) into
# a ptime object and do some math to determine difference
value_template: >-
{% set cur = strptime((as_timestamp(now()) | timestamp_custom('%H:%M')), "%H:%M") %}
{% set nt = strptime(states('sensor.asdz_utr'), "%H:%M") %}
{% if (nt.hour - cur.hour)*60 + (nt.minute - cur.minute) < 30 %}
{{ state_attr('sensor.asdz_utr', 'next') }}
{% else %}
{{ states('sensor.asdz_utr') }}
{% endif %}
I still get a error. But it seems it donât get all the trains from the API.
To bad im not a good developer. I see in developer tool to follow information for the sensor:
going: true
departure_time_planned: 10:26
departure_time_actual: 10:26
departure_delay: false
departure_platform_planned: 2
departure_platform_actual: 2
arrival_time_planned: 10:48
arrival_time_actual: 10:48
arrival_delay: false
arrival_platform_planned: 18
arrival_platform_actual: 18
next: 10:40
status: normal
transfers: 0
route: Amsterdam Zuid,Utrecht Centraal
remarks: null
attribution: Data provided by NS
friendly_name: asdz-utr
icon: mdi:train`
I have access to the API Portal of NS (im working for NS) but you can register also external. And then you have access to the âReisinformatieâ Lots of possible api examples to show things.
Would be so nice if someone can rebuild this integration with lots of more possible options
I made a pull request with exactly this.
And 1,5 year after the pull request, nothing happened because changes are not allowed until the whole integration has been rebuilt
This offset would be very nice, because itâs kind of useless right now. At 10:06 now I see ânext train is at 10:05â until it updates. Would be nice if you can create automations based on the train in an hour or anything, without messing with the config files everytime
Any update on this?
The official docu still doesnât list an offset and whenever i tried {% conditional code it always did not work
And in its current form the Integration is pretty useless as it mostly shows trains that are just departured and not those who are going to and i would like to add a couple of minutes of walking distance to it, otherwise i dont see how this is useful.
This feature is highly needed. In itâs current form the integration is quite useless.
What does it take to get the rebuild going?
Iâve tried replacing the time after time: with a template sensor that has the time offset built in, but I just get an error.
Hi there everybody,
Iâm quite new to Home Assistant but would love to have my train time table in the morning. I tried everything to add the sensor in the yaml.config but it keeps not accepting it. I tried to copy the example of the intergration, but also that itâs not working.
I do have the api key, and in the yaml.config there are already a few sensors. Iâm very helpless. Hope anyone can help out.
Thanks in advance!
is there any life in this card⌠i can;t get it to work either