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

Getting: nb: fatal: TypeError: #4

Closed
SirColeslaw opened this issue Nov 30, 2020 · 13 comments
Closed

Getting: nb: fatal: TypeError: #4

SirColeslaw opened this issue Nov 30, 2020 · 13 comments
Labels
bug Something isn't working

Comments

@SirColeslaw
Copy link

Hello,

im getting this Error all the time for a fresh homebrindge-nb installation.

homebridge@ubuntu:/var/lib/homebridge$ nb discover
nb: fatal: TypeError: Cannot read property 'split' of undefined
at Main.parseArguments (/usr/lib/node_modules/homebridge-nb/cli/nb.js:328:29)
at Main.main (/usr/lib/node_modules/homebridge-nb/cli/nb.js:336:27)
at Object. (/usr/lib/node_modules/homebridge-nb/cli/nb.js:586:12)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47

It seems that no matter which command I use, the same error always occurs.

@ebaauw ebaauw added the bug Something isn't working label Nov 30, 2020
@ebaauw
Copy link
Owner

ebaauw commented Nov 30, 2020

That’s not good. As a workaround, could you try nb -H x discover? For other commands, you need to specify the ip address of your nuki bridge, but discover shouldn’t look at the value.

@SirColeslaw
Copy link
Author

SirColeslaw commented Dec 1, 2020

I tried that too, but unfortunately the message remains the same.

If it helps, every 10 minutes I get this entry in the status log of Homebridge:

[12/1/2020, 5:27:22 AM] [Nuki] warning: TypeError: host: undefined: not an integer
at newTypeError (/usr/lib/node_modules/homebridge-nb/node_modules/homebridge-lib/lib/OptionParser.js:42:52)
at Function.toHost (/usr/lib/node_modules/homebridge-nb/node_modules/homebridge-lib/lib/OptionParser.js:361:13)
at Object._callbacks. [as host] (/usr/lib/node_modules/homebridge-nb/node_modules/homebridge-lib/lib/OptionParser.js:679:33)
at OptionParser.parse (/usr/lib/node_modules/homebridge-nb/node_modules/homebridge-lib/lib/OptionParser.js:817:29)
at new NbClient (/usr/lib/node_modules/homebridge-nb/lib/NbClient.js:99:18)
at NbPlatform.foundBridge (/usr/lib/node_modules/homebridge-nb/lib/NbPlatform.js:92:22)
at NbPlatform.heartbeat (/usr/lib/node_modules/homebridge-nb/lib/NbPlatform.js:74:24)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:93:5)

@ebaauw
Copy link
Owner

ebaauw commented Dec 1, 2020

I tried that too, but unfortunately the message remains the same.

Huh? What version did you install?

$ nb discover
nb: fatal: TypeError: Cannot read property 'split' of undefined
    at Main.parseArguments (/Users/ebaauw/GitHub/homebridge-nb/cli/nb.js:328:29)
    at Main.main (/Users/ebaauw/GitHub/homebridge-nb/cli/nb.js:336:27)
    at Object.<anonymous> (/Users/ebaauw/GitHub/homebridge-nb/cli/nb.js:586:12)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
$ nb -H x discover
[
  {
    "bridgeId": 1522130723,
    "dateUpdated": "2020-11-23T18:26:50Z",
    "ip": "192.168.76.201",
    "port": 8080
  }
]

Can you please try:

$ nb -DD -H x discover
nb discover: nuki server request 1: GET /bridges
nb discover: nuki server request 1: GET https://api.nuki.io/discover/bridges
nb discover: nuki server request 1: response: {"bridges":[{"bridgeId":1522130723,"ip":"192.168.76.201","port":8080,"dateUpdated":"2020-11-23T18:26:50Z"}],"errorCode":0}
nb discover: nuki server request 1: 200 OK
[
  {
    "bridgeId": 1522130723,
    "dateUpdated": "2020-11-23T18:26:50Z",
    "ip": "192.168.76.201",
    "port": 8080
  }
]

If it helps, every 10 minutes I get this entry in the status log of Homebridge:

I don't think that's related to the nb bug. I would theorise Homebridge NB chokes on the response from the Nuki portal, trying to discover your Nuki bridge(s). I need to see the output of ph discover to understand what's happening here. The stack trace suggests you're not running the latest version of Homebridge NB?

@SirColeslaw
Copy link
Author

Version installed is: homebridge-nb v0.0.5

I tried a downgrade before contacting you to look if it solves the problem, but it didnt so i updated back to 0.0.5.

Here is the output from nb -DD -H x Discover:

homebridge@ubuntu:/var/lib/homebridge$ nb -DD -H x discover
nb discover: nuki server request 1: GET /bridges
nb discover: nuki server request 1: GET https://api.nuki.io/discover/bridges
nb discover: nuki server request 1: response: {"bridges":[{"bridgeId":176530759,"dateUpdated":"2020-11-30T14:29:29Z"}],"errorCode":0}
nb discover: nuki server request 1: 200 OK
[
{
"bridgeId": 176530759,
"dateUpdated": "2020-11-30T14:29:29Z"
}
]

@ebaauw
Copy link
Owner

ebaauw commented Dec 1, 2020

That is weird, the response from the Nuki portal doesn't include your bridge's local IP address. I didn't know it could report a bridge without one (I would have expected an empty list instead).

You need to enable something on the Nuki bridge for it to be discoverable.

ebaauw referenced this issue Dec 1, 2020
Bug fix: TypeError when Nuki portal returns bridge without local IP and port.
ebaauw referenced this issue Dec 1, 2020
Big fix: TypeError when no host specified.
@ebaauw
Copy link
Owner

ebaauw commented Dec 1, 2020

v0.0.6 should fix the TypeErrors.

@SirColeslaw
Copy link
Author

Could it be a problem that i am using the nuki software bridge via android instead of a hardware one? On that software bridge i dont have any button i could push to make it discoverable.

@ebaauw
Copy link
Owner

ebaauw commented Dec 2, 2020

I have no idea. I read about the software bridge in the API documentation, but I haven’t been able to find it for download. Does it run only on Android? The button on the hardware bridge is to obtain the API token, not to make it discoverable.

@SirColeslaw
Copy link
Author

SirColeslaw commented Dec 2, 2020

Software bridge seems to be Android only: https://play.google.com/store/apps/details?id=io.nuki.bridge&hl=de&gl=US

There is an option to generate a token on the nuki web interface. Can that be used to insert that generated token into the plugin somehow?

Unbenannt

It shows an oauth2 API Key there too, is that useful?

@ebaauw
Copy link
Owner

ebaauw commented Dec 2, 2020

You can feed the token (and the bridge’s IP address) to nb by setting NB_TOKEN (and NB_HOST) or through command line parameters. There’s currently no way to feed these to Homebridge NB.

Could you check that nb can interact with the software bridge, controlling your lock? Does the software bridge support callbacks?

@SirColeslaw
Copy link
Author

SirColeslaw commented Dec 2, 2020

I found out that the Token can be received on the software bridge app under settings, so i have that token now, but i dont know now where to put it.

If i use this request: http://192.168.178.60:8080/list?token=******

i get this: [{"nukiId":**********,"name":"Zuhause","lastKnownState":{"state":1,"stateName":"locked","batteryCritical":false,"timestamp":"2020-12-02T03:17:49+01:00"}}]

@ebaauw
Copy link
Owner

ebaauw commented Dec 4, 2020

You cannot put a token nor hostname to Homebridge NB. It's all discovered automatically. Below is what happens on the hardware bridge. For Homebridge NB to support the software bridge, it would have to behave similar to the hardware bridge.

You need to enable the HTTP API and API Quick discovery on your bridge, in the Nuki app:
IMG_0232

After that, nb discover finds the bridge:

$ nb discover
[
  {
    "bridgeId": 1522130723,
    "dateUpdated": "2020-12-04T17:19:29Z",
    "ip": "xxx.xxx.xxx.xxx",
    "port": 8080
  }
]

Homebridge NB does an /auth API call to the bridge to obtain the token. As security measure, you need to press the button on the bridge.

The discovered bridgeId is actually the serverId returned by an API call to /info:

$ nb info
{
  "bridgeType": 1,
  "currentTime": "2020-12-04T17:23:52+00:00",
  "ids": {
    "hardwareId": 535158466,
    "serverId": 1522130723
  },
  "scanResults": [
    {
      "deviceType": 2,
      "name": "Nuki_Opener_1E60104A",
      "nukiId": 509612106,
      "paired": true,
      "rssi": -40
    },
    {
      "deviceType": 0,
      "name": "Nuki_1FDE0EED",
      "nukiId": 534646509,
      "paired": true,
      "rssi": -76
    }
  ],
  "serverConnected": true,
  "uptime": 274,
  "versions": {
    "firmwareVersion": "2.8.0",
    "wifiFirmwareVersion": "2.2.0"
  },
  "wlanConnected": true
}

According to the HTTP API documentation, the only differences with the software bridge would be a missing hardwareId and a bridgeType of 2. I have no idea how you'd simulate pressing the button on the software bridge.

@ebaauw
Copy link
Owner

ebaauw commented Dec 4, 2020

The TypeErrors should be fixed in v0.0.7.

@ebaauw ebaauw closed this as completed Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants