Hello! incredible your project. Thanks for sharing it.
- Do you think there is an API key for public transport timetables in Italy?
- Can I use the same transport_nsw.py for a configuration in Italy?
Thank’s!
Hello! incredible your project. Thanks for sharing it.
@DavidFW1960 Thanks for the template, I expanded it slightly:
- platform: template
sensors:
trainmonitor_eleven:
friendly_name_template: >-
Platform 11 - {{ states.sensor.gosfordkariong.attributes.destination }}
value_template: >-
{% if is_state_attr('sensor.gosfordkariong', 'due', 'n/a') %}
No schedule found
{% else %}
{% if (states.sensor.gosfordkariong.attributes.due > 60) %}
{{ (states.sensor.gosfordkariong.attributes.due/60)|round }}hr
{% else %}
{{ states.sensor.gosfordkariong.attributes.due }}m (Next {{ states.sensor.gosfordkariong.attributes.next_due }}m)
{%- endif %}
{% endif %}
entity_picture_template: >-
{{ '/local/icons/' + states.sensor.gosfordkariong.attributes.line_name + '_train_img.png' }}
I’ve changed the py file slightly to get the next train as well, but will write a cleaner version to share over the next few days as I suspect there is a way we can reference the stops as follows:
{{states.sensor.gosfordkariong.attributes.next_train[0]}}'
Hello! Do you think there is even a way for Italian timetables? Could you please include them?
given this is written against an Australian state Government website, there will be only NSW transport info in this system.
You might be able to rework the python against an Italian system - should one exist?
probably exists but I’m not an expert in programming.
It does only work for NSW Australia as the underlying API only provides that data. You have to write different components for any new data source IF there is a public API available.
So, there is NO support for Italian transport and I also have no idea if it is even possible. Sorry, maybe someone comes up with a new sensor in the future.
Hi guys, this is still working?
Thanks!
Yes working fine
I was having problem but I solve it. There is a integration page on home-assistant.io if anyone else is interested!
Thanks david
I notice that the delay time can be seen on sites like AnyTrip, is it possible to retrieve the current eta as opposed to the scheduled eta?
I wish to track country trains which can be delayed significantly.
it reports due and a delay in the sensor
Thanks, I only just created this integration & the two trains I was watching today both had a delay of zero even though one was over 30 minutes late the other ontime.
However, now the delays are showing correctly for the next two trains.
Hey there, I am fairly new at this and I am having some trouble with getting this setup. I have the following configurations in my sensors file but I am being presented with n/a for all responses.
I wonder if anyone can assist with this?
- platform: transport_nsw
name: Next train
stop_id: "201710"
destination: "Central Station"
route: "Airport & South Line"
api_key: !secret trip_planner_api
I should also note that I have tried the following configurations and neither work.
- platform: transport_nsw
name: Next train
stop_id: "201710"
destination: "Central Station"
api_key: !secret trip_planner_api
- platform: transport_nsw
name: Next train
stop_id: "201710"
route: "Airport & South Line"
api_key: !secret trip_planner_api
All three of the above return n/a
I had a similar problem. I removed the destination attribute and get no errors. I am not sure how ‘destintation’ should be setup but is needed given some trains skip stations.
A bit late but I think I ran in to the same problem as you for another station. The stop_id you are using is for the entire station but you need to use the stop_id for the platform.
For Green Square you want to use 2015111 for the city-bound platform or 2015112 for the Macarthur-bound platform.
Also the route may need the line number as well as the name so use “T8 Airport & South Line” rather than “Airport & South Line”
I am not using the destination.
I have read through the thread and have not had luck getting a solution to show multiple trips/trains for the same journey. Anyone have any luck or able to share some example? I have tried previous code above but i’ve had no luck (quite possibly i’m too noob or possibly some of the example code suits older versions?)
Has anyone tried the fork below? It seems perfect for this but for some reason I can only get multiple trips returned on certain lines but not mine (T8 Airport & South Line). It just shows a single trip regardless which station/destination, etc.
- platform: ha_transportnsw
api_key: "xxx"
origin_id: 204310
destination_id: 201510
trip_wait_time: 0
transport_type: 1 # Only trains
return_info: medium
strict_transport_type: true
trips_to_create: 2
name: "Test"
Hi all,
discovered this one today and set it up, all (was) working… great.
Wanted to try getting bus locations so took a look at the custom component above, but didn’t do what I needed.
Since removing it, the built in integration is no longer working for me. Is it possible the custom component has edited the .py file that the built in integration uses?
Here’s the error from my logs:
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:727
integration: Sensor (documentation, issues)
First occurred: 7:54:39 PM (2 occurrences)
Last logged: 7:54:39 PM
transport_nsw: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 727, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/transport_nsw/sensor.py", line 128, in update
self.data.update()
File "/usr/src/homeassistant/homeassistant/components/transport_nsw/sensor.py", line 160, in update
_data = self.tnsw.get_departures(
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TransportNSW' object has no attribute 'get_departures'