GTFS and/or GTFS Realtime Not Working

Two issues. One relatively easy, one that’s left me a little perplexed.

  1. (Easy) Washington Metro (WMATA) uses the header api_key to pass its API key. I was able to modify sensor.py in my installation, but wanted to let you know.
  2. (Perplexing) Installing GTFS RT breaks the Nest integration and causes other interesting errors (like the inability to restart the server from the GUI). I’m assuming you’d like me to submit the logs and report the issue through GitHub?

Hi,

I tried using @zacs great gtfs realtime integration but there were a few issues with the data feed from my provider, the most notable was that every combination of route and calendar had its own route id. Consequently the route id changes often (sometimes daily). So, I have made a few updates to @zacs integration and published it on guthub.

The changes I made were:

  • Added a “route_delimiter” configuration variable to spit route ids (my provider has a format of - so needed to remove the calendar reference
  • Added “icon” configuration variable for each service so different icons can be used for trains, ferries and buses etc.
  • Added “service_type” configuration variable to set the “Next Bus”, “Next Train” etc attribute on the sensor in HA
  • Now uses trip id to search for vehicle position rather than vehicle id (my provider didn’t always include the vehicle id)
  • Ignores stop times that are in the past (my transport provider has an annoying habit of including services that finished hours ago in the realtime feed :frowning:)
  • Added some extra logging.

The integration is installable via HACS.

3 Likes

I can’t get seem to get it to work with this data set.

trip_update_url: 'https://data.calgary.ca/api/views/gs4m-mdc2/files/be59ec25-b97a-46ca-9297-4591fc0c2816?filename=tripupdates.pb'
vehicle_position_url: 'https://data.calgary.ca/api/views/am7c-qe3u/files/90adc2ee-dd09-4efd-90af-7c38d89466c9?filename=vehiclepositions.pb'
route_delimiter: '-'
departures:
- name: "test stop"
  route: '3'
  stopid: '6662'

It always returns - as the output. anyone help?

DEBUG:__main__:...Feed Route Id 3 changed to 3
DEBUG:__main__:......Stop: 6662 Stop Sequence: 1 Stop Time: 1674686100
DEBUG:__main__:......Stop: 5154 Stop Sequence: 2 Stop Time: 1674686170
DEBUG:__main__:......Stop: 8746 Stop Sequence: 3 Stop Time: 1674686234
DEBUG:__main__:......Stop: 5155 Stop Sequence: 4 Stop Time: 1674686293
DEBUG:__main__:......Stop: 8747 Stop Sequence: 5 Stop Time: 1674686347
DEBUG:__main__:......Stop: 5156 Stop Sequence: 6 Stop Time: 1674686409
DEBUG:__main__:......Stop: 7535 Stop Sequence: 7 Stop Time: 1674686474
DEBUG:__main__:......Stop: 7536 Stop Sequence: 8 Stop Time: 1674686540
DEBUG:__main__:......Stop: 7537 Stop Sequence: 9 Stop Time: 1674686600
DEBUG:__main__:......Stop: 5157 Stop Sequence: 10 Stop Time: 1674686647
DEBUG:__main__:......Stop: 5579 Stop Sequence: 11 Stop Time: 1674686700
DEBUG:__main__:......Stop: 5806 Stop Sequence: 12 Stop Time: 1674686756
DEBUG:__main__:......Stop: 5159 Stop Sequence: 13 Stop Time: 1674686847
DEBUG:__main__:......Stop: 8619 Stop Sequence: 14 Stop Time: 1674686895
DEBUG:__main__:......Stop: 8620 Stop Sequence: 15 Stop Time: 1674686948
DEBUG:__main__:......Stop: 8621 Stop Sequence: 16 Stop Time: 1674687002
DEBUG:__main__:......Stop: 5160 Stop Sequence: 17 Stop Time: 1674687060
INFO:__main__:Sensor Update:
INFO:__main__:...Name: 16W Ave N WB
INFO:__main__:...Route: 3
INFO:__main__:...Stop ID: 6662
INFO:__main__:...Direction ID: 0
INFO:__main__:...Icon: mdi:bus
INFO:__main__:...Service Type: Service
INFO:__main__:...unit_of_measurement: min
INFO:__main__:...Due in: -
INFO:__main__:...Due at not defined
INFO:__main__:...Latitude not defined
INFO:__main__:...Longitude not defined
INFO:__main__:...Next Service not defined

I couldn’t get any of the GTFS integrations to work so I used the generic REST sensor to get the data from my local public transportation’s API.

Let me know if you need help putting this together for whatever public transportation system you use!

Were you ever able to get this to work for WMATA? I am hoping to get some sensors set up in my instance.

I never was. I ended up using NodeRed to access the WMATA (and Fairfax Connector) APIs directly to get accurate arrival & departure information.

Care to test my GTFS2 integration?
Or provide me the links, with BART it does not work for realtime as it still assumes another format (that most other us)
vingerha/gtfs2: Support GTFS in Home Assistant GUI-only (github.com)

1 Like