Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error Initializing Plugin #201

Open
hivenet-jakub opened this issue Nov 15, 2024 · 6 comments
Open

Error Initializing Plugin #201

hivenet-jakub opened this issue Nov 15, 2024 · 6 comments

Comments

@hivenet-jakub
Copy link

hivenet-jakub commented Nov 15, 2024

Expected Behavior

Plugin initialized

Current Behavior

Plugin fails to initialize - see log below. I installed it the following way:

  1. sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
  2. Did this just in case: sudo setcap cap_net_raw+eip $(eval readlink -f which node)
  3. Installed the plugin using the Homebridge UI. Plugin installs.
  4. I restart Homebridge
  5. Initialization Error occurs
  6. I try to install npm install bluetooth-hci-socket --unsafe-perm but I'm getting a long error log

Versions

  • homebridge: 1.8.5
  • homebridge-mi-hygrothermograph: /opt/homebridge/lib └── (empty)
  • node: 20.18.0
  • OS: Raspbian GNU/Linux 12 (bookworm) + Pi Zero W (armv6)

Homebridge Log / Command Output

====================
[15/11/2024, 06:45:47] ERROR INITIALIZING PLUGIN homebridge-mi-hygrothermograph:
[15/11/2024, 06:45:47] Error: Cannot find module '../build/Release/bluetooth_hci_socket.node'
Require stack:
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/index.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/hci.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/hci-socket/bindings.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/lib/resolve-bindings.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/with-custom-binding.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/index.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/scanner.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/lib/accessory.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/index.js
- /var/lib/homebridge/node_modules/homebridge/lib/plugin.js
- /var/lib/homebridge/node_modules/homebridge/lib/pluginManager.js
- /var/lib/homebridge/node_modules/homebridge/lib/api.js
- /var/lib/homebridge/node_modules/homebridge/lib/server.js
- /var/lib/homebridge/node_modules/homebridge/lib/cli.js
- /var/lib/homebridge/node_modules/homebridge/bin/homebridge
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js:2:30)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
[15/11/2024, 06:45:47] ====================

I'm not very 'fluent' in all of this. Maybe it's something simple to fix? Any help would be super appreciated!

@hivenet-jakub
Copy link
Author

Here is the error I'm getting after running npm install bluetooth-hci-socket --unsafe-perm

npm error code 1
npm error path /var/lib/homebridge/node_modules/bluetooth-hci-socket
npm error command failed
npm error command sh -c node-gyp rebuild
npm error make: Entering directory '/var/lib/homebridge/node_modules/bluetooth-hci-socket/build'
npm error   CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
npm error make: Leaving directory '/var/lib/homebridge/node_modules/bluetooth-hci-socket/build'
npm error ../src/BluetoothHciSocket.cpp: In static member function ‘static void BluetoothHciSocket::Init(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’:
npm error ../src/BluetoothHciSocket.cpp:128:81: error: no matching function for call to ‘v8::FunctionTemplate::GetFunction()’
npm error   128 |   target->Set(Nan::New("BluetoothHciSocket").ToLocalChecked(), tmpl->GetFunction());
npm error       |                                                                ~~~~~~~~~~~~~~~~~^~
npm error In file included from /home/pi/.cache/node-gyp/20.18.0/include/node/v8-function.h:15,
npm error                  from /home/pi/.cache/node-gyp/20.18.0/include/node/v8.h:33,
npm error                  from /home/pi/.cache/node-gyp/20.18.0/include/node/node.h:73,
npm error                  from /home/pi/.cache/node-gyp/20.18.0/include/node/node_buffer.h:25,
npm error                  from ../src/BluetoothHciSocket.cpp:7:
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-template.h:497:46: note: candidate: ‘v8::MaybeLocal<v8::Function> v8::FunctionTemplate::GetFunction(v8::Local<v8::Context>)’
npm error   497 |   V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
npm error       |                                              ^~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-template.h:497:46: note:   candidate expects 1 argument, 0 provided
npm error ../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::poll()’:
npm error ../src/BluetoothHciSocket.cpp:251:22: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
npm error   251 |     Nan::MakeCallback(Nan::New<Object>(this->This), Nan::New("emit").ToLocalChecked(), 2, argv);
npm error       |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error In file included from ../src/BluetoothHciSocket.cpp:8:
npm error ../node_modules/nan/nan.h:1072:46: note: declared here
npm error  1072 |   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
npm error       |                                              ^~~~~~~~~~~~
npm error ../src/BluetoothHciSocket.cpp: In member function ‘void BluetoothHciSocket::emitErrnoError()’:
npm error ../src/BluetoothHciSocket.cpp:269:74: error: no matching function for call to ‘v8::Object::Get(v8::Local<v8::String>)’
npm error   269 |   Local<Function> errorConstructor = Local<Function>::Cast(globalObj->Get(Nan::New("Error").ToLocalChecked()));
npm error       |                                                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error In file included from /home/pi/.cache/node-gyp/20.18.0/include/node/v8-array-buffer.h:13,
npm error                  from /home/pi/.cache/node-gyp/20.18.0/include/node/v8.h:24:
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-object.h:292:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)’
npm error   292 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
npm error       |                                           ^~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-object.h:292:43: note:   candidate expects 2 arguments, 1 provided
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-object.h:295:43: note: candidate: ‘v8::MaybeLocal<v8::Value> v8::Object::Get(v8::Local<v8::Context>, uint32_t)’
npm error   295 |   V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context,
npm error       |                                           ^~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-object.h:295:43: note:   candidate expects 2 arguments, 1 provided
npm error ../src/BluetoothHciSocket.cpp:275:53: error: no matching function for call to ‘v8::Function::NewInstance(int, v8::Local<v8::Value> [1])’
npm error   275 |   Local<Value> error = errorConstructor->NewInstance(1, constructorArgs);
npm error       |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-function.h:38:44: note: candidate: ‘v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>, int, v8::Local<v8::Value>*) const’
npm error    38 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
npm error       |                                            ^~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-function.h:38:44: note:   candidate expects 3 arguments, 2 provided
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-function.h:41:44: note: candidate: ‘v8::MaybeLocal<v8::Object> v8::Function::NewInstance(v8::Local<v8::Context>) const’
npm error    41 |   V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(
npm error       |                                            ^~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-function.h:41:44: note:   candidate expects 1 argument, 2 provided
npm error ../src/BluetoothHciSocket.cpp:282:20: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::String>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
npm error   282 |   Nan::MakeCallback(Nan::New<Object>(this->This), Nan::New("emit").ToLocalChecked(), 2, argv);
npm error       |   ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error ../node_modules/nan/nan.h:1072:46: note: declared here
npm error  1072 |   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
npm error       |                                              ^~~~~~~~~~~~
npm error ../src/BluetoothHciSocket.cpp: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE BluetoothHciSocket::BindRaw(Nan::NAN_METHOD_ARGS_TYPE)’:
npm error ../src/BluetoothHciSocket.cpp:395:33: error: no matching function for call to ‘v8::Value::IntegerValue()’
npm error   395 |       devId = arg0->IntegerValue();
npm error       |               ~~~~~~~~~~~~~~~~~~^~
npm error In file included from /home/pi/.cache/node-gyp/20.18.0/include/node/v8-primitive.h:11,
npm error                  from /home/pi/.cache/node-gyp/20.18.0/include/node/v8-object.h:11:
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-value.h:423:40: note: candidate: ‘v8::Maybe<long long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const’
npm error   423 |   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
npm error       |                                        ^~~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-value.h:423:40: note:   candidate expects 1 argument, 0 provided
npm error ../src/BluetoothHciSocket.cpp: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE BluetoothHciSocket::BindUser(Nan::NAN_METHOD_ARGS_TYPE)’:
npm error ../src/BluetoothHciSocket.cpp:417:33: error: no matching function for call to ‘v8::Value::IntegerValue()’
npm error   417 |       devId = arg0->IntegerValue();
npm error       |               ~~~~~~~~~~~~~~~~~~^~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-value.h:423:40: note: candidate: ‘v8::Maybe<long long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const’
npm error   423 |   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
npm error       |                                        ^~~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/v8-value.h:423:40: note:   candidate expects 1 argument, 0 provided
npm error ../src/BluetoothHciSocket.cpp: At global scope:
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/node.h:1232:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
npm error  1232 |       (node::addon_register_func) (regfunc),                          \
npm error       |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm error /home/pi/.cache/node-gyp/20.18.0/include/node/node.h:1266:3: note: in expansion of macro ‘NODE_MODULE_X’
npm error  1266 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
npm error       |   ^~~~~~~~~~~~~
npm error ../src/BluetoothHciSocket.cpp:499:1: note: in expansion of macro ‘NODE_MODULE’
npm error   499 | NODE_MODULE(binding, BluetoothHciSocket::Init);
npm error       | ^~~~~~~~~~~
npm error make: *** [binding.target.mk:106: Release/obj.target/binding/src/BluetoothHciSocket.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebridge/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:216:23)
npm error gyp ERR! System Linux 6.6.28+rpt-rpi-v6
npm error gyp ERR! command "/opt/homebridge/bin/node" "/opt/homebridge/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /var/lib/homebridge/node_modules/bluetooth-hci-socket
npm error gyp ERR! node -v v20.18.0
npm error gyp ERR! node-gyp -v v10.2.0
npm error gyp ERR! not ok

@potipot
Copy link

potipot commented Dec 6, 2024

hi @hivenet-jakub I'm having the same issue. Did you manage to resolve it? What method did you use to install the homebridge-mi-hygrothermograph plugin?

@hivenet-jakub
Copy link
Author

I installed the plugin through the UI.
I have smiliar issues with https://www.npmjs.com/package/homebridge-mijia-thermometer. For that plugin I was able to get rid of the bluetooth_hci_socket.node related error but then I got Error: Cannot find module 'mkdirp'. I'm wondering if both plugins are even properly installed.

@potipot
Copy link

potipot commented Dec 7, 2024

Thank you for your reply.
Are you running Raspian in its vanilla state or did you select the homebridge specific os settings when flashing the sd card for your raspberry pi zero?

I flashed my zero2 using the home bridge version of raspbian so it has some preconfigured stuff. For example I realized there is homebridge specific npm and nodejs installation in

/opt/homebridge/bin/npm
/opt/homebridge/bin/node

which is not in $PATH by default.

What npm installation are you using to run the

npm install bluetooth-hci-socket --unsafe-perm

@potipot
Copy link

potipot commented Dec 23, 2024

If anyone is still having issues, mine was solved by installing older homebridge raspbian image :https://github.com/homebridge/homebridge-raspbian-image/releases/tag/v1.1.6

This from my experience has better compatibility with some plugins, like mi-hygrothermograph.

Package Version
NodeJS v18.19.0
Homebridge-Config-UI-X 4.55.1
Homebridge 1.7.0

Installing this plugin via homebridge-UI still shows some bluetooth errors but I simply ignored them and everything works flawlessly.

@javierhurtado
Copy link

javierhurtado commented Jan 3, 2025

Same problem here:

pi@raspberrypi:~$ node -v
v22.12.0
pi@raspberrypi:~$ npm -v
11.0.0
[3/1/2025, 12:43:56] ====================
[3/1/2025, 12:43:56] ERROR INITIALIZING PLUGIN homebridge-mi-hygrothermograph:
[3/1/2025, 12:43:56] Error: Cannot find module '../build/Release/bluetooth_hci_socket.node'
Require stack:
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/native.js
- /var/lib/homebridge/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/index.js

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

No branches or pull requests

3 participants