Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Adapt to probably changed model of return values. #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Joschbosch
Copy link

Hey,

I wanted to use your module but it did not work properly. I had a look into it and made some changes, I think that the data model that is returned by hafas changed a bit.

Maybe my changes can help you or other to get it also working.

Cheers,
Josch

@lavolp3
Copy link

lavolp3 commented Sep 20, 2017

@Joschbosch
Unfortunately, using your updated dbfetcher.js, I now have another error:

TypeError: Cannot read property 'fetchDepartures' of undefined

@Joschbosch
Copy link
Author

@lavolp3
Oh, I had this error also in the beginning, but now it is gone. But it was only at the startup when no connectivity was given, on the first update everything worked. I will have a look at this these days ;)

@stampede79
Copy link

Hi. I do receive the following error:
TypeError: Cannot read property 'fetchDepartures' of undefined
0|mm | at Class.getDepartures (/home/pi/MagicMirror/modules/MMM-PublicTransportDB/node_helper.js:39:43)
0|mm | at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-PublicTransportDB/node_helper.js:113:18)
0|mm | at Socket. (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:103:11)
0|mm | at emitTwo (events.js:106:13)
0|mm | at Socket.emit (events.js:191:7)
0|mm | at /home/pi/MagicMirror/node_modules/socket.io/lib/socket.js:514:12
0|mm | at _combinedTickCallback (internal/process/next_tick.js:67:7)
0|mm | at process._tickCallback (internal/process/next_tick.js:98:9)

@Joschbosch
Copy link
Author

Ok, I also had the problem and just added a check for the problem which in my case worked fine. Also, the module is working correctly for me, having no errors. As far as I can see, I did not make any other changes.
The changed file is added, hopefully it works for you now.

@stampede79
Copy link

After some tries, if receive now the following error:
(node:27880) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'name' of undefined
(node:27880) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@flanagan
Copy link

flanagan commented Oct 5, 2017

I get this...

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'name' of undefined

@Joschbosch
Copy link
Author

Mhh since I do not get this, could one of you post the config you use for the module? Maybe something is different there that leeds to the error.

@Pretowner
Copy link

Hi, I also got this Problem. It worked for me until i updated MagicMirror. with the config attached i get
"Whoops! There was an uncaught ecception... Error: Station must be a string"
which is stragge, because the documentation told me it is an integer. Anyway, when I put ticks (') auround the Station id, , i get the error mentioned in flanagan's post.

config

@Pretowner
Copy link

Did you notice that there is a new portal for developers?: developer.deutschebahn.com After a free Registration you can use a couple of API's , like "Timetable-v1", "Fahrplan-v1", and also "StaDa-Station_Data-v2"
here you can find a php class for building departs and acual delays (PHP 7.0+): ct.de/yz1v , phpbahn.php

@Corburn84
Copy link

Corburn84 commented Dec 15, 2017

I've got the same errors as described above on a fresh installed MagicMirror v2.

Yes, the station ID needs to be a string, so in config.js type something like '123456789' instead of an integer.

I as well got the error "Cannot read property 'name' of undefined" and fixed it in the DbFetcher.js. In fact the problem is in the "processData" prototype. The "data.forEach"-block fails to read the data of the response, because the structure changed. For example "row.product.name" ain't available anymore. Instead you have to use "row.line.name".

The next error is the following line:
departuresData.departuresArray.sort(compare);
That won't work and crashes as well. I just commented it, just because there's no need to sort the array. The response already is sorted.

Additionally the config "excludedTransportationTypes" wasn't used so far. I also added this to "processData".

It's now working for me.
I'm new to git and don't have a clue how to commit my changes to this project. If anyone of you wants the code he might want to help me commit the changes ;-)

@Pretowner:
Yeah, just found the API 2 weeks ago. Looks very neat! Maybe we should switch from db hafas to the API for a future release. The response data is the same, so it shouldn't be that much work.

@housepunk
Copy link

Can you send me your Changes?
[email protected]

@Corburn84
Copy link

That's not working, I get my mails back telling me "Message rejected due to local policy".
You can find my changes here: https://github.com/Corburn84/MMM-PublicTransportDB_modified

You need the two files "DbFetcher.js" and "MMM-PublicTransportDB.js". You might want to update db-hafas modul as well.

@Pretowner
Copy link

@Corburn84 : Thanks, the both files and updating the db-hafas module helped!

@fiaskogaul
Copy link

fiaskogaul commented Jan 26, 2018

I still don't get the module to work. All I get ist a loading message. I copied the two files "DbFetcher.js" and "MMM-PublicTransportDB.js" in the module directory and deleted and db-hafas module and downloaded the latest version. I also tried to call the "MMM-PublicTransportDB_modiefied" module.
What am I missing? Or how can I proper debug the problem.

Heres the code I'm using to call the module in the config.js:

{	module: 'MMM-PublicTransportDB',
	position: 'top_right',
	config: {
		name: "Klosterplatz",
	        hidden: false,
	        stationId: 808180,
	        ignoredStations: [],                 //Which stations should be ignored? (comma-separated list of station IDs)
	        excludedTransportationTypes: 'Bus',  //Which transportation types should not be shown on the mirror? (comma-separated list of types) possible values: bus,tram,suburban,subway,ferry
   		direction: 808084,                   //Which direction should be displayed? (destination station ID)
	        marqueeLongDirections: true,
	        delay: 5,                            //How long do you need to walk to the next Station?
	        interval: 120000,                    //How often should the table be updated in ms?
	        departureMinutes: 60,                //For how many minutes should departures be shown?
	        showColoredLineSymbols: true,        //Want colored line symbols?
	        useColorForRealtimeInfo: true,       //Want colored real time information (delay, early)?
	        showTableHeaders: true,
	        showTableHeadersAsSymbols: true,     //Table Headers as symbols or written?
	        maxUnreachableDepartures: 3,         //How many unreachable departures should be shown?
	        maxReachableDepartures: 10,          //How many reachable departures should be shown?
	        fadeUnreachableDepartures: true,
	        fadeReachableDepartures: true,
	        fadePointForReachableDepartures: 0.25
		}
},

@Corburn84
Copy link

You have to use a string as stationID.
Instead of
stationId: 808180
you need to type
stationId: '808180'

Same for value of "direction".

@fiaskogaul
Copy link

@Corburn84 Great, thanks. It Works.

@djsunrise19
Copy link

djsunrise19 commented Feb 3, 2018

Hi! Any ideas how to make the different product lines more stylish with different colors (like the original module)? Actually it doesn't work with showColoredLineSymbols: true

@djsunrise19
Copy link

Nobody? Something seems to be wrong. color and type are undefined. 2018-02-09_15h38_20

@Corburn84
Copy link

Thanks for the hint. I recently fixed this bug in my repository. The returned type was wrong in the DBFetcher.

I might gonna tune the style.css once more so that the cells aren't that close to each other.

@KristjanESPERANTO
Copy link

KristjanESPERANTO commented Feb 21, 2018

You have to use a string as stationID.

In the README.md it's written that stationId is an integer. So does it have to be changed there?

@Corburn84
Copy link

Yeah, the README.md is wrong.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants