Lyliya / homebridge-ledstrip-ble

11 stars 12 forks source link

Trying to turn on/off the strip and getting an error #8

Closed grintroy closed 6 months ago

grintroy commented 8 months ago

I was trying to find the correct MAC address for my strip, and I think I found it, considering that it shows as ELK-BLEDOB both in hcitool lescan and the Lotus Lantern app:

BE:60:B0:00:88:21 ELK-BLEDOB

However, when I set it up in the config file, I'm getting an error. Please see my config file below (I am removing confidential info with ---).

{
    "bridge": {
        "name": "Homebridge 4412",
        "username": "---",
        "port": 51867,
        "pin": "---",
        "advertiser": "avahi"
    },
    "accessories": [
        {
            "accessory": "LedStrip",
            "name": "LED",
            "uuid": "be60b0008821"
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "platform": "config"
        },
        {
            "name": "Meross",
            "username": "---",
            "password": "---",
            "connection": "default",
            "ignoreHKNative": true,
            "ignoreMatter": true,
            "platform": "Meross"
        }
    ],
    "disabledPlugins": []
}

The error I'm getting in Homebridge logs is below:

Error: Command Disallowed (0xc)
    at NobleBindings.onLeConnComplete (/var/lib/homebridge/node_modules/@lyliya/homebridge-ledstrip-ble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:312:13)
    at Hci.emit (node:events:517:28)
    at Hci.processCmdStatusEvent (/var/lib/homebridge/node_modules/@lyliya/homebridge-ledstrip-ble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:1255:12)
    at Hci.onSocketData (/var/lib/homebridge/node_modules/@lyliya/homebridge-ledstrip-ble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:789:12)
    at BluetoothHciSocketWrapped.emit (node:events:517:28)
noble: unknown peripheral null connected!
Lyliya commented 7 months ago

Hey @grintroy Sorry for the late response, this plugin has been deprecated as I don't use it anymore, I migrated to Home Assistant. But this error seems familiar, have you tried connecting to your ledstrip using bluetoothctl ?

# Run bluetoothctl
> bluetoothctl

> connect BE:60:B0:00:88:21

If you have the same errors, check that you have not too much paired devices

> bluetoothctl
> paired-devices
grintroy commented 7 months ago

Thanks @Lyliya I will try this in a week after getting my hands back on this LED strip. You mentioned that you migrated to Home Assistant, so is there a plugin for LED strips on Home Assistant as well?

Lyliya commented 7 months ago

Yes, I used https://github.com/dave-code-ruiz/elkbledom that work really well with the LED strip I had, and was more reliable on bluetooth connect / disconnect But I quickly changed my LED Strip to make one that support https://kno.wled.ge/, which as a really good integration, both on Homebridge and Home Assistant. That's why I dont actively support this plugin anymore

grintroy commented 7 months ago

@Lyliya thanks. My Pi connects to the strip through bluetoothctl without any problem.

I also just tried to reinstall the plugin and re-add the device, and it finally works! Probably was a mistake from my side at the first place.

grintroy commented 7 months ago

@Lyliya sorry, it's acting weird again. When I tried it for the first time today, it worked, but now it stopped. The commands show up in Homebridge Logs, bluetoothctl devices show that it's connected, bluetoothctl connect BE:60:B0:00:88:21 confirms it.

But the led strip isn't reacting to commands at all, just as before. There are, luckily, no errors, but I still can't control the strip. After reinstalling the plugin again, it works. But I'm afraid it will stop working again.

Also, there was a message in the console when it started working again:

[
  Characteristic {
    _noble: Noble {
      initialized: true,
      address: 'd8:3a:dd:a3:d2:ab',
      _state: 'poweredOn',
      _bindings: [NobleBindings],
      _peripherals: [Object],
      _services: [Object],
      _characteristics: [Object],
      _descriptors: [Object],
      _discoveredPeripheralUUids: [Object],
      _events: [Object: null prototype],
      _eventsCount: 4,
      _allowDuplicates: undefined
    },
    _peripheralId: 'be60b0008821',
    _serviceUuid: 'fff0',
    uuid: 'fff3',
    name: null,
    type: null,
    properties: [ 'read', 'writeWithoutResponse' ],
    descriptors: null
  }
]

Then, with each command, it wrote Write: <Buffer 7e 00 04 01 00 00 00 00 ef>, each time with different data bits.

Lyliya commented 7 months ago

That's weird The log are ok, the first one is just a summary of what is discovered on your bluetooth network The buffer are what are send to the LED controller, here power on

My guess it's it has been disconnected, and cannot reconnect, I will try to find my ledstrip and try to fix it this week end

Lyliya commented 7 months ago

@grintroy In the meantime, I have published a version with more log on discover, connect and disconnect, can you try again. My led are dead but the controller still work, I will try to hook it to a multimeter to try it and debug it, I also need to boot up a new Homebridge installation

Lyliya commented 7 months ago

After some testing, it appear that the bluetooth connection freeze between my adapter and the LED controller, preventing any discover / reconnection. A fix is to restart the bluetooth from the host, but not ideal at all

grintroy commented 7 months ago

@Lyliya thank you for the new version. Before the update, it disconnected again and although my ledstrip was discoverable using hcitool lescan, I couldn't connect to it using bluetoothctl. After the update and Homebridge reload, it connected successfully. I'll continue using it for a bit more and will keep you updated.

Lyliya commented 6 months ago

Hey @grintroy , did you get any issues recently or did this fix worked ?

grintroy commented 6 months ago

Hey @Lyliya sorry to keep you waiting. But unfortunately nothing worked. I also migrated to Home Assistant, but the component you referenced didn’t work either (https://github.com/dave-code-ruiz/elkbledom/issues/59). My controller didn’t even respond to the primary and characteristics commands.

I also bought an another controller which works with Tuya platform through Wi-Fi, but it’s not working with my strip either. For this one, I was supplying it with 5V on USB, but it kept restarting every half a second. So I’m assuming that the Tuya controller needed more current which my USB couldn’t provide, while my original BLE controller didn’t require as much current but had an unusual API.

Anyways, I’m not sure what my next steps are going to be with this LED strip and a bunch of controllers I now have. Perhaps the most logical thing would be to buy a bit more expensive strip/controller (maybe 12V through a proper power supply) and do some more research, but for now, I’m going to take a break from tinkering with my weird LED strips.

Thank you for your help and time, though.