The "Pendler Info" is another personal project of mine, which came to life due to a personal need of myself. Which I took as an opportunity to learn some new technologies while solving a problem I'm facing in my day-to-day life.
I'm traveling cross country a couple of times a week, since I work in the Netherlands, while I still live in Germany. The Public transportation in my area might not be the greatest, but it's sufficient enough for me to use it most of the time to get to work and back. However, one pitfall which annoyed me more than once is its reliability in combination with their rather dump apps and general notification system.
It takes me around 15minutes to get to the train station, while the train needs only ~11minutes from the last town in Germany where it's supposed to take a longer halt. My work town is also the end stop for both lines going there. The problem which I was constantly facing is that I checked their app, which said the train would be on time at the station, but when I arrived at the station the connection was canceled. Sometimes I had to wait only for half an hour for the next train, but not infrequently I stood there for hours waiting to be informed about the next cancelation minutes before the planned departure. Time, I could have just spent in the office instead, to lower my pile of work.
This is something which kept bothering me, so at one point I started to think about a solution for this, while I was obviously waiting again in the freezing rain at the station...
The problem behind this is actually very mundane, but also not that easy to fix. My work town is like already mentioned the last stop on both lines going there. They are alternating and sharing the same track. This means the trains going there need to go back to free up the tracks for the following train, usually coming from the other line. Which is not as straightforward as it may sound. Our German trains apparently get grumpy if they are supposed to change their traveling direction back home & if the computer says no, you are stuck at the station for a while...
Furthermore, trains will just stay in Germany, when they are delayed more than the usually ~11minutes they would need for the drive. Since they count every delay below 4minutes not even as delay, that's not as infrequent either.
Well, that's nothing I can influence or? So what's the problem I can solve here? The notification about this, to use my time more efficiently. If I know the next train won't come, I can just stay in the office and use my time more efficiently.
Which lead me to the creation of the "Pendler Info" project. It's a small web application, which allows you to enter your start & end destination, that you are usually traveling. "pendeln" is German and is used if you are constantly traveling to & from a given location e.g. to work. It will then track if your connection might get canceled or is delayed and will inform you via your desired channel of choice. For me, it was giving me a heads-up via Alexa in the morning before I go to the station and short to the point telegram messages while I'm in the office. Before I have to leave.
But why & how?
Well first off, our train company actually has the information, if the train will go or not early enough most of the time. They are just not processing & presenting it correctly. As I noticed at one point that I could actually make a very good prediction if my train would go or not. If I check both lines in the opposite direction via the app. However, this takes so long in the app, that I often just run for the train instead. Just to notice I hurried for nothing. heh?
Well like I mentioned earlier the trains which bring me home, are actually just changing their direction in our town. So if a train never gets there, it can obviously not depart from there. However, the train app doesn't know this. Even if a train never departures from the origin of the line, it will tell me it's on time. The entire 2 hours it would usually require for that route. Until the point, it's supposed to depart here again. If I know this upfront, I can just take a train earlier, or later.
Okay, but how do I get the data & process it? Well, that was quite a hassle. For that, you have to know how our German Train companies are structured. For most people, it's just "Die Bahn", one company. However in reality it's a convolute of many companies. The national or regional trains, most of them are individual companies. All with their own IT infrastructure and different API sets. Which makes it really annoying to work with. The sad irony behind this is that to my knowledge all these APIs are actually coming all from the same software developed from a third party. Just for the sake of, confusion?, everyone implements them differently. They even name train stations and towns different, depending on which API you ask...
If you are up from some laughs, there are some nice CCC talks about this as well:
(Whish I would have found those before I started to go through this API nightmare myself 😭)
So in the end it's quite simple I "just" use their public APIs which their app is using as well. I'm using an abstraction layer around them to make it more fluent to use and keep my internal code more readable tough. And so far this works quite flawless for quite a while now.
Since I said I'm always trying to use these projects to also learn something new (and this API is something I would rather consider IT Stone-age than new). I took this project as a chance to have a deeper look at Google's Maps & Places API, which allowed me to embed some nice visual content within the dashboard. Giving users a bit more eye-candy and visual information about the town they travel to.
In addition to that, I played around with Laravel Notification System and Amazon's Alexa SDK to deliver the related delay & cancelation messages to the users.