Updated on: August 10th, 2025
All Code can be found here: https://github.com/benwittbrodt/Metra-Tracker
This was part 2 of project to help figure out which train to take in the morning to get to work. I have the luxury of living close to either the regional METRA rail here in Chicago or the CTA ‘L’ trains. The problem was that the METRA is a nicer trip into the city and faster but the station is further away so if the trains are delayed I would end up going further from home to catch it but end up waiting longer than I would have if I just took the slower CTA train.
CTA’s API for the trains is a bit more straightforward than METRA so I built a basic sensor in home assistant for my specific line and stop but needed a more comprehensive solution for METRA.
My solution was a custom integration published in HACS (Home assistant community store) which allows people to add new integrations that aren’t part of the core Home Assistant package. The integration builds 3 entities, one for each of the next 3 trains to arrive at your chosen station and will also give the estimated arrival at your station and arrival at the destination station you select in the setup. Each time a train departs your chosen station the #1 entity gets replaced with #2’s train, and #2 gets replaced with #3’s train and the cycle continues. So #1 is always the very next train to arrive.
Along with the times for the train you can also see details from the trip in the entity attributes
A look at the implementation of this is below – I set up an automation to take the state of these integrations and the CTA sensor and send a notification to my phone at 7:25am on days that I travel in to the city so I can have a very simple choice on what train I take.