@switchbot/homebridge-switchbot 4.1.1-beta.9 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/config.schema.json +2 -2
- package/dist/device/device.d.ts +1 -2
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +16 -16
- package/dist/device/device.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +1 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +6 -18
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/platform.d.ts +21 -9
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +66 -90
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +0 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/docs/functions/default.html +1 -1
- package/package.json +6 -6
- package/src/device/device.ts +16 -17
- package/src/irdevice/irdevice.ts +6 -15
- package/src/platform.ts +69 -104
- package/src/settings.ts +0 -1
- package/.github/npm-version-script.cjs +0 -81
package/dist/settings.d.ts
CHANGED
|
@@ -12,9 +12,6 @@ export declare const PLUGIN_NAME = "@switchbot/homebridge-switchbot";
|
|
|
12
12
|
export interface SwitchBotPlatformConfig extends PlatformConfig {
|
|
13
13
|
credentials?: credentials;
|
|
14
14
|
options?: options;
|
|
15
|
-
deviceConfig?: {
|
|
16
|
-
[deviceType: string]: devicesConfig;
|
|
17
|
-
};
|
|
18
15
|
}
|
|
19
16
|
interface credentials {
|
|
20
17
|
token?: string;
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,OAAO,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CAAA;IACpB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD,gBAAgB,CAAC,EAAE,OAAO,GAAG,WAAW,CAAA;IACxC,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,qBAAqB,CAAA;IAC5D,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD,gBAAgB,CAAC,EAAE,QAAQ,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iCAAiC,CAAA;
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,iCAAiC,CAAA;AAiC3D,CAAC;AA2CD,CAAC;AAOD,CAAC;AAOD,CAAC;AAOD,CAAC;AAcD,CAAC;AAeD,CAAC;AAQD,CAAC;AAOD,CAAC;AAMD,CAAC;AAID,CAAC;AAMD,CAAC;AAMD,CAAC;AAMD,CAAC;AAMD,CAAC;AAUD,CAAC;AA6BD,CAAC;AAKD,CAAC;AAYD,CAAC;AAKD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en"><head><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><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@switchbot/homebridge-switchbot</a></li><li><a href="default.html">default</a></li></ul><h1>Function default</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></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><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en"><head><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><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">@switchbot/homebridge-switchbot</a></li><li><a href="default.html">default</a></li></ul><h1>Function default</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></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><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/ebf590a7c7b218e9a9b9124a9b16a90045eadfdc/src/index.ts#L11">index.ts:11</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>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"><nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>@switchbot/homebridge-switchbot</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><footer></footer><div class="overlay"></div></body></html>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@switchbot/homebridge-switchbot",
|
|
3
3
|
"displayName": "SwitchBot",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.1.1
|
|
5
|
+
"version": "4.1.1",
|
|
6
6
|
"description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
|
|
7
7
|
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
8
8
|
"contributors": [
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"@homebridge/plugin-ui-utils": "^1.0.3",
|
|
81
81
|
"async-mqtt": "^2.6.3",
|
|
82
82
|
"fakegato-history": "^0.6.5",
|
|
83
|
-
"homebridge-lib": "^7.0
|
|
84
|
-
"node-switchbot": "^3.
|
|
83
|
+
"homebridge-lib": "^7.1.0",
|
|
84
|
+
"node-switchbot": "^3.3.0",
|
|
85
85
|
"rxjs": "^7.8.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
"@types/debug": "^4.1.12",
|
|
91
91
|
"@types/fs-extra": "^11.0.4",
|
|
92
92
|
"@types/mdast": "^4.0.4",
|
|
93
|
-
"@types/node": "^22.8.
|
|
93
|
+
"@types/node": "^22.8.6",
|
|
94
94
|
"@types/semver": "^7.5.8",
|
|
95
95
|
"@types/source-map-support": "^0.5.10",
|
|
96
96
|
"@vitest/coverage-v8": "^2.1.4",
|
|
97
|
-
"eslint": "^9.
|
|
97
|
+
"eslint": "^9.14.0",
|
|
98
98
|
"eslint-plugin-format": "^0.1.2",
|
|
99
99
|
"homebridge": "^1.8.5",
|
|
100
100
|
"homebridge-config-ui-x": "4.62.0",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"npm-check-updates": "^17.1.9",
|
|
103
103
|
"shx": "^0.3.4",
|
|
104
104
|
"ts-node": "^10.9.2",
|
|
105
|
-
"typedoc": "^0.26.
|
|
105
|
+
"typedoc": "^0.26.11",
|
|
106
106
|
"typescript": "^5.6.3",
|
|
107
107
|
"vitest": "^2.1.4"
|
|
108
108
|
},
|
package/src/device/device.ts
CHANGED
|
@@ -68,7 +68,6 @@ export abstract class deviceBase {
|
|
|
68
68
|
|
|
69
69
|
this.getDeviceLogSettings(accessory, device)
|
|
70
70
|
this.getDeviceRateSettings(accessory, device)
|
|
71
|
-
this.getDeviceRetry(device)
|
|
72
71
|
this.getDeviceConfigSettings(device)
|
|
73
72
|
this.getDeviceContext(accessory, device)
|
|
74
73
|
this.getDeviceScanDuration(accessory, device)
|
|
@@ -87,34 +86,34 @@ export abstract class deviceBase {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
async getDeviceLogSettings(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
|
|
90
|
-
this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.
|
|
91
|
-
const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.
|
|
89
|
+
this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.platform.platformLogging ?? 'standard'
|
|
90
|
+
const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.platform.platformLogging ? 'Platform Config' : 'Default'
|
|
92
91
|
accessory.context.deviceLogging = this.deviceLogging
|
|
93
92
|
this.debugLog(`Using ${logging} Logging: ${this.deviceLogging}`)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
async getDeviceRateSettings(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
|
|
97
96
|
// refreshRate
|
|
98
|
-
this.deviceRefreshRate = device.refreshRate ?? this.
|
|
97
|
+
this.deviceRefreshRate = device.refreshRate ?? this.platform.platformRefreshRate ?? 5
|
|
99
98
|
accessory.context.deviceRefreshRate = this.deviceRefreshRate
|
|
100
|
-
const refreshRate = device.refreshRate ? 'Device Config' : this.
|
|
99
|
+
const refreshRate = device.refreshRate ? 'Device Config' : this.platform.platformRefreshRate ? 'Platform Config' : 'Default'
|
|
101
100
|
// updateRate
|
|
102
|
-
this.deviceUpdateRate = device.updateRate ?? this.
|
|
101
|
+
this.deviceUpdateRate = device.updateRate ?? this.platform.platformUpdateRate ?? 5
|
|
103
102
|
accessory.context.deviceUpdateRate = this.deviceUpdateRate
|
|
104
|
-
const updateRate = device.updateRate ? 'Device Config' : this.
|
|
103
|
+
const updateRate = device.updateRate ? 'Device Config' : this.platform.platformUpdateRate ? 'Platform Config' : 'Default'
|
|
105
104
|
// pushRate
|
|
106
|
-
this.devicePushRate = device.pushRate ?? this.
|
|
105
|
+
this.devicePushRate = device.pushRate ?? this.platform.platformPushRate ?? 1
|
|
107
106
|
accessory.context.devicePushRate = this.devicePushRate
|
|
108
|
-
const pushRate = device.pushRate ? 'Device Config' : this.
|
|
107
|
+
const pushRate = device.pushRate ? 'Device Config' : this.platform.platformPushRate ? 'Platform Config' : 'Default'
|
|
109
108
|
this.debugLog(`Using ${refreshRate} refreshRate: ${this.deviceRefreshRate}, ${updateRate} updateRate: ${this.deviceUpdateRate}, ${pushRate} pushRate: ${this.devicePushRate}`)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
this.deviceDelayBetweenRetries = device.delayBetweenRetries ? (device.delayBetweenRetries * 1000) : 3000
|
|
116
|
-
const delayBetweenRetries = device.delayBetweenRetries ? 'Device' : 'Default'
|
|
117
|
-
this.debugLog(`Using ${
|
|
109
|
+
// maxRetries
|
|
110
|
+
this.deviceMaxRetries = device.maxRetries ?? this.platform.platformMaxRetries ?? 5
|
|
111
|
+
const maxRetries = device.maxRetries ? 'Device' : this.platform.platformMaxRetries ? 'Platform' : 'Default'
|
|
112
|
+
this.debugLog(`Using ${maxRetries} Max Retries: ${this.deviceMaxRetries}`)
|
|
113
|
+
// delayBetweenRetries
|
|
114
|
+
this.deviceDelayBetweenRetries = device.delayBetweenRetries ? (device.delayBetweenRetries * 1000) : this.platform.platformDelayBetweenRetries ? this.platform.platformDelayBetweenRetries : 3000
|
|
115
|
+
const delayBetweenRetries = device.delayBetweenRetries ? 'Device' : this.platform.platformDelayBetweenRetries ? 'Platform' : 'Default'
|
|
116
|
+
this.debugLog(`Using ${delayBetweenRetries} Delay Between Retries: ${this.deviceDelayBetweenRetries}`)
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
async retryBLE({ max, fn }: { max: number, fn: { (): any, (): Promise<any> } }): Promise<null> {
|
package/src/irdevice/irdevice.ts
CHANGED
|
@@ -30,7 +30,7 @@ export abstract class irdeviceBase {
|
|
|
30
30
|
this.config = this.platform.config
|
|
31
31
|
this.hap = this.api.hap
|
|
32
32
|
|
|
33
|
-
this.getDeviceLogSettings(device)
|
|
33
|
+
this.getDeviceLogSettings(accessory, device)
|
|
34
34
|
this.getDeviceConfigSettings(device)
|
|
35
35
|
this.getDeviceContext(accessory, device)
|
|
36
36
|
this.disablePushOnChanges(device)
|
|
@@ -48,20 +48,11 @@ export abstract class irdeviceBase {
|
|
|
48
48
|
.setCharacteristic(this.hap.Characteristic.SerialNumber, device.deviceId)
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
async getDeviceLogSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
this.deviceLogging = this.accessory.context.logging = device.logging
|
|
57
|
-
this.debugWarnLog(`Using Device Config Logging: ${this.deviceLogging}`)
|
|
58
|
-
} else if (this.config.logging) {
|
|
59
|
-
this.deviceLogging = this.accessory.context.logging = this.config.logging
|
|
60
|
-
this.debugWarnLog(`Using Platform Config Logging: ${this.deviceLogging}`)
|
|
61
|
-
} else {
|
|
62
|
-
this.deviceLogging = this.accessory.context.logging = 'standard'
|
|
63
|
-
this.debugWarnLog(`Logging Not Set, Using: ${this.deviceLogging}`)
|
|
64
|
-
}
|
|
51
|
+
async getDeviceLogSettings(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): Promise<void> {
|
|
52
|
+
this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.platform.platformLogging ?? 'standard'
|
|
53
|
+
const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.platform.platformLogging ? 'Platform Config' : 'Default'
|
|
54
|
+
accessory.context.deviceLogging = this.deviceLogging
|
|
55
|
+
this.debugLog(`Using ${logging} Logging: ${this.deviceLogging}`)
|
|
65
56
|
}
|
|
66
57
|
|
|
67
58
|
async getDeviceConfigSettings(device: irdevice & irDevicesConfig): Promise<void> {
|
package/src/platform.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { MqttClient } from 'mqtt'
|
|
|
10
10
|
import type { blindTiltConfig, curtainConfig, devicesConfig, irDevicesConfig, options, SwitchBotPlatformConfig } from './settings.js'
|
|
11
11
|
|
|
12
12
|
import { readFileSync } from 'node:fs'
|
|
13
|
-
import process from 'node:process'
|
|
13
|
+
import process, { argv } from 'node:process'
|
|
14
14
|
|
|
15
15
|
import asyncmqtt from 'async-mqtt'
|
|
16
16
|
import fakegato from 'fakegato-history'
|
|
@@ -68,14 +68,16 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
68
68
|
public readonly log: Logging
|
|
69
69
|
|
|
70
70
|
// Configuration properties
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
platformConfig!: SwitchBotPlatformConfig
|
|
72
|
+
platformLogging!: options['logging']
|
|
73
|
+
platformRefreshRate!: options['refreshRate']
|
|
74
|
+
platformPushRate!: options['pushRate']
|
|
75
|
+
platformUpdateRate!: options['updateRate']
|
|
76
|
+
platformMaxRetries!: options['maxRetries']
|
|
77
|
+
platformDelayBetweenRetries!: options['delayBetweenRetries']
|
|
78
78
|
config!: SwitchBotPlatformConfig
|
|
79
|
+
debugMode!: boolean
|
|
80
|
+
version!: string
|
|
79
81
|
|
|
80
82
|
// MQTT and Webhook properties
|
|
81
83
|
mqttClient: MqttClient | null = null
|
|
@@ -114,11 +116,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
114
116
|
credentials: config.credentials as object,
|
|
115
117
|
options: config.options as object,
|
|
116
118
|
devices: config.devices as { deviceId: string }[],
|
|
117
|
-
deviceConfig: config.deviceConfig as { [deviceType: string]: devicesConfig },
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
// Plugin Configuration
|
|
121
122
|
this.getPlatformLogSettings()
|
|
123
|
+
this.getPlatformRateSettings()
|
|
122
124
|
this.getPlatformConfigSettings()
|
|
123
125
|
this.getVersion()
|
|
124
126
|
|
|
@@ -361,20 +363,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
361
363
|
this.config = this.config || {}
|
|
362
364
|
this.config.options = this.config.options || {}
|
|
363
365
|
|
|
364
|
-
const platformConfig: options = {}
|
|
365
|
-
if (this.config.options.logging) {
|
|
366
|
-
platformConfig.logging = this.config.options.logging
|
|
367
|
-
}
|
|
368
|
-
if (this.config.options.logging && this.config.options.refreshRate) {
|
|
369
|
-
platformConfig.refreshRate = this.config.options.refreshRate
|
|
370
|
-
}
|
|
371
|
-
if (this.config.options.logging && this.config.options.pushRate) {
|
|
372
|
-
platformConfig.pushRate = this.config.options.pushRate
|
|
373
|
-
}
|
|
374
|
-
if (Object.entries(platformConfig).length !== 0) {
|
|
375
|
-
this.debugWarnLog(`Platform Config: ${JSON.stringify(platformConfig)}`)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
366
|
if (this.config.options) {
|
|
379
367
|
// Device Config
|
|
380
368
|
if (this.config.options.devices) {
|
|
@@ -405,37 +393,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
405
393
|
}
|
|
406
394
|
}
|
|
407
395
|
|
|
408
|
-
if (this.config.options!.refreshRate! < 5) {
|
|
409
|
-
throw new Error('Refresh Rate must be above 5 (5 seconds).')
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (!this.config.options.refreshRate) {
|
|
413
|
-
// default 120 seconds (2 minutes)
|
|
414
|
-
this.config.options!.refreshRate! = 120
|
|
415
|
-
this.debugWarnLog('Using Default Refresh Rate (2 minutes).')
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (!this.config.options.pushRate) {
|
|
419
|
-
// default 100 milliseconds
|
|
420
|
-
this.config.options!.pushRate! = 0.1
|
|
421
|
-
this.debugWarnLog('Using Default Push Rate.')
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (!this.config.options.maxRetries) {
|
|
425
|
-
this.config.options.maxRetries = 5
|
|
426
|
-
this.debugWarnLog('Using Default Max Retries.')
|
|
427
|
-
} else {
|
|
428
|
-
this.maxRetries = this.config.options.maxRetries
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (!this.config.options.delayBetweenRetries) {
|
|
432
|
-
// default 3 seconds
|
|
433
|
-
this.config.options!.delayBetweenRetries! = 3000
|
|
434
|
-
this.debugWarnLog('Using Default Delay Between Retries.')
|
|
435
|
-
} else {
|
|
436
|
-
this.delayBetweenRetries = this.config.options.delayBetweenRetries * 1000
|
|
437
|
-
}
|
|
438
|
-
|
|
439
396
|
if (!this.config.credentials && !this.config.options) {
|
|
440
397
|
this.debugWarnLog('Missing Credentials')
|
|
441
398
|
} else if (this.config.credentials && !this.config.credentials.notice) {
|
|
@@ -458,12 +415,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
458
415
|
}
|
|
459
416
|
|
|
460
417
|
let retryCount = 0
|
|
461
|
-
const maxRetries = this.
|
|
462
|
-
const delayBetweenRetries = this.
|
|
418
|
+
const maxRetries = this.platformMaxRetries ?? 5
|
|
419
|
+
const delayBetweenRetries = this.platformDelayBetweenRetries || 5000
|
|
463
420
|
|
|
464
421
|
this.debugWarnLog(`Retry Count: ${retryCount}`)
|
|
465
|
-
this.debugWarnLog(`Max Retries: ${
|
|
466
|
-
this.debugWarnLog(`Delay Between Retries: ${
|
|
422
|
+
this.debugWarnLog(`Max Retries: ${this.platformMaxRetries}`)
|
|
423
|
+
this.debugWarnLog(`Delay Between Retries: ${this.platformDelayBetweenRetries}`)
|
|
467
424
|
|
|
468
425
|
while (retryCount < maxRetries) {
|
|
469
426
|
try {
|
|
@@ -2680,60 +2637,68 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2680
2637
|
}
|
|
2681
2638
|
}
|
|
2682
2639
|
|
|
2683
|
-
async getVersion(): Promise<string> {
|
|
2684
|
-
const json = JSON.parse(
|
|
2685
|
-
readFileSync(
|
|
2686
|
-
new URL('../package.json', import.meta.url),
|
|
2687
|
-
'utf-8',
|
|
2688
|
-
),
|
|
2689
|
-
)
|
|
2690
|
-
this.debugLog(`Plugin Version: ${json.version}`)
|
|
2691
|
-
this.version = json.version
|
|
2692
|
-
return json.version
|
|
2693
|
-
}
|
|
2694
|
-
|
|
2695
2640
|
async getPlatformConfigSettings() {
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if (options) {
|
|
2700
|
-
platformConfig.logging = options.logging
|
|
2701
|
-
platformConfig.refreshRate = options.refreshRate
|
|
2702
|
-
platformConfig.updateRate = options.updateRate
|
|
2703
|
-
platformConfig.pushRate = options.pushRate
|
|
2704
|
-
|
|
2705
|
-
this.maxRetries = options.maxRetries || 3
|
|
2706
|
-
platformConfig.maxRetries = this.maxRetries
|
|
2707
|
-
if (!options.maxRetries) {
|
|
2708
|
-
this.debugWarnLog('Using Default Max Retries')
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
this.delayBetweenRetries = (options.delayBetweenRetries || 3) * 1000
|
|
2712
|
-
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000
|
|
2713
|
-
if (!options.delayBetweenRetries) {
|
|
2714
|
-
this.debugWarnLog('Using Default Delay Between Retries')
|
|
2641
|
+
if (this.config.options) {
|
|
2642
|
+
const platformConfig: SwitchBotPlatformConfig = {
|
|
2643
|
+
platform: 'Resideo',
|
|
2715
2644
|
}
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2645
|
+
platformConfig.logging = this.config.options.logging ? this.config.options.logging : undefined
|
|
2646
|
+
platformConfig.refreshRate = this.config.options.refreshRate ? this.config.options.refreshRate : undefined
|
|
2647
|
+
platformConfig.updateRate = this.config.options.updateRate ? this.config.options.updateRate : undefined
|
|
2648
|
+
platformConfig.pushRate = this.config.options.pushRate ? this.config.options.pushRate : undefined
|
|
2649
|
+
platformConfig.maxRetries = this.config.options.maxRetries ? this.config.options.maxRetries : undefined
|
|
2650
|
+
platformConfig.delayBetweenRetries = this.config.options.delayBetweenRetries ? this.config.options.delayBetweenRetries : undefined
|
|
2651
|
+
if (Object.entries(platformConfig).length !== 0) {
|
|
2652
|
+
await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`)
|
|
2719
2653
|
}
|
|
2720
|
-
|
|
2721
2654
|
this.platformConfig = platformConfig
|
|
2722
2655
|
}
|
|
2723
2656
|
}
|
|
2724
2657
|
|
|
2725
|
-
async
|
|
2726
|
-
this.
|
|
2727
|
-
if (this.
|
|
2728
|
-
this.
|
|
2729
|
-
this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`)
|
|
2730
|
-
} else if (this.debugMode) {
|
|
2731
|
-
this.platformLogging = 'debugMode'
|
|
2732
|
-
this.debugWarnLog(`Using ${this.platformLogging} Logging`)
|
|
2733
|
-
} else {
|
|
2734
|
-
this.platformLogging = 'standard'
|
|
2735
|
-
this.debugWarnLog(`Using ${this.platformLogging} Logging`)
|
|
2658
|
+
async getPlatformRateSettings() {
|
|
2659
|
+
this.platformRefreshRate = this.config.options?.refreshRate ?? 120
|
|
2660
|
+
if (this.platformRefreshRate < 5) {
|
|
2661
|
+
this.platformRefreshRate = 5
|
|
2736
2662
|
}
|
|
2663
|
+
const refreshRate = this.config.options?.refreshRate ? 'Using Platform Config refreshRate' : 'refreshRate Disabled by Default'
|
|
2664
|
+
await this.debugLog(`${refreshRate}: ${this.platformRefreshRate}`)
|
|
2665
|
+
this.platformUpdateRate = this.config.options?.updateRate ? this.config.options.updateRate : 1
|
|
2666
|
+
const updateRate = this.config.options?.updateRate ? 'Using Platform Config updateRate' : 'Using Default updateRate'
|
|
2667
|
+
await this.debugLog(`${updateRate}: ${this.platformUpdateRate}`)
|
|
2668
|
+
this.platformPushRate = this.config.options?.pushRate ? this.config.options.pushRate : 0.1
|
|
2669
|
+
const pushRate = this.config.options?.pushRate ? 'Using Platform Config pushRate' : 'Using Default pushRate'
|
|
2670
|
+
await this.debugLog(`${pushRate}: ${this.platformPushRate}`)
|
|
2671
|
+
this.platformMaxRetries = this.config.options?.maxRetries ? this.config.options.maxRetries : 3
|
|
2672
|
+
const maxRetries = this.config.options?.maxRetries ? 'Using Platform Config maxRetries' : 'Using Default maxRetries'
|
|
2673
|
+
await this.debugLog(`${maxRetries}: ${this.platformMaxRetries}`)
|
|
2674
|
+
this.platformDelayBetweenRetries = this.config.options?.delayBetweenRetries ? this.config.options.delayBetweenRetries * 1000 : 3000
|
|
2675
|
+
const delayBetweenRetries = this.config.options?.delayBetweenRetries ? 'Using Platform Config delayBetweenRetries' : 'Using Default delayBetweenRetries'
|
|
2676
|
+
await this.debugLog(`${delayBetweenRetries}: ${this.platformDelayBetweenRetries / 1000}`)
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
async getPlatformLogSettings() {
|
|
2680
|
+
this.debugMode = argv.includes('-D') ?? argv.includes('--debug')
|
|
2681
|
+
this.platformLogging = (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard'
|
|
2682
|
+
|| this.config.options?.logging === 'none')
|
|
2683
|
+
? this.config.options.logging
|
|
2684
|
+
: this.debugMode ? 'debugMode' : 'standard'
|
|
2685
|
+
const logging = this.config.options?.logging ? 'Platform Config' : this.debugMode ? 'debugMode' : 'Default'
|
|
2686
|
+
await this.debugLog(`Using ${logging} Logging: ${this.platformLogging}`)
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
/**
|
|
2690
|
+
* Asynchronously retrieves the version of the plugin from the package.json file.
|
|
2691
|
+
*
|
|
2692
|
+
* This method reads the package.json file located in the parent directory,
|
|
2693
|
+
* parses its content to extract the version, and logs the version using the debug logger.
|
|
2694
|
+
* The extracted version is then assigned to the `version` property of the class.
|
|
2695
|
+
*
|
|
2696
|
+
* @returns {Promise<void>} A promise that resolves when the version has been retrieved and logged.
|
|
2697
|
+
*/
|
|
2698
|
+
async getVersion(): Promise<void> {
|
|
2699
|
+
const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'))
|
|
2700
|
+
this.debugLog(`Plugin Version: ${version}`)
|
|
2701
|
+
this.version = version
|
|
2737
2702
|
}
|
|
2738
2703
|
|
|
2739
2704
|
/**
|
package/src/settings.ts
CHANGED
|
@@ -23,7 +23,6 @@ export const PLUGIN_NAME = '@switchbot/homebridge-switchbot'
|
|
|
23
23
|
export interface SwitchBotPlatformConfig extends PlatformConfig {
|
|
24
24
|
credentials?: credentials
|
|
25
25
|
options?: options
|
|
26
|
-
deviceConfig?: { [deviceType: string]: devicesConfig }
|
|
27
26
|
}
|
|
28
27
|
interface credentials {
|
|
29
28
|
token?: string
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
#!/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require("fs");
|
|
8
|
-
const semver = require("semver");
|
|
9
|
-
const child_process = require("child_process");
|
|
10
|
-
const assert = require("assert");
|
|
11
|
-
|
|
12
|
-
const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
|
|
13
|
-
|
|
14
|
-
// Load the contents of the package.json file
|
|
15
|
-
const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
16
|
-
|
|
17
|
-
let refArgument = process.argv[2];
|
|
18
|
-
let tagArgument = process.argv[3] || "latest";
|
|
19
|
-
|
|
20
|
-
if (refArgument == null) {
|
|
21
|
-
console.error("ref argument is missing");
|
|
22
|
-
console.error("Usage: npm-version-script.cjs <ref> [tag]");
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Queries the NPM registry for the latest version for the provided tag.
|
|
28
|
-
* @param tag The tag to query for.
|
|
29
|
-
* @returns {string} Returns the version.
|
|
30
|
-
*/
|
|
31
|
-
function getTagVersionFromNpm(tag) {
|
|
32
|
-
try {
|
|
33
|
-
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw e;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function desiredTargetVersion(ref) {
|
|
40
|
-
// ref is a GitHub action ref string
|
|
41
|
-
if (ref.startsWith("refs/pull/")) {
|
|
42
|
-
throw Error("The version script was executed inside a PR!");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
assert(ref.startsWith("refs/heads/"))
|
|
46
|
-
let branchName = ref.slice("refs/heads/".length);
|
|
47
|
-
|
|
48
|
-
let results = branchName.match(BRANCH_VERSION_PATTERN);
|
|
49
|
-
if (results != null) {
|
|
50
|
-
if (results[1] !== tagArgument) {
|
|
51
|
-
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return results[2];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// legacy mode were we use the `betaVersion` property in the package.json
|
|
58
|
-
if (branchName === "beta" && packageJSON.betaVersion) {
|
|
59
|
-
return packageJSON.betaVersion
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// derive the base version from the branch ref
|
|
66
|
-
const baseVersion = desiredTargetVersion(refArgument);
|
|
67
|
-
|
|
68
|
-
// query the npm registry for the latest version of the provided tag name
|
|
69
|
-
const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
|
|
70
|
-
const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
71
|
-
|
|
72
|
-
let publishTag;
|
|
73
|
-
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
|
|
74
|
-
publishTag = latestReleasedVersion; // set the current latest beta to be incremented
|
|
75
|
-
} else {
|
|
76
|
-
publishTag = baseVersion; // start of with a new beta version
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// save the package.json
|
|
80
|
-
packageJSON.version = publishTag;
|
|
81
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));
|