TramTracker sensor

Hello everyone! Many of you I’m sure value the ability to pull up public transport data wherever you are. In Melbourne, where I’m from, our tram operator has a system called TramTracker that lets you view tram arrival times at any stop on the network.

I’m curious to see if anyone is interested in creating a TramTracker sensor for Home Assistant (my Python skills are basic).

TramTracker can be queried using a curl command like this:

curl -s '' --data 'StopID=[STOPID]&Route=[ROUTE]&LowFloorOnly=[FLOOR]'


  • [STOPID] is the ID of the stop you want to query
  • [ROUTE] is the route number that you want to pull out from the stop
  • [FLOOR] is a true/false asking whether you only want to have low-floor trams included

Filling in the variables — e.g. for stop ID 1422, route 19, and false for low floor only — returns JSON that contains a whole lot of stuff about the upcoming services and the line in general.

Since I only want the arrival time of the nearest tram, I pipe the result into jq to filter out what I don’t want:

curl -s '' --data 'StopID=[STOPID]&Route=[ROUTE]&LowFloorOnly=[FLOOR]'  | jq -r '.TramTrackerResponse.ArrivalsPages[] | .[0].Arrival'

Normally, a simple countdown is returned. If the tram is due, “NOW” is returned. When nothing’s running, I believe a scheduled time or a null result is returned.

I suspect a sensor for this would work like so:

  - platform: tramtracker
    name: City tram
    stop_id: 1422
    route: 19
    low_floor_only: false

Where stop_id and route are compulsory; low_floor_only and name are optional. low_floor_only would default to false.

Caveat: how to get this working for multiple routes?
If you don’t specify a route, the service returns an array for each route that passes through the stop. That means that the jq command above will tell you when the next tram on the first listed route will arrive, but that route may not necessarily have the nearest tram. This is fine for lines that only carry one route, but not so much for lines that carry more.

Hey did you manage to give this a go at all?

I’ve been wanting something similar so I can maybe set up an alert to tell me when trams are leaving in the morning.

When I get a chance I might have a look and see if I can set it up, haven’t played with python in awhile though.