PRT Monitor
Twitter bot ๐ค written in Python ๐ that monitors WVU's PRT.
Dependencies:
- Coffee โ๏ธ
- Twython
Background
PRT Monitor is a Twitter bot that tracks the uptime/downtime of WVUโs PRT and helps users stay updated on whether it is running. The PRT is an elevated tram car system for public transit and is located throughout Morgantown, WV. It is used by locals and students to get around campus or the city itself. The goals of the system were to minimize traffic and provide an alternative public transportation option. Morgantown, like much of West Virginia, has unique geographical and weather limitations, making a non-traditional public transit system necessary.
Check out this cool historical snapshot of the PRT here.
Despite how effective the PRT is in Morgantown, it is not perfect. There are only 5 stations to board the PRT, so commuters need to travel some distance before or after their PRT ride to complete their trip. It is not uncommon to walk about 15 minutes to the nearest station, only to find out that the PRT is temporarily out of service because of weather. Before PRT Monitor existed, the best way to find out whether the PRT is running was by following the official twitter account or checking the status on the website, but these sources do not report each outage. Typically they only announce an outage if it is expected to be longer than 30 minutes of downtime.
PRT Monitor will report any outage as long as it lasts at least 5 minutes, and because it is a twitter account, users can receive push notifications instead of manually checking a webpage. The goal of the project is to help commuters save time in their busy schedules by letting them know about service outages before they get to a station.
Details
The project is entirely written in python and is running on a Raspberry Pi 3 Model B in headless mode. The scripts are triggered by CRON and I use a Twitter App for the tweeting functionality. You can see PRT Monitor in action on Twitter.
What does it do?
PRT_Monitor.py
Every 5 minutes this requests the PRT status from a JSON feed. If the status is different than the last status, then it will record the new status in a CSV file and tweet the new status.
So this doubles as both the twitter bot and the โmonitorโ at the same time.
PRT_Analysis.py
This script is executed every Friday at 5pm. And here is what it does:
- Adds up how many times the PRT has gone down during the semester.
- Calculates the amount of time the PRT was out of service (doesnโt include when the PRT is closed).
- Calculates the amount of time the PRT was working normally.
- Calculates the percentage of uptime.
- Tweets the stats in a pretty format.
Youโre welcome to check my math (was never particularly good at it). ๐ฌ
PRT_Prediction.py
This one is just an idea I had. It doesnโt work yet. But I was thinking that I could predict outages based on historical data and weather.