Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is missing for profile "Deutsche Bahn" #21

Open
Marcus-Schubert opened this issue Jan 8, 2025 · 20 comments
Open

Data is missing for profile "Deutsche Bahn" #21

Marcus-Schubert opened this issue Jan 8, 2025 · 20 comments
Labels
DB Related to DB profile

Comments

@Marcus-Schubert
Copy link

Since today at roughly 11:20 (CET) Hafas is not able to pull any data from the profile "Deutsche Bahn". Existing entities just show "unknown".

If I try to create a new entity, I always get the error "invalid_station" no matter which stations I'm trying.

Looking at the logs, I can only see this line which seems to be related (note: I removed the name of the stations):
2025-01-08 11:23:50.357 WARNING (MainThread) [custom_components.hafas.sensor] Couldn't fetch journeys for sensor.[xxx]_to_[xxx]: Expecting value: line 1 column 1 (char 0)

Let me know, if you need any more details.

@paschmal
Copy link

paschmal commented Jan 8, 2025

I'm having the same issue.

@akloeckner
Copy link
Owner

akloeckner commented Jan 8, 2025

I just checked, and I also have the same issue... It seems to be affecting DB only.

@wolritz
Copy link

wolritz commented Jan 8, 2025

same issue here...

@lomtaslipptas
Copy link

same

@kaffeetrinker71
Copy link

Seems there is a API Problem.
https://bahnvorhersage.de doesn't work either.

@akloeckner
Copy link
Owner

Hmm. Their front-end warning commit is commented with "Warning as mgate.exe was shut down". I think, pyhafas also uses mgate. So, I think, this will need upstream fixing...

@Marcus-Schubert
Copy link
Author

@akloeckner That's unfortunate to read, but thank you for diving deeper.

@heschdy
Copy link

heschdy commented Jan 10, 2025

Seems there is a API Problem.
https://bahnvorhersage.de doesn't work either.

It seems like they solved the issue:

https://gitlab.com/bahnvorhersage/bahnvorhersage_frontend/-/commits/main

@Alex9779
Copy link

It seems like they solved the issue:

https://gitlab.com/bahnvorhersage/bahnvorhersage_frontend/-/commits/main

Unfortunately I don't find any hint what they did, the commit just removes the banner and the other repo has also no commit changing anything relevant...

@heschdy
Copy link

heschdy commented Jan 10, 2025

It seems like they solved the issue:

https://gitlab.com/bahnvorhersage/bahnvorhersage_frontend/-/commits/main

Unfortunately I don't find any hint what they did, the commit just removes the banner and the other repo has also no commit changing anything relevant...

Me neither...

But found something on another repository about the vendo client:

https://github.com/emmaboecker/railboard-api

Here is the commit:
emmaboecker/railboard-api@f13d9cf

@Alex9779
Copy link

Alex9779 commented Jan 10, 2025

Just to have this here explained, this and several other public transport apps use pyhafas which relies for "Deutsche Bahn" on mgate according to this line.

This service is not available right now or anymore, some say it has been shutdown forever. So basically pyhafas's DB integration is broken.

@Alex9779
Copy link

But found something on another repository about the vendo client:

https://github.com/emmaboecker/railboard-api

Reading the docs of that repo shows that it has three endpoints implemented, none of them was the mgate stuff, there is iris, ris and vendo, also explained which one is good for what. It seems the structure of vendo changed recently so there had to be some adjustments.

Question is, is there a ready-to-use python lib for one or all of these APIs especially with the needs of this project...

@akloeckner akloeckner pinned this issue Jan 10, 2025
@Alex9779
Copy link

Ok after some research I found the best starting point is DB API Marketplace.

Doing a code search on Github with "apis.deutschebahn.com" you find some code accross multiple projects and languages.

As far as I can tell there are and have been several systems for getting the information but RIS seems to be the only real supported one. But complete RIS is not public and costs money.

There is one "public" API accessible: "Timetables", which should give the needed information but you still have to register with DB, the best project I found with some documentation how to do this is Deutsche Bahn API.

In the search result you also find projects with the needed keys which should not be public so...

So IMHO "Deutsche Bahn API" could be used as a base but I don't think it does fit this project as all other clients are also mgate based and a new "DB Departures" component should be developed but which will then reuiqre each user to register their own account with DB. There are other components which require something similar so...

@akloeckner
Copy link
Owner

That's what they're doing over at the deutschebahn integration: FaserF/ha-deutschebahn#60

@Alex9779
Copy link

Ahh that is where I initially came from, used the core component until banned because of web-scraping then the custom but was unreliable so switched to yours...
Maybe you just focus on the local public transport and just remove the DB stuff... no idea what I would do, think that would depend on my own needs...

@mk-lp
Copy link

mk-lp commented Jan 11, 2025

It seems like they solved the issue:
https://gitlab.com/bahnvorhersage/bahnvorhersage_frontend/-/commits/main

Unfortunately I don't find any hint what they did, the commit just removes the banner and the other repo has also no commit changing anything relevant...

They moved their backend integration to https://github.com/public-transport/db-vendo-client/pkgs/container/db-vendo-client

The changes are not in the frontend but in the backend - that's why you don't see it in the repository above.

Please check here: https://gitlab.com/bahnvorhersage/bahnvorhersage

Cheers!
Marcus

@wolritz
Copy link

wolritz commented Jan 12, 2025

Found a easy solution for VVS in Stuttgart. There is a Web-Service (https://www.vvs.de/services/efaaufhp/). I integrated the service with a ifram-card.

type: iframe url: >- https://dfisite.vvs.de/?default_stop=de%3A08119%3A1701&time_offset=3&zoom_factor=0.4&rows=5&show_messages=1&show_position=1&lpm=400&lang=de aspect_ratio: "16:7"

Works for me.

@akloeckner
Copy link
Owner

So, it appears the DB HAFAS endpoint will likely stay shut down, as the DB mobile apps use a different API now. Some relevant links can be found in the upstream issue: FahrplanDatenGarten/pyhafas#51 (comment). There is also a first hint, what might need to be done to enable the new "vendo" API in pyhafas.

I am afraid, this is more than I am able to do myself, currently. So, unless we find a volunteer to fix pyhafas (or create a new library to replace it), the DB profile will likely stay broken. 😞

@FaserF
Copy link

FaserF commented Jan 21, 2025

I am not sure how db-infoscreen fetches the data from DB (havent had a look into the source code, but it's still based on HAFAS), but it works great. I have published a new Homeassitant Integration using this.

Maybe the data source can also be interesting for this project.

@kRew94
Copy link

kRew94 commented Jan 22, 2025

I am not sure how db-infoscreen fetches the data from DB (havent had a look into the source code, but it's still based on HAFAS), but it works great. I have published a new Homeassitant Integration using this.

Maybe the data source can also be interesting for this project.

Thank you for this integration, for anyone interested, I build a template sensor which gives the information for a destination in the format "HH:MM +DELAY", here is the code:
{% set departures = state_attr('sensor.train_departures','next_departures') %} {% if departures %} {% set <destination> = departures | selectattr('destination','search','<destination>') | list | first %} {% if <destination> %} {{ <destination>.scheduledDeparture ~ ' +' ~ (<destination>.delayDeparture|int) }} {% else %} No departure information {% endif %} {% else %} No data {% endif %}

Note: you need to change the to the one you wand and is available in the attributes of the sensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DB Related to DB profile
Projects
None yet
Development

No branches or pull requests