question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dnicolsoncommented, Dec 27, 2022

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

0reactions
donavanbeckercommented, Dec 27, 2022

thanks @dnicolson!

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bot: wasn't able to establish BLE Connection, ending ... - GitHub
I am trying to connect a "Bot" via BLE but it seems the connection cannot be established. See the attached logs for the...
Read more >
Bot failed to get detected in “Bluetooth device nearby” scan ...
Bot failed to get detected in “Bluetooth device nearby” scan during setup ... 1. Make sure your SwitchBot App version is up to...
Read more >
@switchbot/homebridge-switchbot-ble - npm
The @switchbot/homebridge-switchbot-ble is a nodejs module , and also a homebridge plug-in that directly controls SwitchBot products via BLE.
Read more >
Switchbot Bot: failed refreshStatus with BLE Connection - Reddit
Device is a Switchbot Bot. Homebridge host is a Raspberry Pi 4. Attempted to use BLE since I don't have a hub.
Read more >
2022.8: You can fix it! - Home Assistant
First-class support for Bluetooth, get notified about detected issues and how to repair them, find integrations by brand name, and maps with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found