asednev / homebridge-plugin-govee

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

Could not start scanning, state is unauthorized (not poweredOn) #74

Closed 2bsc closed 1 year ago

2bsc commented 2 years ago

Hi there, this problem started a few months ago after updating macOS, suddenly the plugin was not able to connect to the bluetooth module (it seems) anymore. I deactivated the plugin at the time, so homebridge wasn't looping anymore, and I was hoping some update would fix it ... The prerequisites were followed, new Xcode install, Terminal has permissions to access bluetooth, did a fresh reinstall of node.js and homebridge today, but no success. Do you have any ideas? Any help would be appreciated! Best regards

Homebridge logs:

 Error: Could not start scanning, state is unauthorized (not poweredOn)
    at Noble.scan (/usr/local/lib/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/noble.js:120:21)
    at Object.onceWrapper (node:events:642:26)
    at Noble.emit (node:events:527:28)
    at Noble.onStateChange (/usr/local/lib/node_modules/homebridge-plugin-govee/node_modules/@abandonware/noble/lib/noble.js:88:8)
    at NobleMac.emit (node:events:527:28)
[8/31/2022, 6:29:42 PM] Got SIGTERM, shutting down Homebridge...
[8/31/2022, 6:29:47 PM] [Homebridge UI] Changes to config.json saved.
[8/31/2022, 6:29:47 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[8/31/2022, 6:29:52 PM] [HB Supervisor] Restarting Homebridge...

Homebridge config:


{
    "bridge": {
        "name": "Homebridge XXXX",
        "username": "00:00:00:00:00:00",
        "port": XXXXX,
        "pin": "XXX-XX-XXX",
        "advertiser": "bonjour-hap"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": XXXX,
            "platform": "config"
        },
        {
            "name": "Govee",
            "batteryThreshold": 25,
            "debug": false,
            "humidityOffset": 0,
            "platform": "GoveeHomebridgePlugin"
        }
    ],
    "disabledPlugins": []
}

Environment:

asednev commented 2 years ago

@2bsc While I haven't experienced this myself, it's worth taking a look at this: https://github.com/abandonware/noble#sandboxed-terminal

Perhaps allow listing Homebridge in "System Preferences" —> "Security & Privacy" —> "Bluetooth" will help.

2bsc commented 2 years ago

I've seen this before and Terminal already had full access rights to Bluetooth, but this unfortunately didn't solve the issue. But just to confirm, how could I test if I'm getting an "Abort trap: 6", as the logs don't show such statement? Is there a more specific file/application that I could give Bluetooth access to, to circumvent the problem?

asednev commented 2 years ago

@2bsc To be clear, while directions are specific to Terminal this method can be extended to Node. Homebridge is a node application so what I would recommend is making sure that node process has been added to allow list for Bluetooth.

Also, I am connecting the dots here because Mac OS has been stepping up the security. The fact that your process can't access bluetooth seems security related.

2bsc commented 1 year ago

Sorry for the late response, but I just revisited the problem... after trying around a bunch it was resolved by adding node located in /usr/local/bin/ to the Bluetooth allow list in System Preferences. Homebridge alone did not work. More importantly, the administrator account must be logged in.