- Notifications
You must be signed in to change notification settings - Fork3
simple python module for the VVS and SSB API (Verkehrsverbund Stuttgart)
License
NotificationsYou must be signed in to change notification settings
zaanposni/vvspy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Fully object-oriented library to integrate theVVS API into your project.
pip install vvspy
Tip
For optimal performance on low-spec hardware such as Raspberry Pi, it is advisable to use the string values of the enum directly to avoid the overhead associated with loading the full enum.
- Detect delay in upcoming departures:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF,limit=3)fordepindeps:ifdep.delay>0:print("Alarm! Delay detected.")print(dep)# [Delayed] [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhofelse:print("Train on time")print(dep)# [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof
- Detect cancellations in upcoming departures/arrivals:
fromvvspyimportget_departuresfromvvspy.enumsimportStationarrivals=get_departures(Station.VAIHINGEN,limit=5)forarrivalinarrivals:ifarrival.cancelled:print(f"Alarm! The train at{arrival.real_datetime} has been cancelled!")# Check arrival.stop_infos and arrival.line_infos for more information
- Get complete trip info between two stations (including interchanges):
fromvvspyimportget_trip# also usable: get_tripsfromvvspy.enumsimportStationtrip=get_trip(Station.HAUPTBAHNHOF__TIEF,Station.HARDTLINDE)print(f"Duration:{trip.duration/60} minutes")forconnectionintrip.connections:print(f"From:{connection.origin.name} - To:{connection.destination.name}")
# Output:Duration: 58 minutesFrom: Hauptbf (Arnulf-Klett-Platz) - To: Stuttgart Hauptbahnhof (tief)From: Stuttgart Hauptbahnhof (tief) - To: Marbach (N)From: Marbach (N) Bf - To: Murr Hardtlinde
- Filter for specific lines:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF)fordepindeps:ifdep.serving_line.symbol=="S4":print(f"Departure of S4 at{dep.real_datetime}")
- Filter for specific platforms:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF)fordepindeps:ifdep.platform=="101":print(f"Departure of{dep.serving_line.number} to{dep.serving_line.direction} on{dep.platform_name} at{dep.real_datetime}")
See:#64
vvspy uses the python logging module. If you want to change the log level of vvspy, use the following:
importlogginglogging.basicConfig(level=logging.INFO)logger=logging.getLogger("vvspy")logger.setLevel(logging.DEBUG)
If you want to saythank you or/and support active development ofvvspy
:
- Add aGitHub Star to the project.
- Support me onKo-fi.
- vvs_direct_connect is a dockerized REST service providing departure data by aschuma.
- discord-masz - MASZ is a selfhostable highly sophisticated moderation bot for Discord. Includes a web dashboard and a discord bot.
vvspy is free and open-source software licensed undertheMIT.
About
simple python module for the VVS and SSB API (Verkehrsverbund Stuttgart)