Xkhi / MMM-Vasttrafik-PublicTransport

Magic Mirror2 module to display information from public transportation in Västra Götaland, Sweden
1 stars 2 forks source link

Limited departure info #3

Open Zoonie81 opened 5 months ago

Zoonie81 commented 5 months ago

@Xkhi thanks for updating and forking this! I'll write this here since you haven't activated "issues" on your fork. I'm seeing some issues compared to the master, not sure why.

Upcoming departures (after next) column is almost always empty Using multiple stops, the second stop only shows 1-2 lines at most I've checked API v4 console and the info is there, it just doesn't output properly in this module. Do you have the same issues?

EDIT: I believe any departure longer than 10 min away is lost and not shown. If there is a departure or an upcoming departure after next within 10 min it seems to show up. all other fall into undefined and is presented with a dash (-) in the time table. This also seems to be the reason the second stop in my list only shows 1-2 lines, since those busses depart with longer intervals.

EDIT 2: Moved to fork :)

DSC_0046~2

manshurtigh commented 5 months ago

I have the same problem.

Zoonie81 commented 4 months ago

@Xkhi do you also have this issue or is it just an "us" problem?

I also noticed that the status "now" never shows up. In the master it would say "now" as the tram was on location. I saw the code snippet is still present in your fork but it never triggers.

Xkhi commented 4 months ago

sorry guys, day job is keeping me busy. Yeah, I see the same behaviour, my guess is that the API doesn't provide info if the upcoming bus/tram is gonna take more than 10 minutes

Zoonie81 commented 4 months ago

@Xkhi no problem man, nobody's expecting you to take time from work for this.

So I have the solution to the problem and yes it is the amount of data the API returns as standard. Default is a list of 10 departures. The problem grows the more lines pass by the given stop. We can easily request for a bigger list of departures to resolve this. However, there is also a fundamental issue in the way you filter tracks that augments the problem.

Since you always ask for the full list of departures for a stop from the API and filter them locally in your code for platforms, ie Svingel, Platform F, you will have restricted your data to only a few hits since only few of those 10 results are for Platform F. You can actually ask the API to filter for Platform F and in that way the returned list of 10 hits will all be for Platform F.

For now though, replacing line 130 in node_helper.js will solve the issue. uri: `https://ext-api.vasttrafik.se/pr/v4/stop-areas/${myStop.id}/departures?timeSpanInMinutes=120&maxDeparturesPerLineAndDirection=2&limit=120&offset=0&includeOccupancy=false`,

Also, traffic situations aren't working, but I noticed you are calling the wrong API address for this.

Good luck with the progress :)