deg0nz / MMM-PublicTransportBerlin

MagicMirror module to display public transport in Berlin and Brandenburg with BVG Hafas data.
MIT License
40 stars 20 forks source link

Can't get the new stationId! Please help. #144

Closed essknete closed 1 year ago

essknete commented 1 year ago

Hi, when I start the script by typing node ./convenience/query_stations.mjs, then I get the following: import { createClient } from "hafas-client"; ^^^^^^^^^^^^ SyntaxError: Named export 'createClient' not found. The requested module 'hafas-client' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'hafas-client'; const { createClient } = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)

Any ideas for help?

rejas commented 1 year ago

You need node 18 to run this (at least that what worked for me)

essknete commented 1 year ago

Thanks a lot for your input, I updated node to the newest version, but it still doesn't work for me:

file:///home/XXXXXXXXX/MagicMirror/modules/MMM-PublicTransportBerlin/convenience/query_stations.mjs:2 import { createClient } from "hafas-client"; ^^^^^^^^^^^^ SyntaxError: Named export 'createClient' not found. The requested module 'hafas-client' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:

import pkg from 'hafas-client'; const { createClient } = pkg;

at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)

Node.js v19.7.0

KristjanESPERANTO commented 1 year ago

Oh, the problem is that the query_stations script already requires hafas-client v6. I didn't think about that when I made the change. I think I can build a fix tonight.

KristjanESPERANTO commented 1 year ago

It should work with the last commit. @essknete , please let us know if it works for you.

essknete commented 1 year ago

@KristjanESPERANTO thanks for your effort! it works for me now to search for the stationID, but if I insert the 6-digit ID to my config.js, than nothing shows up and no information is visible on the MagicMirror. BTW: with the old 12-digit stationID it works fine, but the warning shows up.

KristjanESPERANTO commented 1 year ago

Which station is it?

KristjanESPERANTO commented 1 year ago

The 12-digit stationID will stop working with the next big update of the module. It would be very good for us to know what the problem is with your installation. It would be good for us to know why the long ID doesn't work for you.

essknete commented 1 year ago

Which station is it?

I'm using 2 different stations, because my kids using different buses, but both (new ID's) don't work for me... stationId: "900000085154", // old works fine with warning message stationId: "732275", // new don't works at all.

essknete commented 1 year ago

The 12-digit stationID will stop working with the next big update of the module. It would be very good for us to know what the problem is with your installation. It would be good for us to know why the long ID doesn't work for you.

the old long (12 digit) ID works fine at the moment... :)

rejas commented 1 year ago

what station names are you searching for?

essknete commented 1 year ago

what station names are you searching for?

as I wrote before, I'm able to find the new station ID with the script! so that's not the issue... but if you like to check this, than look for: me ;)

KristjanESPERANTO commented 1 year ago

OK, I see the problem. To be more precise, even two. Firstly, I made a mistake when selecting the hafas-profile. And secondly, there still seems to be 12-digit IDs, as in this example. So the warning we added a few days ago isn't correct for everyone.

I'll fix the script and remove the warning.

EDIT: Okay, it's a little more complicated. I'll do some more research about how to handle old and new IDs.

@essknete, you can use the stationId 900085154.

KristjanESPERANTO commented 1 year ago

Sorry for the trouble 🤦😅

KristjanESPERANTO commented 1 year ago

I should have tested the changes better beforehand. But it should work now.

essknete commented 1 year ago

OK, I see the problem. To be more precise, even two. Firstly, I made a mistake when selecting the hafas-profile. ~And secondly, there still seems to be 12-digit IDs, as in this example. So the warning we added a few days ago isn't correct for everyone.~

I'll fix the script ~and remove the warning~.

EDIT: Okay, it's a little more complicated. I'll do some more research about how to handle old and new IDs.

@essknete, you can use the stationId 900085154.

Thanks, now it works for me fine!

essknete commented 1 year ago

Sorry for the trouble 🤦😅

no problem and thanks for your effort in this case. ;)

KristjanESPERANTO commented 1 year ago

Very good! I close the ticket now. Have a nice weekend! :slightly_smiling_face: