hacs-hafas
hacs-hafas copied to clipboard
Data is missing for profile "Deutsche Bahn"
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.
I'm having the same issue.
I just checked, and I also have the same issue... It seems to be affecting DB only.
same issue here...
same
Seems there is a API Problem. https://bahnvorhersage.de doesn't work either.
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...
@akloeckner That's unfortunate to read, but thank you for diving deeper.
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
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...
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: https://github.com/emmaboecker/railboard-api/commit/f13d9cf7bcebd04cc3e1f437a5e1ed28ebdbe514
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.
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...
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...
That's what they're doing over at the deutschebahn integration: https://github.com/FaserF/ha-deutschebahn/pull/60
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...
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
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.
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: https://github.com/FahrplanDatenGarten/pyhafas/issues/51#issuecomment-2585761737. 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. 😞
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.
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