renssies / homebridge-am43-blinds

A homebridge plugin to control the AM43 based blind motors in HomeKit
MIT License
18 stars 6 forks source link

Conflicting with other BLE plugins. #31

Open Jacksonbm1 opened 3 years ago

Jacksonbm1 commented 3 years ago

Hello, I'm using the plugin right now, but every time I turn it and my switchbot plugin on, I start getting errors. Turning off one or the other allows this the plugins to work correctly.

Here's the switchbot plugin I'm running.

CONFIG (redacted irrelevant parts):

    "accessories": [
        {
            "name": "door",
            "retries": 5,
            "macAddress": "DB:EE:1B:F9:F1:2A",
            "accessory": "SwitchBot-For-Mac"
        },
        {
            "name": "door-auto-off",
            "stateful": false,
            "reverse": false,
            "time": 3000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "Lights-on (day)",
            "stateful": false,
            "reverse": false,
            "time": 1000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "Lights-on (red)",
            "stateful": false,
            "reverse": false,
            "time": 1000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "Lights-on (orange)",
            "stateful": false,
            "reverse": false,
            "time": 1000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "Lights-on (adaptive)",
            "stateful": false,
            "reverse": false,
            "time": 1000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "Z-Morning-lights",
            "stateful": false,
            "reverse": false,
            "time": 1000,
            "resettable": false,
            "accessory": "DummySwitch"
        },
        {
            "name": "freezer",
            "model": "not in list - try it anyway",
            "loglevel": 4,
            "accessory": "InkbirdBtTHSensor"
        }
    ],
    "platforms": [
        {
            "allowed_devices": [
                "02:46:bd:af:f2:ae"
            ],
            "scanning_timeout": 8,
            "hap_interaction_timeout": 90,
            "poll_interval": 300,
            "platform": "am43-blinds"
        }
    ],
}

Logs


Preparing Advertiser for '***' using bonjour-hap backend!
Setup Payload:
X-HM://0024LBU9UAYQD
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

[5/9/2021, 7:36:02 PM] [door] WoHand (DB:EE:1B:F9:F1:2A) was discovered
[5/9/2021, 7:36:09 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 0 devices
[5/9/2021, 7:36:11 PM] [am43-blinds] Started scanning for AM43 blinds, stopping in 5 seconds
[5/9/2021, 7:36:14 PM] [am43-blinds] Found known AM43 Motor: Master Bedroom (02:46:bd:af:f2:ae)
[5/9/2021, 7:36:16 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices
noble: unknown peripheral 0246bdaff2ae connected!
[5/9/2021, 7:36:17 PM] TypeError: Cannot set property 'mtu' of undefined
    at Noble.onMtu (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/noble.js:585:18)
    at NobleBindings.emit (events.js:315:20)
    at NobleBindings.onMtu (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:291:8)
    at Gatt.emit (events.js:315:20)
    at Object.callback (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:329:10)
    at Gatt.onAclStreamData (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/gatt.js:133:26)
    at AclStream.emit (events.js:327:22)
    at AclStream.push (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/acl-stream.js:33:10)
    at NobleBindings.onAclDataPkt (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:302:15)
    at Hci.emit (events.js:315:20)
    at Hci.onSocketData (/usr/lib/node_modules/homebridge-switchbot-for-mac/node_modules/@abandonware/noble/lib/hci-socket/hci.js:631:14)
    at BluetoothHciSocket.emit (events.js:315:20)
[5/9/2021, 7:36:17 PM] Got SIGTERM, shutting down Homebridge...
[5/9/2021, 7:36:17 PM] [am43-blinds] Homebridge is shutting down, disconnecting AM43 motors and saving state
noble: unknown peripheral 0246bdaff2ae disconnected!
[5/9/2021, 7:36:20 PM] [Homebridge UI] Homebridge restart request received
[5/9/2021, 7:36:20 PM] [Homebridge UI] UI / Bridge settings have not changed; only restarting Homebridge process
[5/9/2021, 7:36:20 PM] [Homebridge UI] Sending SIGTERM to Homebridge
[5/9/2021, 7:36:22 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[5/9/2021, 7:36:27 PM] [HB Supervisor] Restarting Homebridge...
[5/9/2021, 7:36:27 PM] [HB Supervisor] Starting Homebridge with extra flags: -I
[5/9/2021, 7:36:27 PM] [HB Supervisor] Started Homebridge v1.3.4 with PID: 3146
Initializing HAP-NodeJS v0.9.4...
neil-morrison44 commented 3 years ago

This is probably unavoidable due to the way noble works where it's a shared resource: if plugin A starts listening for discovered devices & plugin B starts discovering devices then plugin A will be notified about the ones discovered in plugin B's discovery step.

Since noble is still the best node cross platform BLE library, even though the original developers abandoned it, all BLE homebridge plugins will likely suffer from some level of cross-talk & the bugs that present themselves from that.

Jacksonbm1 commented 3 years ago

So if you were to have one plug in (like yours) with multiple devices, do you think this issue would persist? I imagine people often want more than one device and aren’t using a dedicated pi for each device

neil-morrison44 commented 3 years ago

"Each device" being an AM43 motor or "each device" being different BLE devices?

This plug-in can support as many AM43 devices as whatever's hosting your Homebridge can support (which for the Pi's built in Bluetooth is 10 I think).

If you're talking about different devices then yeah, until someone writes a better low level library for communicating to BLE from node JS then I think there's always going to be cross-talk causing bugs that are very hard to replicate.

Running separate child Homebridges on one device might be enough but if noble works the way I think it does then I doubt it'd help much.