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
242 stars 52 forks source link

Support Request: I can not connect bluetooth BlindTilt to Homebridge #1003

Closed 6vyes closed 3 weeks ago

6vyes commented 3 months ago

Describe Your Problem

When I try to pair my BlintTilt to HomeBridge with bluetooth on a RaspberryPi, it says that the device id is not 17 digits (it is) and then it goes into boot loop.

Relevant log output

[10/07/2024, 20:18:39] [SwitchBot] Restoring existing accessory from cache: Window deviceId: XX:XX:XX:XX:XX:XX
[10/07/2024, 20:18:39] Error: The number of characters in the `id` must be less than or equal to 17.
    at file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/node-switchbot/src/switchbot.ts:456:16
    at new Promise (<anonymous>)
    at SwitchBot.startScan (file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/node_modules/node-switchbot/src/switchbot.ts:421:21)
    at BlindTilt.monitorAdvertisementPackets (file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/src/device/device.ts:363:21)
    at file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/src/device/blindtilt.ts:404:40
    at BlindTilt.BLERefreshStatus (file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/src/device/blindtilt.ts:414:9)
    at BlindTilt.refreshStatus (file:///var/lib/homebridge/node_modules/@switchbot/homebridge-switchbot/src/device/blindtilt.ts:385:7)
[10/07/2024, 20:18:39] Got SIGTERM, shutting down Homebridge...
[10/07/2024, 20:18:39] Homebridge v1.8.3 (HAP v0.12.2) (Homebridge 9E51) is running on port 51114.
[10/07/2024, 20:18:44] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[10/07/2024, 20:18:49] [HB Supervisor] Restarting Homebridge...
[10/07/2024, 20:18:49] [HB Supervisor] Starting Homebridge with extra flags: -I -P /var/lib/homebridge/node_modules --strict-plugin-resolution
[10/07/2024, 20:18:49] [HB Supervisor] Started Homebridge v1.8.3 with PID: 5401

Config for homebridge-switchbot

{
    "name": "SwitchBot",
    "credentials": {
        "notice": "Keep your Token & Secret a secret!"
    },
    "options": {
        "devices": [
            {
                "deviceId": "XX:XX:XX:XX:XX:XX",
                "configDeviceName": "Window",
                "configDeviceType": "Blind Tilt",
                "connectionType": "BLE"
            }
        ]
    },
    "platform": "SwitchBot"
}

Screenshots

No response

Device & Model

BlindTilt

Node.js Version

v20.15.1

NPM Version

10.7.0

Homebridge Version

1.8.3

Homebridge SwitchBot Plugin Version

v3.6.0

Homebridge Config UI X Plugin Version

4.56.4

Operating System

Raspbian

donavanbecker commented 3 months ago

taking your :s out

6vyes commented 3 months ago

Here is the log output after I removed them,

[10/07/2024, 20:29:39] [SwitchBot] Secondary Curtain: Window, deviceId: XXXXXXXXXXXX
[10/07/2024, 20:29:39] [SwitchBot] Adding new accessory: Window deviceId: XXXXXXXXXXXX
[10/07/2024, 20:29:39] Homebridge v1.8.3 (HAP v0.12.2) (Homebridge 9E51) is running on port 51114.
[10/07/2024, 20:29:44] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:44] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:53] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:53] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:53] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:53] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:55] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Current Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
[10/07/2024, 20:29:55] [@switchbot/homebridge-switchbot] This plugin generated a warning from the characteristic 'Target Position': characteristic value expected valid finite number and received "NaN" (number). See https://homebridge.io/w/JtMGR for more info.
donavanbecker commented 3 months ago

Doesn't look like it was able to connect over BLE.

Bluetooth issues, checkout the Bluetooth Plugins Wiki.

6vyes commented 3 months ago

I have run these commands,

  1. sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
  2. DisablePlugins=pnat
  3. sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev pi-bluetooth

And I am still getting the same messages.

donavanbecker commented 3 months ago

can you turn on debug mode for the device and post logs.

6vyes commented 3 months ago

Here you go,

[10/07/2024, 20:58:09] [SwitchBot] Discovered Blind Tilt Window: XXXXXXXXXXXX
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] deviceName: Window deviceId: XXXXXXXXXXXX, blindTiltDevicesIds: undefined, master: undefined, group: undefined, disable_group: undefined, connectionType: BLE
[10/07/2024, 20:58:09] [SwitchBot] master: undefined
[10/07/2024, 20:58:09] [SwitchBot] deviceName: Window [Blind Tilt Config] connectionType: BLE,  group: undefined
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] Device: Window registerCurtains: true
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] Device: Window Blind Tilt registerDevice: true
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] Device: Window connectionType: BLE, will display in HomeKit
[10/07/2024, 20:58:09] [SwitchBot] Restoring existing accessory from cache: Window deviceId: XXXXXXXXXXXX
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Using Debug Mode Logging: debugMode
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Using Platform Config refreshRate: 120, Default updateRate: 5, Platform Config pushRate: 0.1
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Using Default Max Retries: 5, Default Delay Between Retries: 3000
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] Blind Tilt: Window Config: {“connectionType”:“BLE”}
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Model: W2701600, BLE Model: x, BLE Model Name: WoBlindTilt, BLE Model Friendly Name: Blind Tilt
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Using Default scanDuration: 5
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Using Default MQTT URL: , Default mqttOptions: {}, Default mqttPubOptions: {}
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Mapping mode: only_up
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Retrieve initial values and update Homekit
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window BLERefreshStatus
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Registering Webhook Event Handler
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window is not listening webhook.
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt uuid: XXXXXXXXXXXX-Blind Tilt, (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Firmware Version: 3.6.0
[10/07/2024, 20:58:09] [SwitchBot] [DEBUG] Blind Tilt: Window version: 3.6.0
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window ‘node-switchbot’ found: [object Object]
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window BLE Address: xx:xx:xx:xx:xx:xx
[10/07/2024, 20:58:09] [SwitchBot] Blind Tilt: Window Scanning for WoBlindTilt devices…
[10/07/2024, 20:58:09] Error: listen EADDRINUSE: address already in use :::51114
at Server.setupListenHandle [as _listen2] (node:net:1898:16)
at listenInCluster (node:net:1946:12)
at Server.listen (node:net:2044:7)
at EventedHTTPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/eventedhttp.ts:166:20)
at HAPServer.listen (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/HAPServer.ts:380:21)
at Bridge. (/var/lib/homebridge/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1378:18)
at step (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:195:27)
at Object.next (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:176:57)
at fulfilled (/var/lib/homebridge/node_modules/homebridge/node_modules/tslib/tslib.js:166:62)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
[10/07/2024, 20:58:09] Got SIGTERM, shutting down Homebridge…
donavanbecker commented 3 months ago

Yes node-SwitchBot didn't get installed because of some reason.

I would recommend using OpenAPI

6vyes commented 3 months ago

I cant use OpenAPI because I do not have cloud services enabled and I do not have a SwitchBot bridge to enable it. That is why I was trying to use bluetooth. Is there a way to install node-SwitchBot?

Also when I try OpenAPI I get stuck on this message "Initializing SwitchBot platform..."

donavanbecker commented 3 months ago

Can you try the latest beta:

npm version

Click here to find out how to install Beta

6vyes commented 3 months ago

When I installed the beta and put in the mac address, I got the device into the homebridge accessories tab. However, when I tried to control the blind tilt, it said that it changed but nothing happened. Here are the logs from the plugin.

[22/07/2024, 16:26:43] [SwitchBot] Initializing SwitchBot platform...
[22/07/2024, 16:26:43] [SwitchBot] Secondary Curtain: Window, deviceId: ############
[22/07/2024, 16:26:43] [SwitchBot] Adding new accessory: Window deviceId: ############
[22/07/2024, 16:27:24] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:24] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:25] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:25] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:26] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:26] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:27] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:27] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:28] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:28] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:28] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:28] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:29] [SwitchBot] Blind Tilt: Window TypeError: Cannot read properties of undefined (reading 'runToPos')
[22/07/2024, 16:27:29] [SwitchBot] Blind Tilt: Window Retrying
[22/07/2024, 16:27:29] [SwitchBot] Blind Tilt: Window failed BLEpushChanges with BLE Connection, Error Message: "Cannot read properties of undefined (reading 'runToPos')"
Kositch commented 2 months ago

Same issue with Bot device (see this already opened issue seems that node-switchbot is unable to communicate with BLE devices correctly.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 3 weeks ago

This issue has been closed as no further activity has occurred.