hannseman / homebridge-mi-hygrothermograph

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

Hygrothermograph 2 / LYWSD03MMC cannot be detected #106

Closed comcaptain closed 4 years ago

comcaptain commented 4 years ago

Expected Behavior

Homebridge is able to find my Hygrothermograph 2

Current Behavior

Homebridge is not able to find my Hygrothermograph 2. In homebridge log:

[5/24/2020, 12:52:25 AM] [Temperature & Humidity] Initializing Hygrotermograph accessory...
[5/24/2020, 12:52:25 AM] [Temperature & Humidity] Start scanning.

Then no more log lines appear...

Steps to Reproduce (for bugs)

Nothing special, install this plugin, config it, then restart homebridge

Versions

Configuration

    "accessories": [
        {
            "name": "Temperature & Humidity",
            "accessory": "Hygrotermograph",
            "address": "A4:C1:38:xx:xx:xx",
            "bindKey": "AB3198E7AF704987025XXXXXXXXXXXX"
        }
    ]

I got bindKey by following this instruction

I specified address because I have multiple Hygrothermograph 2 devices

Homebridge Log / Command Output

[5/24/2020, 12:52:21 AM] [HB Supervisor] Starting Homebridge with extra flags: -I
[5/24/2020, 12:52:21 AM] [HB Supervisor] Started Homebridge v1.1.0 with PID: 7692
[5/24/2020, 12:52:22 AM] Loaded config.json with 1 accessories and 1 platforms.
[5/24/2020, 12:52:22 AM] ---
[5/24/2020, 12:52:23 AM] Loaded plugin: homebridge-config-ui-x@4.20.0
[5/24/2020, 12:52:23 AM] Registering platform 'homebridge-config-ui-x.config'
[5/24/2020, 12:52:23 AM] ---
[5/24/2020, 12:52:23 AM] Loaded plugin: homebridge-mi-hygrothermograph@3.0.0
[5/24/2020, 12:52:25 AM] Registering accessory 'homebridge-mi-hygrothermograph.Hygrotermograph'
[5/24/2020, 12:52:25 AM] ---
[5/24/2020, 12:52:25 AM] Loading 1 platforms...
[5/24/2020, 12:52:25 AM] [Config] Initializing config platform...
[5/24/2020, 12:52:25 AM] [Config] Running in Service Mode
[5/24/2020, 12:52:25 AM] Loading 1 accessories...
[5/24/2020, 12:52:25 AM] [Temperature & Humidity] Initializing Hygrotermograph accessory...
Setup Payload:
X-HM://XXXXXXXXXXX
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ XXX-XX-XXX │     
    └────────────┘     

[5/24/2020, 12:52:25 AM] Homebridge is running on port 51694.
[5/24/2020, 12:52:25 AM] [Temperature & Humidity] Start scanning.
hannseman commented 4 years ago

Thanks for your report, duplicate of #101

hannseman commented 4 years ago

Sorry I was a bit quick there, can you check your logs for "Unsupported state or unable to authenticate data"?

comcaptain commented 4 years ago

@hannseman Thanks for your quick reply. No, "Unsupported state or unable to authenticate data" does not exist in my log. In fact there is no error or exception at all in my log

pi@raspberrypi:/var/lib/homebridge $ grep 'Unsupported state or unable to authenticate data' homebridge.log
pi@raspberrypi:/var/lib/homebridge $

BTW, the log I pasted in "Homebridge Log / Command Output" is all the log I have after HM starts up

hannseman commented 4 years ago

If you’re not running homebridge as root make sure that you’ve granted the node binary cap_net_raw privileges:

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
comcaptain commented 4 years ago

@hannseman Just tried your command

pi@raspberrypi:/var/lib/homebridge $ sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
pi@raspberrypi:/var/lib/homebridge $

But it still doesn't work. Then I tried to start homebridge as root:

pi@raspberrypi:/var/lib/homebridge $ sudo hb-service stop
ℹ Stopping Homebridge Service...
✔ Homebridge Stopped
pi@raspberrypi:/var/lib/homebridge $ sudo su - root
root@raspberrypi:~# sudo hb-service start
ℹ Starting Homebridge Service...
✔ Homebridge Started

Initially, my "Home" app still shows Hygrothermograph as not responsive. Then I switch IOS system language from Chinese to English. And all of a sudden it works! Then I stopped the HW service and switch to PI user and start HM:

root@raspberrypi:~# sudo hb-service stop
ℹ Stopping Homebridge Service...
✔ Homebridge Stopped
root@raspberrypi:~# exit
logout
pi@raspberrypi:/var/lib/homebridge $ sudo hb-service start
ℹ Starting Homebridge Service...
✔ Homebridge Started

Then it doesn't work any more even if I change IOS system language forth and back. Then stop HM, switch to root and start HM again. Again it doesn't work any more even if I change IOS system language forth and back...

pi@raspberrypi:/var/lib/homebridge $ sudo hb-service stop
ℹ Stopping Homebridge Service...
✔ Homebridge Stopped
pi@raspberrypi:/var/lib/homebridge $ sudo su - root
root@raspberrypi:~# sudo hb-service start
ℹ Starting Homebridge Service...
✔ Homebridge Started

Then I suspect maybe my Hygrothermograph is broken. But I checked again and it works perfectly in Mi Home app...

In summary: It magically worked once when I start HW as root. But then it no longer works even if I start HW as root again

And the HW log is always the same across all those restarts, even for the restart that works. It's always stuck here:

[5/24/2020, 3:36:41 PM] [Temperature & Humidity] Start scanning.
hannseman commented 4 years ago

I just released a new version (3.0.1) with updates to the bluetooth library. Please give it a shot.

comcaptain commented 4 years ago

@hannseman That's quick. Thanks!

Before releasing your new version, I found that Home app can recognize Hygrothermograph. The last restart of HM was done as root and I did nothing but to leave it there for a couple of hours. Although it worked but log was still stuck there:

[5/24/2020, 3:36:41 PM] [Temperature & Humidity] Start scanning.

Then I removed your plugin in HM website, then install the new version as pi:

pi@raspberrypi:/var/lib/homebridge $ sudo npm install --g --unsafe-perm homebridge-mi-hygrothermograph@latest

> usb@1.6.3 install /usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/usb
> prebuild-install --verbose || node-gyp rebuild

prebuild-install info begin Prebuild-install version 5.3.4
prebuild-install info looking for cached prebuild @ /root/.npm/_prebuilds/470134-usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install http request GET https://github.com/tessel/node-usb/releases/download/v1.6.3/usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install http 404 https://github.com/tessel/node-usb/releases/download/v1.6.3/usb-v1.6.3-node-v72-linux-arm.tar.gz
prebuild-install WARN install No prebuilt binaries found (target=12.16.3 runtime=node arch=arm libc= platform=linux)
make: Entering directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/usb/build'
  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
  CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o
  CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o
  CC(target) Release/obj.target/libusb/libusb/libusb/io.o
  CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o
  CC(target) Release/obj.target/libusb/libusb/libusb/sync.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/poll_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o
  CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_udev.o
  AR(target) Release/obj.target/usb.a
  COPY Release/usb.a
  CXX(target) Release/obj.target/usb_bindings/src/node_usb.o
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from ../src/node_usb.h:14,
                 from ../src/node_usb.cc:1:
../src/node_usb.cc: At global scope:
/root/.cache/node-gyp/12.16.3/include/node/node.h:608:43: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
       (node::addon_register_func) (regfunc),                          \
                                           ^
/root/.cache/node-gyp/12.16.3/include/node/node.h:642:3: note: in expansion of macro ‘NODE_MODULE_X’
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/node_usb.cc:95:1: note: in expansion of macro ‘NODE_MODULE’
 NODE_MODULE(usb_bindings, Initialize)
 ^~~~~~~~~~~
../src/node_usb.cc: In function ‘void handleHotplug(std::pair<libusb_device*, libusb_hotplug_event>)’:
../src/node_usb.cc:151:58: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, const char*, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
  Nan::MakeCallback(Nan::New(hotplugThis), "emit", 2, argv);
                                                          ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h:1001:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
../src/node_usb.cc:151:58: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, const char*, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
  Nan::MakeCallback(Nan::New(hotplugThis), "emit", 2, argv);
                                                          ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/node_usb.cc:1:
../node_modules/nan/nan.h:1001:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
In file included from ../src/node_usb.h:12,
                 from ../src/node_usb.cc:1:
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]’:
/root/.cache/node-gyp/12.16.3/include/node/node_object_wrap.h:85:78:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../node_modules/nan/nan_object_wrap.h:65:61:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
  CXX(target) Release/obj.target/usb_bindings/src/device.o
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/device.cc:1:
../node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
../src/device.cc: In member function ‘void Req::submit(Device*, v8::Local<v8::Function>, uv_work_cb, uv_work_cb)’:
../src/device.cc:220:70: warning: cast between incompatible function types from ‘uv_work_cb’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
   uv_queue_work(uv_default_loop(), &req, backend, (uv_after_work_cb) after);
                                                                      ^~~~~
../src/device.cc: In static member function ‘static void Req::default_after(uv_work_t*)’:
../src/device.cc:237:64: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
    Nan::MakeCallback(device, Nan::New(baton->callback), 1, argv);
                                                                ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/device.cc:1:
../node_modules/nan/nan.h:959:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
../src/device.cc:237:64: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
    Nan::MakeCallback(device, Nan::New(baton->callback), 1, argv);
                                                                ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/device.cc:1:
../node_modules/nan/nan.h:959:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
In file included from ../src/node_usb.h:12,
                 from ../src/device.cc:1:
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]’:
/root/.cache/node-gyp/12.16.3/include/node/node_object_wrap.h:85:78:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../node_modules/nan/nan_object_wrap.h:65:61:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
  CXX(target) Release/obj.target/usb_bindings/src/transfer.o
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/transfer.cc:1:
../node_modules/nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../node_modules/nan/nan.h:2232:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
../src/transfer.cc: In function ‘void handleCompletion(Transfer*)’:
../src/transfer.cc:126:72: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
   Nan::MakeCallback(self->handle(), Nan::New(self->v8callback), 3, argv);
                                                                        ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/transfer.cc:1:
../node_modules/nan/nan.h:959:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
../src/transfer.cc:126:72: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
   Nan::MakeCallback(self->handle(), Nan::New(self->v8callback), 3, argv);
                                                                        ^
In file included from ../src/helpers.h:3,
                 from ../src/node_usb.h:21,
                 from ../src/transfer.cc:1:
../node_modules/nan/nan.h:959:46: note: declared here
   NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
                                              ^~~~~~~~~~~~
In file included from ../src/node_usb.h:12,
                 from ../src/transfer.cc:1:
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)]’:
/root/.cache/node-gyp/12.16.3/include/node/node_object_wrap.h:85:78:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<node::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<node::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
                reinterpret_cast<Callback>(callback), type);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.cache/node-gyp/12.16.3/include/node/v8.h: In instantiation of ‘void v8::PersistentBase<T>::SetWeak(P*, typename v8::WeakCallbackInfo<P>::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo<P>::Callback = void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)]’:
../node_modules/nan/nan_object_wrap.h:65:61:   required from here
/root/.cache/node-gyp/12.16.3/include/node/v8.h:10226:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfo<Nan::ObjectWrap>::Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<Nan::ObjectWrap>&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo<void>&)’} [-Wcast-function-type]
  SOLINK_MODULE(target) Release/obj.target/usb_bindings.node
  COPY Release/usb_bindings.node
make: Leaving directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/usb/build'

> @abandonware/bluetooth-hci-socket@0.5.3-5 install /usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/abandonware/node-bluetooth-hci-socket/releases/download/0.5.3-5/binding-0.5.3-5-node-v72-linux-arm.tar.gz
node-pre-gyp WARN Pre-built binaries not found for @abandonware/bluetooth-hci-socket@0.5.3-5 and node@12.16.3 (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/build'
  CXX(target) Release/obj.target/binding/src/BluetoothHciSocket.o
In file included from ../src/BluetoothHciSocket.cpp:8:
../../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../../nan/nan.h:2294:62: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
                                                              ^
In file included from /root/.cache/node-gyp/12.16.3/include/node/node_buffer.h:25,
                 from ../src/BluetoothHciSocket.cpp:7:
../src/BluetoothHciSocket.cpp: At global scope:
/root/.cache/node-gyp/12.16.3/include/node/node.h:608:43: 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]
       (node::addon_register_func) (regfunc),                          \
                                           ^
/root/.cache/node-gyp/12.16.3/include/node/node.h:642:3: note: in expansion of macro ‘NODE_MODULE_X’
   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
   ^~~~~~~~~~~~~
../src/BluetoothHciSocket.cpp:578:1: note: in expansion of macro ‘NODE_MODULE’
 NODE_MODULE(binding, BluetoothHciSocket::Init);
 ^~~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/binding.node
  COPY Release/binding.node
  COPY /usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/lib/binding/binding.node
  TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/bluetooth-hci-socket/build'

> @abandonware/noble@1.9.2-9 install /usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble
> node-gyp rebuild

make: Entering directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/build'
  SOLINK_MODULE(target) Release/obj.target/noble.node
  COPY Release/noble.node
make: Leaving directory '/usr/local/lib/node_modules/homebridge-mi-hygrothermograph/node_modules/@abandonware/noble/build'
+ homebridge-mi-hygrothermograph@3.0.1
added 185 packages from 175 contributors in 71.419s

Then I tried to restart HM several times as pi or root. And it only worked once when I restart HM as root. After the successful restart, I restart HM 2 more times as root, and it no longer works

And the HM log is still same as before across multiple restarts, stuck here:

[5/24/2020, 9:11:39 PM] [Temperature & Humidity] Start scanning.
hannseman commented 4 years ago

Regarding the log [5/24/2020, 9:11:39 PM] [Temperature & Humidity] Start scanning, that’s expected and nothing that’s stuck. If you want more output you can start homebridge with the debug flag homebridge -D.

Since it works when you run homebridge as root I’m pretty sure that it’s a permission issue or that the capability have not been set correctly on the node binary.

I would try running this again:

sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
comcaptain commented 4 years ago

@hannseman Got it. Thanks.

Do you know how to specify -D with hb-service command? I ran sudo hb-service start -D but not sure whether it's correct

I just ran sudo setcap cap_net_raw+eip $(eval readlink -fwhich node) again and started HM as pi

pi@raspberrypi:~ $ sudo hb-service start -D
ℹ Starting Homebridge Service...
✔ Homebridge Started

Now home app recognizes my device within minutes! Thanks a lot, I think it's resolved now :)

I'll try to connect to other Hygrothermograph devices

hannseman commented 4 years ago

I think you can enable debug mode in the GUI: https://github.com/oznu/homebridge-config-ui-x/wiki/Config-Options#debug

Jut don’t forget to turn it off when everything works as expected or else your disk space will drain pretty quickly.

I’m closing this issue as everything looks fine now.

Lars83 commented 4 years ago

@comcaptain Hello I have the same problem as you and have already tried everything possible but can't get any further and my sensors are all in the home app for no answer. Could you tell me step by step how you proceeded to get the sensors running again.

Lars83 commented 4 years ago

@comcaptain @hannseman Hello I have the same problem as you and have already tried everything possible but can't get any further and my sensors are all in the home app for no answer. Could you tell me step by step how you proceeded to get the sensors running again.