asednev / homebridge-plugin-govee

Govee H-series Thermometer Hygrometer plugin for Homebrige.
Apache License 2.0
53 stars 9 forks source link

Can't Start Device Search Process in Homebridge Docker Setup #46

Closed mhellmeier closed 2 years ago

mhellmeier commented 2 years ago

Describe The Bug:

When running homebridge with docker / docker-compose, the plugin doesn't work. In Debug mode, the error Could not start scanning, state is unsupported (not poweredOn) appears when homebridge boots up. I also tried to run homebridge with the -privileged and --net=host flags but it still throws the error. The Bluetooth dongle works as expected!

A found similar issues from other (homebridge) projects that might help: https://github.com/hannseman/homebridge-mi-hygrothermograph/issues/48 https://github.com/noble/noble/issues/228

To Reproduce:

  1. Install homebridge via docker / docker-compose
  2. Install homebridge-plugin-govee
  3. Restart homebridge
  4. Error occurs
  5. Homebridge automatically restarts
  6. Error occurs again
  7. Homebridge automatically restarts
  8. ...

Expected behavior:

The scanning process should work with a docker / docker-compose setup.

Logs:

Full error log in Debug mode:

Error: Could not start scanning, state is unsupported (not poweredOn)
    at Noble.scan (/homebridge/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/noble.js:107:21)
    at Object.onceWrapper (node:events:510:26)
    at Noble.emit (node:events:390:28)
    at Noble.onStateChange (/homebridge/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/noble.js:87:8)
    at NobleBindings.emit (node:events:390:28)
    at NobleBindings.onStateChange (/homebridge/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:125:8)
    at Hci.emit (node:events:402:35)
    at Hci.processCmdCompleteEvent (/homebridge/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/hci-socket/hci.js:699:12)
    at Hci.onSocketData (/homebridge/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/hci-socket/hci.js:567:12)
    at BluetoothHciSocket.emit (node:events:390:28)

Plugin Config:

Default

Environment:

asednev commented 2 years ago

@mhellmeier There is no magic bullet with Docker because the container needs access to BLE device. As the error suggests, your container doesn't detect BLE thus it can't work.

mhellmeier commented 2 years ago

Thanks a lot for your response, @asednev As mentioned in the issue description above, the Bluetooth dongle works as expected.

The following picture shows the internal homebridge UI command-line tool. I am able to successfully start Bluetooth and find my Govee H5102 device (I censored some IDs): bluetooth-homebridge

Therefore, the problem must be related to the plugin. Maybe it have to wait until Bluetooth is ready as mentioned in this noble issue? https://github.com/noble/noble/issues/228#issuecomment-130784841

mhellmeier commented 2 years ago

Ok, I just found the reason for the problem. As shown in the screenshot above, I am using two Bluetooth controllers. The first one (default) doesn't support BLE while the second one does. Noble doesn't recognize this and fails with the above-mentioned error.

Removing the Bluetooth dongle that doesn't support BLE solves the problem.

Would be nice to see an update on the README that the plugin only works with one single Bluetooth device that supports BLE.