As a student who lives a little far from campus and whose tuition includes free bus rides on the local public transit system (Port Authority), naturally I use them on a daily basis to get to classes. Port Authority also recently began providing an awesome service called Truetime that tracks where busses are in real time, and predicts when they’ll arrive at certain stops.
So, instead of checking chrome on my phone every time I leave, it would be conveneint to have the arrival times passively displayed somewhere. My first thought was to use the truetime developer api to serve an rss feed that can then be displayed using any rss feed service that can be configured to update relatively frequently. So I wrote a simple rss feed that’s served using flask and Feedgenerator:
Now, after spinning up a small t2.micro instance on AWS and installing the code above to start on boot, I have an rss feed available for any given stop id (the bus stops are numbered and labeled).
What can you do with an rss feed? Well, I chose an RSS feed because it’s simple, easy to parse, and is a pretty standard way of transmitting this type of basic information. In my case, I want to have bus arrivals displayed passively on my phone in the notification tray. This seems like a job for Tasker!
With tasker, it becomes relatively easy to a) create a task that will run every few minutes only when I’m home or near home, b) get/parse the rss, and c) create an updating notification that neatly displays the arrival times. First, I wrote a task that would produce the desired notification. This involved running a HTTP Get request, then doing a search/replace on a couple regex’s to turn the feed into a csv format that can be passed to AutoNotification (a tasker plugin) to diplay as a table. The details of how I set this up, are below:
Then, just tie the task to a profile that activates near home and every few minutes, and you’re good to go!