Skip to content

Commit 086838b

Browse files
Update to node-switchbot@3.6.0-beta.9 with proper Hub 3 support
Co-authored-by: donavanbecker <9875439+donavanbecker@users.noreply.github.com>
1 parent df9fdfe commit 086838b

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

docs/variables/default.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><style>body { visibility: hidden; }</style><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="../assets/style.css"><link rel="stylesheet" href="../assets/highlight.css"><script defer="" src="../assets/main.js"></script><script async="" src="../assets/icons.js" id="tsd-icons-script"></script><link rel="stylesheet" href="../assets/dmt/dmt-components.css"><link rel="stylesheet" href="../assets/dmt/dmt-theme.css"><script src="../assets/dmt/dmt-components.js" type="module"></script><noscript><style>body { visibility: visible; }</style></noscript></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";</script><div class="overlay"></div>
2-
<main><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container" id="dmt-toolbar"></div></header><div class="container container-main" tabindex="-1"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"></ul><div class="dmt-title-header-flex"><h1>Variable default</h1></div></div><div class="tsd-signature"><span class="tsd-kind-variable">default</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/ce4db16764f0f0c9ea32376a01aee47f740a93bd/src/index.ts#L11">index.ts:11</a></li></ul></aside></div><div class="col-sidebar" tabindex="-1"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked=""><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu" tabindex="-1"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"></ul></nav></div></div></div></main></body></html>
2+
<main><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container" id="dmt-toolbar"></div></header><div class="container container-main" tabindex="-1"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"></ul><div class="dmt-title-header-flex"><h1>Variable default</h1></div></div><div class="tsd-signature"><span class="tsd-kind-variable">default</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=&gt;</span> <span class="tsd-signature-type">void</span></div><div class="tsd-type-declaration"><h4>Type declaration</h4><ul class="tsd-parameters"><li class="tsd-parameter-signature"><ul class="tsd-signatures"><li class="tsd-signature" id="__type"><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/df9fdfe3db12499d255f11c54af0547c6dee6341/src/index.ts#L11">index.ts:11</a></li></ul></aside></div><div class="col-sidebar" tabindex="-1"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked=""><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu" tabindex="-1"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"></ul></nav></div></div></div></main></body></html>

package-lock.json

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"async-mqtt": "^2.6.3",
8484
"fakegato-history": "^0.6.7",
8585
"homebridge-lib": "^7.1.6",
86-
"node-switchbot": "^3.6.0-beta.1",
86+
"node-switchbot": "^3.6.0-beta.9",
8787
"rxjs": "^7.8.2"
8888
},
8989
"devDependencies": {

src/device/device.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ export abstract class deviceBase {
447447
bleModelFriendlyName: SwitchBotBLEModelFriendlyName.Hub2,
448448
},
449449
'Hub 3': {
450-
model: SwitchBotModel.Hub2,
451-
bleModel: SwitchBotBLEModel.Hub2,
452-
bleModelName: SwitchBotBLEModelName.Hub2,
453-
bleModelFriendlyName: SwitchBotBLEModelFriendlyName.Hub2,
450+
model: SwitchBotModel.Hub3,
451+
bleModel: SwitchBotBLEModel.Hub3,
452+
bleModelName: SwitchBotBLEModelName.Hub3,
453+
bleModelFriendlyName: SwitchBotBLEModelFriendlyName.Hub3,
454454
},
455455
'Bot': {
456456
model: SwitchBotModel.Bot,

src/device/hub.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* hub.ts: @switchbot/homebridge-switchbot.
44
*/
55
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6-
import type { device, hub2ServiceData, hub2Status, hub2WebhookContext, SwitchBotBLE } from 'node-switchbot'
6+
import type { device, hub2ServiceData, hub3ServiceData, hub2Status, hub2WebhookContext, SwitchBotBLE } from 'node-switchbot'
77

88
import type { SwitchBotPlatform } from '../platform.js'
99
import type { devicesConfig, hubConfig } from '../settings.js'
@@ -46,7 +46,7 @@ export class Hub extends deviceBase {
4646
webhookContext!: hub2WebhookContext
4747

4848
// BLE
49-
serviceData!: hub2ServiceData
49+
serviceData!: hub2ServiceData | hub3ServiceData
5050

5151
// Updates
5252
hubUpdateInProgress!: boolean
@@ -294,9 +294,10 @@ export class Hub extends deviceBase {
294294
// Start to monitor advertisement packets
295295
(async () => {
296296
// Start to monitor advertisement packets
297-
const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as hub2ServiceData
297+
const serviceData = await this.monitorAdvertisementPackets(switchBotBLE) as hub2ServiceData | hub3ServiceData
298298
// Update HomeKit
299-
if (serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2) {
299+
if ((serviceData.model === SwitchBotBLEModel.Hub2 && serviceData.modelName === SwitchBotBLEModelName.Hub2) ||
300+
(serviceData.model === SwitchBotBLEModel.Hub3 && serviceData.modelName === SwitchBotBLEModelName.Hub3)) {
300301
this.serviceData = serviceData
301302
if (serviceData !== undefined || serviceData !== null) {
302303
await this.BLEparseStatus()

src/platform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
26962696
const delayBetweenRetries = deviceDelayBetweenRetries ?? 1000
26972697
while (retryCount < maxRetries) {
26982698
try {
2699-
const { response, statusCode } = await this.switchBotAPI.controlDevice(device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType, this.config.credentials?.token, this.config.credentials?.secret)
2699+
const { response, statusCode } = await this.switchBotAPI.controlDevice(device.deviceId, bodyChange.command, bodyChange.parameter, bodyChange.commandType as any, this.config.credentials?.token, this.config.credentials?.secret)
27002700
this.debugLog(`response: ${JSON.stringify(response)}`)
27012701
return { response, statusCode }
27022702
} catch (error: any) {

0 commit comments

Comments
 (0)