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

Module stops with error message "userAgent must be a string" #71

Closed
RolSch01 opened this issue Mar 2, 2020 · 2 comments
Closed

Module stops with error message "userAgent must be a string" #71

RolSch01 opened this issue Mar 2, 2020 · 2 comments

Comments

@RolSch01
Copy link

RolSch01 commented Mar 2, 2020

Hi.
I just installed a clean new version of MagicMirror, added this module (from the greenkeeper/hafas-client-5.1.1 branch) modified the example configuration with my own station ID and started MM.
But the module crashes with the following message:

[17:46:00.564] [ERROR] TypeError: userAgent must be a string
at createClient (/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_modules/hafas-client/index.js:31:9)
at new HafasFetcher (/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/core/HafasFetcher.js:29:24)
at Class.createFetcher (/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_helper.js:31:17)
at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_helper.js:17:14)
at Socket. (/home/pi/MagicMirror/js/node_helper.js:113:11)
at Socket.emit (events.js:198:13)
at /home/pi/MagicMirror/node_modules/socket.io/lib/socket.js:528:12
at process._tickCallback (internal/process/next_tick.js:61:11)
^Cevents.js:174
throw er; // Unhandled 'error' event
^
A can find the reason. The code seems to be ok. (hands over a static string to the method)

My configuration:

{
module: "MMM-PublicTransportHafas",
position: "bottom_right",
config: {
stationID: "00903736", // Replace with your stationID!
stationName: "Holzwickede Bahnhof", // Replace with your station name
direction: "", // Show only departures heading to this station. (A station ID.)
ignoredLines: [], // Which lines should be ignored? (comma-separated list of line names)
excludedTransportationTypes: ["bus"], // (comma-separated list of types) possible values: StN for tram, BuN for bus, s for suburban
timeToStation: 8, // How long do you need to walk to the next Station?
timeInFuture: 60,
showColoredLineSymbols: true, // Want colored line symbols?
useColorForRealtimeInfo: true, // Want colored real time information (timeToStation, early)?
showTableHeadersAsSymbols: true, // Table Headers as symbols or text?
maxUnreachableDepartures: 0, // How many unreachable departures should be shown?
maxReachableDepartures: 7, // How many reachable departures should be shown?
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"
}
},

I did the following:
git clone ....
git checkout greenkeeper/hafas-client-5.1.1
npm install

Master didn't compile with version conflicts.

When i disable the module MM starts and runs normally.
Any idea?
Thanks in advance.

@RolSch01
Copy link
Author

RolSch01 commented Mar 2, 2020

I really don't know what the problem was.
Just deleted and reinstalled the module. Didn't change anything else.
Now it runs like a charm.

Thanks for coding it.

@RolSch01 RolSch01 closed this as completed Mar 2, 2020
@derhuerst
Copy link

Author of hafas-client, the library used by MMM-PublicTransportHafas, here.

hafas-client@5 has breaking changes over the currently used hafas-client@2. This means that you cannot upgrade from hafas-client@2 to hafas-client@5 without adapting the MMM-PublicTransportHafas code. This is why it complains about a missing userAgent argument.

The greenkeeper/hafas-client-5.1.1 branch has been created by a bot, which did obviously not adapt the MMM-PublicTransportHafas code to hafas-client@5. For a German discussion on upgrading hafas-client, check #67. This repo doesn't seem to be maintained though.

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

No branches or pull requests

2 participants