OpenWonderLabs / homebridge-switchbot

The Homebridge SwitchBot plugin allows you to access your SwitchBot Device(s) from HomeKit. Homebridge.
https://openwonderlabs.github.io/homebridge-switchbot/
ISC License
239 stars 52 forks source link

Bug: wasn't able to establish BLE Connection, node-switchbot: false #626

Closed adamstamper closed 1 year ago

adamstamper commented 1 year ago

Describe The Bug

homebridge-switchbot no longer functions (it used to work!) - shows error "wasn't able to establish BLE Connection, node-switchbot: false"

To Reproduce

Install

Expected behavior

Switches control bot

Relevant log output

[21/12/2022, 17:27:06] [SwitchBot] [DEBUG] Bot: Gate BLE Address: fb:d6:f8:xx:xx:xx
[21/12/2022, 17:27:06] [SwitchBot] Bot: Gate wasn't able to establish BLE Connection, node-switchbot: false
[21/12/2022, 17:27:06] Homebridge v1.6.0 (HAP v0.11.0) (Adam_Flat) is running on port 51413.
[21/12/2022, 17:29:06] [SwitchBot] [DEBUG] Bot: Gate BLERefreshStatus
[21/12/2022, 17:29:06] [SwitchBot] Was 'node-switchbot' found: false
[21/12/2022, 17:29:06] [SwitchBot] [DEBUG] Bot: Gate BLE Address: fb:d6:f8:xx:xx:xx
[21/12/2022, 17:29:06] [SwitchBot] Bot: Gate wasn't able to establish BLE Connection, node-switchbot: false

I tried removing and re-adding the plugin and have captured some errors visible during the installation:

USER: pi
DIR: /var/lib/homebridge
CMD: npm install --save @switchbot/homebridge-switchbot@2.3.2

(##################) ⠧ reify:googleapis: timing reifyNode:node_modules/@switchbot/home
> @abandonware/bluetooth-hci-socket@0.5.3-9 install
> node-pre-gyp install --fallback-to-build --update-binary

node-pre-gyp ERR! install response status 404 Not Found on https://github.com/abandonware/node-bluetooth-hci-socket/releases/download/0.5.3-9/bluetooth_hci_socket-0.5.3-9-node-v108-linux-arm.tar.gz 
make: Entering directory '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@abandonware/bluetooth-hci-socket/build'
  CXX(target) Release/obj.target/bluetooth_hci_socket/src/BluetoothHciSocket.o
In file included from /home/pi/.cache/node-gyp/18.12.1/include/node/node_buffer.h:25,
                 from ../src/BluetoothHciSocket.cpp:7:
/home/pi/.cache/node-gyp/18.12.1/include/node/node.h:976:7: warning: cast between incompatible function types from ‘void (*)(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’ {aka ‘void (*)(v8::Local<v8::Object>)’} to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)’} [-Wcast-function-type]
  976 |       (node::addon_register_func) (regfunc),                          \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pi/.cache/node-gyp/18.12.1/include/node/node.h:1010:3: note: in expansion of macro ‘NODE_MODULE_X’
 1010 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/BluetoothHciSocket.cpp:740:1: note: in expansion of macro ‘NODE_MODULE’
  740 | NODE_MODULE(binding, BluetoothHciSocket::Init);
      | ^~~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/bluetooth_hci_socket.nodees/@switchbot/home
  COPY Release/bluetooth_hci_socket.node timing reifyNode:node_modules/@switchbot/home
  COPY /var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@abandonware/bluetooth-hci-socket/lib/binding/bluetooth_hci_socket.node
  TOUCH Release/obj.target/action_after_build.stampfyNode:node_modules/@switchbot/home
make: Leaving directory '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@abandonware/bluetooth-hci-socket/build'
(##################) ⠋ reify:googleapis: timing reifyNode:node_modules/@switchbot/home
> @abandonware/noble@1.9.2-15 install
> node-gyp rebuild

make: Entering directory '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@abandonware/noble/build'
  SOLINK_MODULE(target) Release/obj.target/noble.node
  COPY Release/noble.nodeify:googleapis: timing reifyNode:node_modules/@switchbot/home
make: Leaving directory '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/@abandonware/noble/build'

> usb@1.9.2 install
> node-gyp-build

make: Entering directory '/var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/usb/build'
  CC(target) Release/obj.target/libusb/libusb/libusb/core.o
(##################) ⠦ reify:googleapis: timing reifyNode:node_modules/@switchbot/home

Config for homebridge-switchbot

{
            "name": "SwitchBot",
            "credentials": {
                "notice": "Keep your Token & Secret a secret!"
            },
            "options": {
                "devices": [
                    {
                        "deviceId": "FBD6F8XXXXXX",
                        "configDeviceName": "Gate",
                        "configDeviceType": "Bot",
                        "connectionType": "BLE",
                        "bot": {
                            "mode": "press",
                            "deviceType": "garagedoor",
                            "doublePress": 1
                        },
                        "logging": "debug"
                    }
                ]
            },
            "platform": "SwitchBot"
        }

Screenshots

No response

Device & Model

SwitchBot bot

Node.js Version

v18.12.1

NPM Version

v8.19.2

Homebridge Version

v1.6.0

Homebridge Switchbot Plugin Version

v2.3.2

Homebridge Config UI X Plugin Version

v4.50.2

Operating System

Raspbian GNU/Linux Bullseye (11)

martindinicolino commented 1 year ago

I'm seeing the same, hopefully there will be a fix soon

alevehemens commented 1 year ago

Same problem unfortunately. I hope to fix it 😭

donavanbecker commented 1 year ago

Can you try the latest beta:

npm version

Click here to find out how to install Beta

alevehemens commented 1 year ago

Problem persist, I think is node version or maybe abadonware error the issue. However I have 18.2.1 as node, but which version of node is recommend for latest version stable of SwitchBot? Thanks donavabecker for your help!

dnicolson commented 1 year ago

The beta isn't needed to resolve the issue, simply reinstalling v2.3.2 will install v1.7.2 of the node-switchbot dependency which contains the fix.

donavanbecker commented 1 year ago

@dnicolson Beta has node-SwitchBot 1.7.2 as dependency.

dnicolson commented 1 year ago

v2.3.2 has ^1.7.0 of node-switchbot as a dependency, so v1.7.2 gets installed in both cases.

donavanbecker commented 1 year ago

thanks @dnicolson!

@adamstamper, @alevehemens, & @martindinicolino Version 2.4.0 has been released.

alevehemens commented 1 year ago

Ok, 2.4.0 not resolve issue unfortunately, however I installed again SwitchBot 2.3.2 but again still problem. I made a video directly on iPhone to record the error during installation. How can upload on this discussion? Because I’m trying to do this with image icon above the box text but when I upload video (30 seconds) nothing happens. Thanks a lot for your support in the meanwhile! Ps. I think that I’ve start to have a problem when I updated nove version from 16.x.x to 18.2.1. Is it possible that the issue would be node version?

donavanbecker commented 1 year ago

@alevehemens It could be that, you may need to reviews prerequisites on noble and node-SwitchBot.

More then likely not a plug-in issue, but a ble dependency issue.

adamstamper commented 1 year ago

2.4.0 seems to have fixed this for me - thanks @donavanbecker & all!

alevehemens commented 1 year ago

@alevehemens It could be that, you may need to reviews prerequisites on noble and node-SwitchBot.

More then likely not a plug-in issue, but a ble dependency issue.

Ok so how can I fix it eventually? Which command should I write in the terminal? :)

donavanbecker commented 1 year ago

won't be able to give you specifics, but this repo: node-switchbot, uses this repo: noble

Also there is a BLE Issue wiki: Bluetooth Issues

alevehemens commented 1 year ago

Ok so, I’ve downgraded node to 16.9.0 and now the error is the follow:

Bot failed BLEpushChanges with BLE /OpenAPI Connection & botMode: switch, Er ror Message: "Cannot read properties of u ndefined (reading 'wait')"

any suggest? :) thanks a lot for your continuos support guys!

donavanbecker commented 1 year ago

can you try install 2.3.0 of the plugin version?

alevehemens commented 1 year ago

Done and downgrade to node version 14.21.2 and now the error is this:

[SwitchBot] Bot: Portoncino wasn't able to establish BLE COnnection, node-switchbot: object Object]

and other error:

Bot: Portoncino failed BLEpushChanges with BLE/ OpenAPI Connection & botMode: press, Erro I Message: "Cannot read property 'press' of undefined"

same error with other bot.

any idea?😭

donavanbecker commented 1 year ago

Seems like a prerequisite isn't being meet.

donavanbecker commented 1 year ago

this

adamstamper commented 1 year ago

Going to close this as my issue is resolved - maybe @alevehemens might want to raise a separate issue if problems continue. Thanks for the resolution!

martindinicolino commented 1 year ago

i'm sorry for the late reply

I tried reinstalling this plugin, but the issue was not solved

every time I install this plugin I see this error install response status 404 Not Found on https://github.com/abandonware/node-bluetooth-hci-socket/releases/download/0.5.3-9/bluetooth_hci_socket-0.5.3-9-node-v108-linux-arm64.tar.gz despite this error, the installation still finishes successfully @adamstamper are you getting this too? I tried the solution given in this discussion https://github.com/OpenWonderLabs/homebridge-switchbot/issues/511#issuecomment-1292801346 but this also did not fix the issue in my case

i'm open to suggestions if anyone has some