ebaauw / homebridge-nb

Homebridge plugin for Nuki Bridge
Apache License 2.0
50 stars 3 forks source link

Unable to obtain IP #21

Closed BNoiZe closed 3 years ago

BNoiZe commented 3 years ago

Whenever I try to setup the Bridge I have problems with the IP address. It just tells me that it can't find the IPv4 address. Searching the internet didn't help much.

[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Serial Number to "xxx"
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Manufacturer to "Nuki Home Solutions GmbH"
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Model to "Bridge"
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Firmware Revision to "1.18.2"
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: Nuki Bridge v1.18.2 xxx at 192.168.2.100:8080
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Heartrate to 60 seconds
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Restart to false
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Log Level to 2
[2/13/2021, 16:18:52] [Nuki] Nuki_Bridge_B9FC91: set Status Fault to 0
[2/13/2021, 16:18:53] [Nuki] error: unhandled rejection: Error: cannot determine my IPv4 address
    at /usr/lib/node_modules/homebridge-nb/lib/NbListener.js:108:27
    at new Promise (<anonymous>)
    at NbListener.listen (/usr/lib/node_modules/homebridge-nb/lib/NbListener.js:103:12)
    at NbListener.addClient (/usr/lib/node_modules/homebridge-nb/lib/NbListener.js:131:16)
    at NbPlatform.addClient (/usr/lib/node_modules/homebridge-nb/lib/NbPlatform.js:227:26)
    at Bridge.init (/usr/lib/node_modules/homebridge-nb/lib/NbAccessory.js:145:52)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
ebaauw commented 3 years ago

Homebridge NB sets up a web server to receive push notifications from the Nuki bridge. It needs to subscribe to the bridge, specifying the address of this web server. The error indicates that it cannot determine the IP address for this web server.

I think this would only happen on a multi-homed server, where none of the interfaces share a subnet with the Nuki bridge. Or in layman's terms: a very complex network setup. What system are you running Homebridge on? How is it connected to the Nuki bridge? When you start node from the command line (in REPL mode), what is the output of os.networkInterfaces()?

BNoiZe commented 3 years ago

"very complex network setup" may be the correct term in my case. My network is splitted into 3 parts. 192.168.1.x where the Homebridge is in, 192.168.2.x for all the smarthome devices and 192.168.3.x for guests. The traffic from 192.168.1.x and 192.168.2.x is routed between the nets.

Output from os.networkInterface() (I removed the parts from docker. None of them are relevant for my Homebridge setup.):

{
  lo: [
    {
      address: '127.0.0.1',
      netmask: '255.0.0.0',
      family: 'IPv4',
      mac: '00:00:00:00:00:00',
      internal: true,
      cidr: '127.0.0.1/8'
    },
    {
      address: '::1',
      netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
      family: 'IPv6',
      mac: '00:00:00:00:00:00',
      internal: true,
      cidr: '::1/128',
      scopeid: 0
    }
  ],
  eth0: [
    {
      address: '192.168.1.3',
      netmask: '255.255.255.0',
      family: 'IPv4',
      mac: 'dc:a6:32:14:a7:b7',
      internal: false,
      cidr: '192.168.1.3/24'
    },
    {
      address: 'fe80::8730:6bb0:90df:1ef0',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'dc:a6:32:14:a7:b7',
      internal: false,
      cidr: 'fe80::8730:6bb0:90df:1ef0/64',
      scopeid: 2
    }
  ],
  ...
}
ebaauw commented 3 years ago

Output from os.networkInterface() (I removed the parts from docker. None of them are relevant for my Homebridge setup.):

I’m afraid they are. With this output, Homebridge NB would just select 192.168.1.3, as that’s the only non-internal IPv4 address available. Because there’s multiple potential addresses, Homebridge NB doesn’t know which one to choose.

BNoiZe commented 3 years ago

Here is the complete output.

> os.networkInterfaces()
{
  lo: [
    {
      address: '127.0.0.1',
      netmask: '255.0.0.0',
      family: 'IPv4',
      mac: '00:00:00:00:00:00',
      internal: true,
      cidr: '127.0.0.1/8'
    },
    {
      address: '::1',
      netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
      family: 'IPv6',
      mac: '00:00:00:00:00:00',
      internal: true,
      cidr: '::1/128',
      scopeid: 0
    }
  ],
  eth0: [
    {
      address: '192.168.1.3',
      netmask: '255.255.255.0',
      family: 'IPv4',
      mac: 'dc:a6:32:14:a7:b7',
      internal: false,
      cidr: '192.168.1.3/24'
    },
    {
      address: 'fe80::8730:6bb0:90df:1ef0',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'dc:a6:32:14:a7:b7',
      internal: false,
      cidr: 'fe80::8730:6bb0:90df:1ef0/64',
      scopeid: 2
    }
  ],
  docker0: [
    {
      address: '172.17.0.1',
      netmask: '255.255.0.0',
      family: 'IPv4',
      mac: '02:42:46:75:9c:2b',
      internal: false,
      cidr: '172.17.0.1/16'
    },
    {
      address: 'fe80::42:46ff:fe75:9c2b',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: '02:42:46:75:9c:2b',
      internal: false,
      cidr: 'fe80::42:46ff:fe75:9c2b/64',
      scopeid: 4
    }
  ],
  veth056725e: [
    {
      address: '169.254.235.225',
      netmask: '255.255.0.0',
      family: 'IPv4',
      mac: 'd6:7f:6b:46:93:de',
      internal: false,
      cidr: '169.254.235.225/16'
    },
    {
      address: 'fe80::4ca2:7bf7:6473:6dd4',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'd6:7f:6b:46:93:de',
      internal: false,
      cidr: 'fe80::4ca2:7bf7:6473:6dd4/64',
      scopeid: 10
    },
    {
      address: 'fe80::d47f:6bff:fe46:93de',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'd6:7f:6b:46:93:de',
      internal: false,
      cidr: 'fe80::d47f:6bff:fe46:93de/64',
      scopeid: 10
    }
  ],
  veth7abaca3: [
    {
      address: '169.254.216.152',
      netmask: '255.255.0.0',
      family: 'IPv4',
      mac: 'fe:72:aa:05:b6:39',
      internal: false,
      cidr: '169.254.216.152/16'
    },
    {
      address: 'fe80::984e:ac1c:fdee:f6bc',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'fe:72:aa:05:b6:39',
      internal: false,
      cidr: 'fe80::984e:ac1c:fdee:f6bc/64',
      scopeid: 12
    },
    {
      address: 'fe80::fc72:aaff:fe05:b639',
      netmask: 'ffff:ffff:ffff:ffff::',
      family: 'IPv6',
      mac: 'fe:72:aa:05:b6:39',
      internal: false,
      cidr: 'fe80::fc72:aaff:fe05:b639/64',
      scopeid: 12
    }
  ]
}
ebaauw commented 3 years ago

Could you try beta v1.0.7-0? You should be able to specify address in config.json (under Advanced Settings when using the Homebridge UI).

BNoiZe commented 3 years ago

v1.0.7-0 fixes the issue. Adding the address was sufficient. Thanks!