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

Configuration option 'direction' does not work anymore (with db profile) #193

Open
evroom opened this issue Jan 12, 2025 · 18 comments
Open
Labels
help wanted Extra attention is needed upstream-issue The problem is in a dependency and must be solved there

Comments

@evroom
Copy link

evroom commented Jan 12, 2025

MMM-PublicTransportHafas
release v3.0.1

(git pull && npm ci where used to get the latest code)

The configuration option 'direction' does not work (anymore).
When setting the parameter with the station ID of the station adjacent to the stationID, it still shows the other directions too.

Configuration used:

  {
    module: "MMM-PublicTransportHafas",
    disabled: false,
    position: "top_right",
    header: "DEPARTURES",
    config: {
      hafasProfile: "db",
      stationID: "8004491",
      stationName: "Nürnberg-Rehhof",
      updatesEvery: 60,
      timeInFuture: 180,
      direction: "",
      //direction: "8005185", // Roth
      direction: "682675", // Mögeldorf Bahnhof, Nürnberg
      ignoredLines: [],
      excludedTransportationTypes: ["bus"],
      timeToStation: 5,
      displayLastUpdate: true,
      displayLastUpdateFormat: "dddd MMM D - HH:mm",
      showColoredLineSymbols: true,
      useColorForRealtimeInfo: true,
      noRealtimeDelayString: "⚠",
      showTableHeadersAsSymbols: true,
      maxUnreachableDepartures: 2,
      maxReachableDepartures: 10,
      customLineStyles: "nuernberg",
      showOnlyLineNumbers: true
    }
  },

It can be that this is the result of the necessary change from the 'db' profile to the db-vendo-client'.

@evroom evroom added the bug Something isn't working label Jan 12, 2025
@ggruening
Copy link

ggruening commented Jan 14, 2025

+1 Same here...

@KristjanESPERANTO
Copy link
Owner

Should be fixed now with release 3.0.2 🙂

Please confirm.

@ggruening
Copy link

ggruening commented Jan 15, 2025

Recently, I tested the workaround provided by @KristjanESPERANTO , but unfortunately, it did not perform as expected. While it successfully filters the departures to show only those trains that have the specified destination as their final stop, it incorrectly excludes trains that pass through the destination at any point in their route.

I kindly request that this filtering functionality be further improved to ensure that all relevant departures are displayed accurately. It would greatly enhance the usability of the system for passengers who are looking to travel to specific destinations.

Thank you for your attention to this matter. I appreciate your efforts in making our public transport experience better!

Gregor

@KristjanESPERANTO
Copy link
Owner

@ggruening At the moment I can hardly imagine how the workaround creates this effect. The workaround filters based on information about the direction, stops on the route are not treated at all. Didn't this behaviour already occur with 3.0.1 or 3.0.0?
In any case, I need more info (like the config and which directions are being falsely filtered) to investigate.

@evroom How is the new version working for you?

@ggruening
Copy link

@KristjanESPERANTO I'm not quite sure which version I last used. I can find that out later today or tomorrow, as I'm currently not at home. In the older versions, the effect of 'direction' has been as I described for years. It seems reasonable to me: as a commuter, all trains that reach a specific destination are helpful. The route is actually irrelevant; what matters is that the destination appears at some point during the journey. Perhaps the 'direction' parameter has always been intended differently, but that is indeed what helps me, at least. I will gladly provide my configuration later today or tomorrow, but maybe my use case will already help: 'show all departures from Münster(Westf)Hbf to Dortmund(Hbf)' (all in Germany from Deutsche Bahn). Thank you for considering this! Best regards!

@blinkybob
Copy link

I had the same problem as @evroom with the direction I updated the module to 3.0.2
Now I have zero departures listed on the screen. Before the update there were three to four ones.

Here is my config:

{
module: "MMM-PublicTransportHafas",
        position: "bottom_left",
        config: {
                // Departures options
                stationID: "8005976",             // Replace with your stationID!
                stationName: "Unterasbach",       // Replace with your station name!
                direction: "8004486",             // Show only departures heading to this station. (A station ID.)
                excludedTransportationTypes: [],  // Which transportation types should not be shown on the mirror? (comma-separated list of types) possible values: "tram", "bus">
                ignoredLines: [],                 // Which lines should be ignored? (comma-separated list of line names)
                timeToStation: 9,                // How long do you need to walk to the next Station?
                timeInFuture: 90,

                // Look and Feel
                displayLastUpdate: true,          // Display the last time of module update.
                maxUnreachableDepartures: 2,      // How many unreachable departures should be shown?
                maxReachableDepartures: 7,        // How many reachable departures should be shown?
                showColoredLineSymbols: true,     // Want colored line symbols?
                customLineStyles: "",             // Prefix for the name of the custom css file. ex: Leipzig-lines.css (case sensitive)
                showOnlyLineNumbers: false,       // Display only the line number instead of the complete name, i. e. "11" instead of "STR 11"
                showTableHeadersAsSymbols: true,  // Table Headers as symbols or text?
                useColorForRealtimeInfo: true     // Want colored real time information (timeToStation, early)?
                }
        }

@evroom
Copy link
Author

evroom commented Jan 15, 2025

It works, but it is kind of useless for me.
But ... it greatly depends on the direction station ID that is being used.

Part of my config:

      hafasProfile: "db",
      stationID: "8004491", // Nürnberg-Rehhof
      direction: "", // [ Schwabach - Roth - Lauf(links Pegnitz) - Hersbrück(l Pegnit) - Hartmannshof ]
      //direction: "682675",  // Mögeldorf Bahnhof, Nürnberg (not okay)
      //direction: "8004481", // Nürnberg-Mögeldorf (not okay)
      //direction: "8005185", // Roth (okay)
      //direction: "8005439", // Schwabach (okay)
      //direction: "683437",  // Bahnhof, Schwabach (not okay)
      //direction: "8000284", // Nürnberg Hbf (not okay)
      //direction: "682669",  // Hauptbahnhof, Nürnberg (not okay)
      //direction: "8004480", // Nürnberg-Laufamholz (not okay)
      //direction: "8005451", // Schwaig (not okay)
      //direction: "683039",  // Hartmannshof Bahnhof, Pommelsbrunn (not okay)
      //direction: "8003580", // Lauf(links Pegnitz) (okay)
      //direction: "8002793", // Hersbrück(l Pegnitz) (okay)
      //direction: "8002612", // Hartmannshof (okay)
      //direction: "683039",  // Hartmannshof Bahnhof, Pommelsbrunn (not okay)
      ignoreRelatedStations: true,

So, it only works for directions that are on the list when run with direction: "".
This needs to be a one-on-one match.
The ignoreRelatedStations: true does not seem to make any difference, btw.

For me it is not useful as I mainly travel with the S2 to Nürnberg Hbf and sometimes to Schwaig.
Showing 2 separate boards for the 2 directions does not make great sense and it would not work for the direction Schwaig.

@ggruening
Copy link

Perhaps departures in a specific direction are not what I and others are really looking for. It might be worth considering a display of the next connections from one station to a specific destination. That would certainly be a perfect feature for commuters ;-)

@lklinge
Copy link

lklinge commented Jan 16, 2025

Without direction the module shows me all trains departing from the starting station. S-Bahn (S) and Regional Express (RE) trains.

As soon as I enter a destination station in “direction” only the S-Bahn trains are displayed. And the Regional Express is missing.

@KristjanESPERANTO
Copy link
Owner

I probably won't have time to look at the problem until next week.

@KristjanESPERANTO
Copy link
Owner

KristjanESPERANTO commented Jan 18, 2025

Okay, I've had a look.

Let me elaborate a little: The hafas-client direction option really worked so that you could enter a stop on the route. Since Deutsche Bahn has apparently shut down the server that the hafas-client used for the db profile, we no longer received any departures for this module.

To make the db profile work again, we switched to the db-vendo-client with version 3. This new client has almost the same functionalities as the hafas-client. So we've got our departures back 🙂

Unfortunately, the db-vendo-client is only almost complete - the direction option is not yet functional, which is stated in the README of the client.

So I see the following options for you:

  1. participate in the development of db-vendo-client and fix the problem yourself. My focus is currently on other projects.
  2. check whether a profile other than the db profile might work for your stop (checkout the README for that). The hafas-client is still used for other profiles, which is why the direction option works there. Remember that you will most likely have to use different IDs for other profiles.
  3. if you only have one line coming along, you can enter the ID of the end point for the direction. This works with the above-mentioned workaround that I have included in version 3.0.2 of the module.
  4. switch off the direction option and wait until someone fixes the problem in db-vendo-client.

Even if it is an upstream issue, I leave the issue open so that others can see that the problem is known, but needs to be fixed elsewhere.

@KristjanESPERANTO KristjanESPERANTO added the upstream-issue The problem is in a dependency and must be solved there label Jan 18, 2025
@KristjanESPERANTO KristjanESPERANTO changed the title The configuration option 'direction' does not work (anymore). Configuration option 'direction' does not work anymore (with db profile) Jan 18, 2025
KristjanESPERANTO added a commit that referenced this issue Jan 18, 2025
@KristjanESPERANTO KristjanESPERANTO removed the bug Something isn't working label Jan 18, 2025
@evroom
Copy link
Author

evroom commented Jan 18, 2025

Thanks for looking into it and the extensive comment.
I personally do not use it, but good that is has been investigated.

Thx!

@traines-source
Copy link

For clarification: It's not that I chose to not implement it in db-vendo-client so far, it's because the DB APIs don't offer this parameter anymore (or we don't know it). (And as you have discovered, we can't just filter by the direction/destination field because that excludes trips that pass by that station.)
There is the bahn.de boards API that is not implemented yet that at least returns some stopovers/ueber by which you could filter (but still not all, so it's not very helpful), and there is the RIS::Boards API that apparently returns all stopovers, although I'm not sure how reliable that is. And crucially, this API is paid if you don't find an API key somewhere 👀 ^^
(Also see public-transport/db-vendo-client#3)
When only trains are of interest (i.e. no buses etc.) the DB IRIS API might also be worth a try (but I currently don't see that to be implemented as part of db-vendo-client, especially because I have a feeling that it could also be shut down at some point, but I don't know).

@ggruening
Copy link

ggruening commented Jan 22, 2025

@KristjanESPERANTO
I'm not really sure, but the db-vendo-client can provide connections. Maybe it helps to take a closer look:

https://github.com/public-transport/db-vendo-client/blob/main/docs/journeys.md

Instead of a direction from a station, we would then have a start station and a destination station as a 'direction'. May this work?

@traines-source
Copy link

That's actually not a bad idea, if you additionally set transfers=0 to get only direct connections, the result should be exactly the same as a filtered departure board, if I'm not missing anything. (But you will only get 3-4 results and there doesn't seem to be an option to get more within a single request with the new DB APIs.)

@KristjanESPERANTO
Copy link
Owner

@traines-source: Thanks for the clarification and huge thanks for db-vendo-client, it really saves us here 😃

@ggruening: Yes, I also think that the idea is good and that it could work. Do you feel like trying to implement this and creating a PR?

@ggruening
Copy link

@KristjanESPERANTO @traines-source
Thank you for considering my suggestion. Unfortunately, I lack the skills required for JavaScript development. While I can read some code and would be happy to help with testing, I'm not able to contribute to the actual development process. I hope that someone with the right skills will pick up this suggestion and implement it. I look forward to seeing how this feature evolves.

@traines-source
Copy link

traines-source commented Jan 23, 2025

Well we all had to learn it (by doing) at some point :)

Btw, this would also show cancelled trips, which I think is helpful (if you're exposing the remarks/cancelled flag, haven't checked), while with the db profile you seem to be using, cancelled trips are not returned in the boards! (And in the dbnav profile they are returned but boards are limited to one hour...)

@KristjanESPERANTO KristjanESPERANTO added the help wanted Extra attention is needed label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed upstream-issue The problem is in a dependency and must be solved there
Projects
None yet
Development

No branches or pull requests

6 participants