GTFS-Realtime coverage checker: does an open GTFS-RT feed carry real-time data for your lines at your stop? One-shot or MQTT-publishing watcher
pip install somestuff-oepnvstuff Copy PIP instructions
Validate whether an open GTFS-Realtime feed actually carries real-time data (delays / actual times) for specific transit lines at a specific station, either as a one-shot check or as a long-running watcher that publishes its findings to MQTT.
Open-data GTFS-RT aggregators (such as gtfs.de) merge whatever the transit agencies deliver. For many rural and suburban lines that is schedule only: the feed exists, but your lines never get actual times. This tool answers "is there real realtime for my lines at my stop?" before you build anything on top of it. The defaults (station Blankenese, lines 1/12/22/189) are just defaults; every parameter is overridable via CLI option or OEPNV_* environment variable.
Only mqtt_bridge.py imports mqttstuff; the core runs without a broker. Logging (loguru, with an intercept for stdlib logging, e.g. requests and paho-mqtt) and the startup banner are shared via somestuff.oepnvstuff.
pip install somestuff-oepnvstuff somestuff is a PEP 420 namespace; the package is imported as somestuff.oepnvstuff and shares the namespace with the other somestuff-* distributions.
Console script and module invocation are equivalent:
oepnv-check-realtime python3 -m somestuff.oepnvstuff.check_realtime One-shot check (human-readable report, the exit code summarises the result):
oepnv-check-realtime oepnv-check-realtime --station "Blankenese" --lines "286,488" Both feed options also accept local file paths (handy for tests): --static feed.zip --realtime snapshot.pb.
Exit codes: 0 realtime found for at least one line (or watch ended cleanly), 2 schedule found but no realtime (or stale abort), 3 no matching stops or trips in the static feed, 1 technical error.
# which stops would match? Reads only stops.txt plus one stop_times pass and # shows coordinates, serving lines (incl. agency) and directions per stop oepnv-check-realtime --show-stops # several stations at once, ';'-separated (stop names contain commas and spaces) oepnv-check-realtime --station "Blankenese;Ellerbek" --lines "1,189,195" # same-named stations in different towns? GTFS has no postal codes, so filter # geographically by 'lat,lon,radius_km'; applies to the check itself as well. # Several areas are ';'-separated and OR-combined. oepnv-check-realtime --show-stops --station Blankenese --near 53.5633,9.8144,2 oepnv-check-realtime --near "53.5633,9.8144,2;53.647,9.892,3" Watch mode # poll loop, one compact status line per cycle oepnv-check-realtime --watch --interval 180 # exit with code 2 once the feed goes stale (lets a supervisor restart it) oepnv-check-realtime --watch --stop-on-stale Departures # next N departures per line+direction, with realtime delay # ("1 Richtung S Rissen: in 2 min (+80s)") oepnv-check-realtime --watch --departures --departures-count 2 --departures-horizon sets the look-ahead window in hours (default 48).
oepnv-check-realtime --watch --mqtt --mqtt-host broker.example.org mosquitto_sub -h broker.example.org -v -t 'oepnv/#' With base_topic at its default oepnv:
Everything is published with retain=False: the broker keeps no last value and subscribers see the live stream only. A late subscriber waits at most one poll interval for the next status/departures cycle.
Precedence: CLI option > real environment variable > ./oepnv.local.env (current working directory) > oepnv.local.env next to the installed check_realtime module. Both env files are auto-loaded via python-dotenv and never override variables that are already set. An example env file ships in the repository, not in the wheel: https://github.com/vroomfondel/somestuff/tree/main/somestuff/oepnvstuff/
OEPNV_INTERVAL is the only lever on data volume, for a reason that is not obvious:
Volume therefore depends only on how many feed versions are fetched, not on how often you poll. Polling faster than the rebuild costs nothing (the extra polls are 304s); polling slower is the only saving. Measured over 360 cycles: about 44 MB per version (min 29, max 53).
OEPNV_MAX_AGE does not have to grow with the interval: age is now - feed_ts at fetch time and stays below 60 s because of the per-minute rebuild, regardless of the interval.
Configure everything via env in the Deployment. Point OEPNV_CACHE_DIR at a persistent volume so pod restarts reuse the large static zip via 304, and combine OEPNV_WATCH=1 with OEPNV_STOP_ON_STALE=1 so a dead feed exits with code 2 and the kubelet restarts the pod. A ready-made Deployment (watch + MQTT + cache volume) and a Secret example for the broker credentials are in the repository, not in the wheel: https://github.com/vroomfondel/somestuff/tree/main/somestuff/oepnvstuff/
The monitor knows nothing about consoles or brokers: it dispatches typed results to registered handlers. Add your own the same way the console report and the MQTT bridge do:
from somestuff.oepnvstuff.gtfs_realtime import RealtimeFetcher from somestuff.oepnvstuff.gtfs_static import build_index, obtain from somestuff.oepnvstuff.monitor import CycleResult, RealtimeMonitor index = build_index(obtain("https://download.gtfs.de/germany/nv_free/latest.zip", ".gtfs_cache"), ["1", "189"], "Blankenese") monitor = RealtimeMonitor(RealtimeFetcher("https://realtime.gtfs.de/realtime-free.pb"), index, interval=180.0, stop_on_stale=True) def my_handler(cycle: CycleResult) -> None: for line, status in cycle.per_line.items(): print(line, status.updates, status.avg_delay) monitor.add_cycle_handler(my_handler) # every completed cycle monitor.add_alert_handler(print) # each new service alert (deduplicated) monitor.add_stale_handler(print) # edge-triggered on going stale monitor.add_error_handler(print) # fetch errors (loop keeps running) raise SystemExit(monitor.watch()) # or: monitor.check_once() Handler exceptions are logged and swallowed, so one misbehaving sink cannot kill the poll loop.
The defaults are the free, registration-less feeds from gtfs.de (CC BY-SA 4.0, https://gtfs.de/de/open-data/): static germany/nv_free/latest.zip (German regional transit) and realtime-free.pb (TripUpdates + ServiceAlerts). Any other GTFS / GTFS-RT pair works via --static / --realtime, for example an agency's own feed if the open aggregate turns out to lack your lines (for HVV territory: Geofox-GTI).
GNU Lesser General Public License v3 (LGPLv3)
gtfs gtfs-realtime monitoring mqtt oepnv public-transport transit
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




