hannseman / homebridge-mi-hygrothermograph

Homebridge plugin for the Xiaomi Mi Bluetooth Temperature and Humidity Sensor
MIT License
269 stars 50 forks source link

Error Initializing Plugin #201

Open hivenet-jakub opened 2 hours ago

hivenet-jakub commented 2 hours ago

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 -fwhich 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 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 commented 2 hours ago

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