bureus / MMM-Vasttrafik-PublicTransport

Initial commit
9 stars 6 forks source link

Traffic situations #10

Closed Zoonie81 closed 4 years ago

Zoonie81 commented 4 years ago

First off, thank you very much for your hard work on this module. It's one of the most useful modules in our home.

I have a request regarding the traffic situations. Could you possibly evolve this part in the readme? Perhaps with a couple of lines of examples? I have the subscription and option is set to true. I'm just not sure where to paste the query results.

Thanks in advance!

bureus commented 4 years ago

Hi @Zoonie81!

Thanks for the kind words! I have looked into the traffic situation feature this weekend and it seems to be working as normal. As long as you have any ongoing traffic situations for your stop that you are tracking it should show up automatically if you have the setting set to true and a valid subscription. Traffic situations are rendered each hr, compare to the board which you can decide yourself.

You can try it out with this stop, which seems to have an ongoing situation. Stopid: "9021014007270000". So just add it into stopid array. The config should look something like this:

{ module: 'MMM-Vasttrafik-PublicTransport', position: 'bottom_left', header: "Västtrafik", config: { stopIds: ["9022014081830001", "9021014007270000"], appKey: "APPKEY", appSecret: "APPSECRET", debug: false, sortBy: "track", refreshRate: "20000", trafficSituations: true, board: { destination: { maxPxWidth: 200 } } } }

So you don't need to do anything else than subscribing to the product and set the setting to true. Then it should show up :) I will try to add some more information about this into the read me.

Zoonie81 commented 4 years ago

@bureus that was some 1st class support, thanks for your time!

I rechecked everything and I just wouldn't get any situation information for my stop specifically, even though they are doing maintenance here. I checked https://www.vasttrafik.se/en/traffic-information/ and indeed there was information about disturbances in traffic at my stop. I went back to Reseplaneraren console and started looking at my stop again. Everything checked out - I looked up my stop through the location name and it would return the same id I already have.

So, I went to the TrafficSituations console and made a request for all ongoing situations and found my stop in the response. I realized there are 2 different ids - a gid and a stopAreaGid. The latter is what I had. Changing this to the gid solved the issue and I'm getting the information on display. Strangely, I have no idea how to get this gid through Reseplaneraren console. It just returns the stopAreaGid as the gid, and even though the times would show up with no issues, traffic information wouldn't.

TLDR; I had the an id that would give me the time schedule but not the traffic info.

One last thing I noticed today btw. Realized that the swedish characters (å,ä,ö) in the titles such in Göteborg, Nästa, Därefter are all widened. Is this a font issue?

Cheers! /Z

bureus commented 4 years ago

@Zoonie81 : Sorry for late reply. I have been in contact with Västtrafik regarding the issue and here is some more information :)

There is two types of guides. Stop area GID, which relates to a stop like Brunnsparken and a Stop Point GID, which is a specific direction of a stop like Brunnsparken Läge A. Stop Area GID is what we get when searching for a location by name (https://api.vasttrafik.se/bin/rest.exe/v2/location.name?input=brunnsparken). Which should work according to västtrafik with the endpoint we use for traffic situations (/traffic-situations/stoparea/{gid}).

There is no way right now to search and get Stop Point GID, which is what seems to work for you right now. But they are working on an endpoint to get that as well.

I will see if I can change my code to be able to search for both or to enable us to decide what type of GID to use towards the traffic situation endpoints.

Hopefully, I will be able to resolve this today :) So look out for a commit.

bureus commented 4 years ago

@Zoonie81 Ahh!! I was using the wrong traffic situation endpoint in the code. So we were searching for traffic situations for a specific läge. Therefore the GID you had was not working. I have changed the code now to search for traffic situations based on stop area GID, which is the current GID we use. So the issue should be resolved now. So please do an update of the module :) Let me know if it works better!