Closed danielbacara closed 1 year ago
Try to use the async functionality. Works for me. For example:
async def demo() -> None:
station = await MvgApi.station_async('Ebersberg, Ebersberg (Obb.)')
if station:
departures = MvgApi.departures_async(station['id'],
transport_types=[TransportType.SBAHN])
print(station, await departures)
loop = asyncio.get_event_loop()
loop.run_until_complete(demo())
Thanks @jannikobenhoff for your reply. Indeed with async this works. However for smaller villages where only bus stations exist, e.g. Egmating, Schule
I don't get any departure,
The station is correctly identified because it returns the right station ID: {'id': 'de:09175:4212', 'name': 'Egmating, Schule', 'place': 'Egmating'}
, but there is no departure.
The return of the demo above is:
{'id': 'de:09175:4212', 'name': 'Egmating, Schule', 'place': 'Egmating'} []
where the departure list is empty
Any ideas?
OK, I have some more info. It seems as an issue with the v2 API of the MVG.
In order to get the departures of the Regional Buses
, the transport type TransportType.REGIONAL_BUS]
must be explicitly set. The demo above works now. (Using async approach of course)
@danielbacara: I was able to reproduce the Invalid station
of "Ebersberg, Ebersberg (Obb.)". The station is not listed in https://www.mvg.de/.rest/zdm/mvgStationGlobalIds which I used for validation - so I consider this list useless and will skip the validation with commit d228e42, which will be available in the next release.
@danielbacara: I was able to reproduce the empty result of departures()
for "Egmating, Schule". As you said the MVG endpoint requires to explicitly pass the transport type REGIONAL_BUS
. So in commit 0d79bfe I changed the code to pass all transport types if none is provided. Will be part of the next release, too.
Hi,
I am trying to get this package working for my station, e.g. in Ebersberg and get always
Invalid Station
.Either, there is a wrong usage from my side, MVG updated their interfaces or something else is wrong.
Below is a reproducible code, which I hope it can help investigating this issue:
The response from
MvgApi.stations()
for Ebersberg looks as followsThen using this information in the example from the README I get
Invalid station
I also tried with the station ID and got the same error.
Any thoughts?