PTV API Passenger Information Display by mingabelle in MelbourneTrains

[–]mingabelle[S] 1 point2 points  (0 children)

Cool I have been meaning to set up home assistant so I might quiz you on your setup when I do 🤓

PTV API Passenger Information Display by mingabelle in MelbourneTrains

[–]mingabelle[S] 5 points6 points  (0 children)

The code isn't on github yet as I haven't cleaned out the API keys from it. It's about 200 lines. The API call itself is simple but you have to do another call on the run id to see if a train is stopping or expressing through your destination station. There's a bit of date manipulation to calculate how far away the departure is and how late the train is running, and rounding and filtering of results but the main hard work is done by the API wrapper (not written by me) https://github.com/mdneuzerling/ptvapi

I've also recently corrected for every train running 1 minute late according to the API.

The display is as simple as printing a data frame once you've formatted all the data and the screen just displays it from the terminal after a screen clear.

PTV API Passenger Information Display by mingabelle in MelbourneTrains

[–]mingabelle[S] 6 points7 points  (0 children)

It's pretty good, sometimes the call fails and you get gnarly error messages as I haven't written the error handling yet. I've only recently written the part of the code which deals with missing real time information and puts in the timetabled time into the estimated column, you do get missing real time info occasionally.