quentinms / homebridge-aranet4

An Homebridge plugin to get data from an Aranet4
Apache License 2.0
36 stars 1 forks source link

[Aranet4 Platform] errored while getting devices:Error: Bluetooth is not ready #18

Closed finestructure closed 1 year ago

finestructure commented 1 year ago

I'm unable to connect my Aranet4 accessory and the home bridge logs show the error:

[12/6/2022, 11:14:54 AM] [Aranet4 Platform] errored while getting devices:Error: Bluetooth is not ready

Plugin Config:

{
    "bridge": {
        "name": "Homebridge 47AE",
        "username": "xxxxx",
        "port": 51907,
        "pin": "xxxxx",
        "advertiser": "bonjour-hap"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "Aranet4 Platform",
            "co2AlertThreshold": 1006,
            "batteryAlertThreshold": 10,
            "sensorDataRefreshInterval": 300,
            "bluetoothReadyTimeout": 10,
            "bluetoothDeviceSearchTimeout": 10,
            "_bridge": {
                "username": "xxxxx",
                "port": 56655
            },
            "platform": "Aranet4"
        }
    ]
}

Environment:

I've paired the Aranet4 to the Mac via the Aranet4 iOS app running on the Mac.

The same error appears if the device is not paired.

I'm not sure if I've messed up the install or setup somehow, any help to debug this greatly appreciated!

finestructure commented 1 year ago

Well, it helps to open issues! I just had a thought after posting this and re-reading the message - what if this is about Bluetooth permissions? So I added node to the Bluetooth settings in "Privacy & Security"

CleanShot 2022-12-06 at 11 25 07@2x

and lo and behold on restart I get:

[12/6/2022, 11:24:38 AM] [Aranet4 Platform] Adding new accessory: Aranet4

and the device's info shows up in the Home app now:

IMG_7546804C1472-1 2

What's odd is that all sensor data seems to be reporting 0 🤔

finestructure commented 1 year ago

Ok, never mind, it seems this was just because the device hadn't reported a new reading yet and doesn't report via home bridge unless it does:

IMG_00D2DC101823-1

Thanks for ... listening 😄

and of course thanks for making this plugin!

quentinms commented 1 year ago

Thanks a lot for both the report and the solution! I haven't upgraded to the latest macOS yet which is why I had not run into this issue.

I'll update the readme so hopefully it'll help the next person who encounters this.

finestructure commented 1 year ago

I should add that it's not ideal that I have to grant effectively all node based processes Bluetooth access in this way. I'd much prefer if I could do this only for Homebridge-related processes but I suppose unless Homebridge bundled its own separate node binary this isn't really possible.

Is this worth raising somewhere? I guess this isn't specific to the Aranet4 plugin but relevant for all Homebridge plugins.