@switchbot/homebridge-switchbot 1.5.0 → 1.5.1-beta.3
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 +7 -0
- package/config.schema.json +11 -2
- package/dist/devices/bots.d.ts +1 -0
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +31 -18
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.js +13 -12
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.js +13 -12
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +16 -15
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.js +13 -12
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.js +13 -12
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.js +13 -12
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.js +13 -12
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +11 -1
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +11 -1
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +11 -1
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +11 -1
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +11 -1
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +2 -0
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +38 -7
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +11 -1
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +11 -1
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +11 -1
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +68 -68
- package/src/devices/bots.ts +32 -18
- package/src/devices/colorbulb.ts +12 -12
- package/src/devices/contact.ts +12 -12
- package/src/devices/curtains.ts +16 -16
- package/src/devices/humidifiers.ts +12 -12
- package/src/devices/meters.ts +12 -12
- package/src/devices/motion.ts +12 -12
- package/src/devices/plugs.ts +12 -12
- package/src/irdevices/airconditioners.ts +10 -1
- package/src/irdevices/airpurifiers.ts +10 -1
- package/src/irdevices/cameras.ts +10 -1
- package/src/irdevices/fans.ts +10 -1
- package/src/irdevices/lights.ts +10 -1
- package/src/irdevices/others.ts +39 -8
- package/src/irdevices/tvs.ts +10 -1
- package/src/irdevices/vacuumcleaners.ts +10 -1
- package/src/irdevices/waterheaters.ts +10 -1
- package/src/settings.ts +1 -0
package/package.json
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"homebridge": "^1.3.8",
|
|
17
|
-
"node": "^14.18.2 || ^16.13.1"
|
|
18
|
-
},
|
|
19
|
-
"main": "dist/index.js",
|
|
20
|
-
"scripts": {
|
|
21
|
-
"check": "npm install && npm outdated",
|
|
22
|
-
"update": "ncu -u && npm update && npm install",
|
|
23
|
-
"lint": "eslint src/**.ts",
|
|
24
|
-
"watch": "npm run build && npm link && nodemon",
|
|
25
|
-
"build": "rimraf ./dist && tsc",
|
|
26
|
-
"prepublishOnly": "npm run lint && npm run build"
|
|
27
|
-
},
|
|
28
|
-
"funding": [
|
|
29
|
-
{
|
|
30
|
-
"type": "Paypal",
|
|
31
|
-
"url": "https://paypal.me/donavanbecker"
|
|
2
|
+
"displayName": "Homebridge SwitchBot",
|
|
3
|
+
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
+
"version": "1.5.1-beta.3",
|
|
5
|
+
"description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
|
|
6
|
+
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
|
|
32
11
|
},
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"homebridge": "^1.3.9",
|
|
17
|
+
"node": "^14.18.2 || ^16.13.1"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"check": "npm install && npm outdated",
|
|
22
|
+
"update": "ncu -u && npm update && npm install",
|
|
23
|
+
"lint": "eslint src/**.ts",
|
|
24
|
+
"watch": "npm run build && npm link && nodemon",
|
|
25
|
+
"build": "rimraf ./dist && tsc",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"funding": [
|
|
29
|
+
{
|
|
30
|
+
"type": "Paypal",
|
|
31
|
+
"url": "https://paypal.me/donavanbecker"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "GitHub",
|
|
35
|
+
"url": "https://github.com/sponsors/donavanbecker"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"homebridge-plugin",
|
|
43
|
+
"switchbot",
|
|
44
|
+
"humidifier",
|
|
45
|
+
"humidity",
|
|
46
|
+
"temperature",
|
|
47
|
+
"bot",
|
|
48
|
+
"curtains",
|
|
49
|
+
"windows",
|
|
50
|
+
"ble",
|
|
51
|
+
"ir"
|
|
52
|
+
],
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
55
|
+
"axios": "^0.24.0",
|
|
56
|
+
"node-switchbot": "^1.1.2",
|
|
57
|
+
"rxjs": "^7.5.1"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^17.0.5",
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
|
62
|
+
"@typescript-eslint/parser": "^5.8.1",
|
|
63
|
+
"eslint": "^8.5.0",
|
|
64
|
+
"homebridge": "^1.3.9",
|
|
65
|
+
"nodemon": "^2.0.15",
|
|
66
|
+
"npm-check-updates": "^12.0.5",
|
|
67
|
+
"rimraf": "^3.0.2",
|
|
68
|
+
"ts-node": "^10.4.0",
|
|
69
|
+
"typescript": "^4.5.4",
|
|
70
|
+
"typescript-axios-wb": "^1.0.3"
|
|
36
71
|
}
|
|
37
|
-
],
|
|
38
|
-
"publishConfig": {
|
|
39
|
-
"access": "public"
|
|
40
|
-
},
|
|
41
|
-
"keywords": [
|
|
42
|
-
"homebridge-plugin",
|
|
43
|
-
"switchbot",
|
|
44
|
-
"humidifier",
|
|
45
|
-
"humidity",
|
|
46
|
-
"temperature",
|
|
47
|
-
"bot",
|
|
48
|
-
"curtains",
|
|
49
|
-
"windows",
|
|
50
|
-
"ble",
|
|
51
|
-
"ir"
|
|
52
|
-
],
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
55
|
-
"axios": "^0.24.0",
|
|
56
|
-
"node-switchbot": "^1.1.2",
|
|
57
|
-
"rxjs": "^7.4.0"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@types/node": "^17.0.5",
|
|
61
|
-
"@typescript-eslint/eslint-plugin": "^5.8.0",
|
|
62
|
-
"@typescript-eslint/parser": "^5.8.0",
|
|
63
|
-
"eslint": "^8.5.0",
|
|
64
|
-
"homebridge": "^1.3.8",
|
|
65
|
-
"nodemon": "^2.0.15",
|
|
66
|
-
"npm-check-updates": "^12.0.5",
|
|
67
|
-
"rimraf": "^3.0.2",
|
|
68
|
-
"ts-node": "^10.4.0",
|
|
69
|
-
"typescript": "^4.5.4",
|
|
70
|
-
"typescript-axios-wb": "^1.0.3"
|
|
71
|
-
}
|
|
72
72
|
}
|
package/src/devices/bots.ts
CHANGED
|
@@ -39,6 +39,9 @@ export class Bot {
|
|
|
39
39
|
deviceLogging!: string;
|
|
40
40
|
deviceRefreshRate!: number;
|
|
41
41
|
|
|
42
|
+
// Others
|
|
43
|
+
doublePress!: number;
|
|
44
|
+
|
|
42
45
|
// Updates
|
|
43
46
|
botUpdateInProgress!: boolean;
|
|
44
47
|
doBotUpdate!: Subject<void>;
|
|
@@ -49,19 +52,26 @@ export class Bot {
|
|
|
49
52
|
public device: device & devicesConfig,
|
|
50
53
|
) {
|
|
51
54
|
// default placeholders
|
|
55
|
+
this.refreshRate();
|
|
56
|
+
this.logs();
|
|
52
57
|
if (this.On === undefined) {
|
|
53
58
|
this.On = false;
|
|
59
|
+
this.accessory.context.On = this.On;
|
|
54
60
|
} else {
|
|
55
61
|
this.On = this.accessory.context.On;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
if (device.bot?.doublePress) {
|
|
64
|
+
this.doublePress = device.bot?.doublePress;
|
|
65
|
+
this.accessory.context.doublePress = this.doublePress;
|
|
66
|
+
} else {
|
|
67
|
+
this.doublePress = 1;
|
|
68
|
+
}
|
|
59
69
|
this.BatteryLevel = 100;
|
|
60
70
|
this.StatusLowBattery = 1;
|
|
61
71
|
|
|
62
72
|
// Bot Config
|
|
63
73
|
this.debugLog(`Bot: ${this.accessory.displayName} Config: (ble: ${device.ble}, offline: ${device.offline}, mode: ${device.bot?.mode},`
|
|
64
|
-
+ ` deviceType: ${device.bot?.deviceType})`);
|
|
74
|
+
+ ` deviceType: ${device.bot?.deviceType}, doublePress: ${this.doublePress})`);
|
|
65
75
|
|
|
66
76
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
67
77
|
this.doBotUpdate = new Subject();
|
|
@@ -151,7 +161,11 @@ export class Bot {
|
|
|
151
161
|
)
|
|
152
162
|
.subscribe(async () => {
|
|
153
163
|
try {
|
|
154
|
-
|
|
164
|
+
interval(100)
|
|
165
|
+
.pipe(take(this.doublePress!))
|
|
166
|
+
.subscribe(async () => {
|
|
167
|
+
await this.pushChanges();
|
|
168
|
+
});
|
|
155
169
|
} catch (e: any) {
|
|
156
170
|
this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges`);
|
|
157
171
|
if (this.deviceLogging === 'debug') {
|
|
@@ -170,33 +184,33 @@ export class Bot {
|
|
|
170
184
|
refreshRate() {
|
|
171
185
|
if (this.device.refreshRate) {
|
|
172
186
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
173
|
-
if (this.platform.debugMode) {
|
|
174
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
187
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
188
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
175
189
|
}
|
|
176
190
|
} else if (this.platform.config.options!.refreshRate) {
|
|
177
191
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
178
|
-
if (this.platform.debugMode) {
|
|
179
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
192
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
193
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
180
194
|
}
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
|
|
184
198
|
logs() {
|
|
185
|
-
if (this.
|
|
199
|
+
if (this.platform.debugMode) {
|
|
200
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
201
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
202
|
+
} else if (this.device.logging) {
|
|
186
203
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
187
|
-
if (this.
|
|
188
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
204
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
205
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
189
206
|
}
|
|
190
207
|
} else if (this.platform.config.options?.logging) {
|
|
191
208
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
192
|
-
if (this.
|
|
193
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
209
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
210
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
194
211
|
}
|
|
195
212
|
} else {
|
|
196
213
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
197
|
-
if (this.platform.debugMode) {
|
|
198
|
-
this.warnLog('Using Device Standard Logging');
|
|
199
|
-
}
|
|
200
214
|
}
|
|
201
215
|
}
|
|
202
216
|
|
|
@@ -245,7 +259,7 @@ export class Bot {
|
|
|
245
259
|
this.On = false;
|
|
246
260
|
}
|
|
247
261
|
}
|
|
248
|
-
this.debugLog(`Bot ${this.accessory.displayName} On: ${this.On}`);
|
|
262
|
+
this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
|
|
249
263
|
}
|
|
250
264
|
}
|
|
251
265
|
|
|
@@ -469,7 +483,7 @@ export class Bot {
|
|
|
469
483
|
|
|
470
484
|
// Make the API request
|
|
471
485
|
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
|
|
472
|
-
this.debugLog(`Bot ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
486
|
+
this.debugLog(`Bot: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
473
487
|
this.statusCode(push);
|
|
474
488
|
this.OnCached = this.On;
|
|
475
489
|
this.accessory.context.On = this.OnCached;
|
package/src/devices/colorbulb.ts
CHANGED
|
@@ -200,33 +200,33 @@ export class ColorBulb {
|
|
|
200
200
|
refreshRate() {
|
|
201
201
|
if (this.device.refreshRate) {
|
|
202
202
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
203
|
-
if (this.platform.debugMode) {
|
|
204
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
203
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
204
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
205
205
|
}
|
|
206
206
|
} else if (this.platform.config.options!.refreshRate) {
|
|
207
207
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
208
|
-
if (this.platform.debugMode) {
|
|
209
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
208
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
209
|
+
this.warnLog(`Color Bulb: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
logs() {
|
|
215
|
-
if (this.
|
|
215
|
+
if (this.platform.debugMode) {
|
|
216
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
217
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
218
|
+
} else if (this.device.logging) {
|
|
216
219
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
217
|
-
if (this.
|
|
218
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
220
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
221
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
219
222
|
}
|
|
220
223
|
} else if (this.platform.config.options?.logging) {
|
|
221
224
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
222
|
-
if (this.
|
|
223
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
225
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
226
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
224
227
|
}
|
|
225
228
|
} else {
|
|
226
229
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
227
|
-
if (this.platform.debugMode) {
|
|
228
|
-
this.warnLog('Using Device Standard Logging');
|
|
229
|
-
}
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
package/src/devices/contact.ts
CHANGED
|
@@ -146,33 +146,33 @@ export class Contact {
|
|
|
146
146
|
refreshRate() {
|
|
147
147
|
if (this.device.refreshRate) {
|
|
148
148
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
149
|
-
if (this.platform.debugMode) {
|
|
150
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
149
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
150
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
151
151
|
}
|
|
152
152
|
} else if (this.platform.config.options!.refreshRate) {
|
|
153
153
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
154
|
-
if (this.platform.debugMode) {
|
|
155
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
154
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
155
|
+
this.warnLog(`Contact Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
logs() {
|
|
161
|
-
if (this.
|
|
161
|
+
if (this.platform.debugMode) {
|
|
162
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
163
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
164
|
+
} else if (this.device.logging) {
|
|
162
165
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
163
|
-
if (this.
|
|
164
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
166
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
167
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
165
168
|
}
|
|
166
169
|
} else if (this.platform.config.options?.logging) {
|
|
167
170
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
168
|
-
if (this.
|
|
169
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
171
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
172
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
170
173
|
}
|
|
171
174
|
} else {
|
|
172
175
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
173
|
-
if (this.platform.debugMode) {
|
|
174
|
-
this.warnLog('Using Device Standard Logging');
|
|
175
|
-
}
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
package/src/devices/curtains.ts
CHANGED
|
@@ -4,7 +4,7 @@ import Switchbot from 'node-switchbot';
|
|
|
4
4
|
import { interval, Subject } from 'rxjs';
|
|
5
5
|
import { SwitchBotPlatform } from '../platform';
|
|
6
6
|
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
7
|
-
import { Service, PlatformAccessory, CharacteristicValue
|
|
7
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
8
8
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, payload } from '../settings';
|
|
9
9
|
|
|
10
10
|
export class Curtain {
|
|
@@ -196,45 +196,45 @@ export class Curtain {
|
|
|
196
196
|
// refreshRate
|
|
197
197
|
if (this.device.refreshRate) {
|
|
198
198
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
199
|
-
if (this.platform.debugMode) {
|
|
200
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
199
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
200
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
201
201
|
}
|
|
202
202
|
} else if (this.platform.config.options!.refreshRate) {
|
|
203
203
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
204
|
-
if (this.platform.debugMode) {
|
|
205
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
204
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
205
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
// curtainRefreshRate
|
|
209
209
|
if (this.device?.curtain?.refreshRate) {
|
|
210
210
|
this.curtainRefreshRate = this.device?.curtain?.refreshRate;
|
|
211
|
-
if (this.platform.debugMode) {
|
|
212
|
-
this.warnLog(`Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
|
|
211
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
212
|
+
this.warnLog(`Curtain: ${this.accessory.displayName} Using Device Config Curtain refreshRate: ${this.deviceRefreshRate}`);
|
|
213
213
|
}
|
|
214
214
|
} else {
|
|
215
215
|
this.curtainRefreshRate = 5;
|
|
216
|
-
if (this.deviceLogging === 'debug') {
|
|
216
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
217
217
|
this.warnLog(`Curtain: ${this.accessory.displayName} Using Default Curtain Refresh Rate.`);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
logs() {
|
|
223
|
-
if (this.
|
|
223
|
+
if (this.platform.debugMode) {
|
|
224
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
225
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
226
|
+
} else if (this.device.logging) {
|
|
224
227
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
225
|
-
if (this.
|
|
226
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
228
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
229
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
227
230
|
}
|
|
228
231
|
} else if (this.platform.config.options?.logging) {
|
|
229
232
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
230
|
-
if (this.
|
|
231
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
233
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
234
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
232
235
|
}
|
|
233
236
|
} else {
|
|
234
237
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
235
|
-
if (this.platform.debugMode) {
|
|
236
|
-
this.warnLog('Using Device Standard Logging');
|
|
237
|
-
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -193,33 +193,33 @@ export class Humidifier {
|
|
|
193
193
|
refreshRate() {
|
|
194
194
|
if (this.device.refreshRate) {
|
|
195
195
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
196
|
-
if (this.platform.debugMode) {
|
|
197
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
196
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
197
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
198
198
|
}
|
|
199
199
|
} else if (this.platform.config.options!.refreshRate) {
|
|
200
200
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
201
|
-
if (this.platform.debugMode) {
|
|
202
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
201
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
202
|
+
this.warnLog(`Humidifier: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
logs() {
|
|
208
|
-
if (this.
|
|
208
|
+
if (this.platform.debugMode) {
|
|
209
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
210
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
211
|
+
} else if (this.device.logging) {
|
|
209
212
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
210
|
-
if (this.
|
|
211
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
213
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
214
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
212
215
|
}
|
|
213
216
|
} else if (this.platform.config.options?.logging) {
|
|
214
217
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
215
|
-
if (this.
|
|
216
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
218
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
219
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
217
220
|
}
|
|
218
221
|
} else {
|
|
219
222
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
220
|
-
if (this.platform.debugMode) {
|
|
221
|
-
this.warnLog('Using Device Standard Logging');
|
|
222
|
-
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
package/src/devices/meters.ts
CHANGED
|
@@ -183,33 +183,33 @@ export class Meter {
|
|
|
183
183
|
refreshRate() {
|
|
184
184
|
if (this.device.refreshRate) {
|
|
185
185
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
186
|
-
if (this.platform.debugMode) {
|
|
187
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
186
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
187
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
188
188
|
}
|
|
189
189
|
} else if (this.platform.config.options!.refreshRate) {
|
|
190
190
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
191
|
-
if (this.platform.debugMode) {
|
|
192
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
191
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
192
|
+
this.warnLog(`Meter: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
logs() {
|
|
198
|
-
if (this.
|
|
198
|
+
if (this.platform.debugMode) {
|
|
199
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
200
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
201
|
+
} else if (this.device.logging) {
|
|
199
202
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
200
|
-
if (this.
|
|
201
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
203
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
204
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
202
205
|
}
|
|
203
206
|
} else if (this.platform.config.options?.logging) {
|
|
204
207
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
205
|
-
if (this.
|
|
206
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
208
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
209
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
207
210
|
}
|
|
208
211
|
} else {
|
|
209
212
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
210
|
-
if (this.platform.debugMode) {
|
|
211
|
-
this.warnLog('Using Device Standard Logging');
|
|
212
|
-
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
package/src/devices/motion.ts
CHANGED
|
@@ -114,33 +114,33 @@ export class Motion {
|
|
|
114
114
|
refreshRate() {
|
|
115
115
|
if (this.device.refreshRate) {
|
|
116
116
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
117
|
-
if (this.platform.debugMode) {
|
|
118
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
117
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
118
|
+
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
119
119
|
}
|
|
120
120
|
} else if (this.platform.config.options!.refreshRate) {
|
|
121
121
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
122
|
-
if (this.platform.debugMode) {
|
|
123
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
122
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
123
|
+
this.warnLog(`Motion Sensor: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
logs() {
|
|
129
|
-
if (this.
|
|
129
|
+
if (this.platform.debugMode) {
|
|
130
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
131
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
132
|
+
} else if (this.device.logging) {
|
|
130
133
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
131
|
-
if (this.
|
|
132
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
134
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
135
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
133
136
|
}
|
|
134
137
|
} else if (this.platform.config.options?.logging) {
|
|
135
138
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
136
|
-
if (this.
|
|
137
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
139
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
140
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
138
141
|
}
|
|
139
142
|
} else {
|
|
140
143
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
141
|
-
if (this.platform.debugMode) {
|
|
142
|
-
this.warnLog('Using Device Standard Logging');
|
|
143
|
-
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
package/src/devices/plugs.ts
CHANGED
|
@@ -117,33 +117,33 @@ export class Plug {
|
|
|
117
117
|
refreshRate() {
|
|
118
118
|
if (this.device.refreshRate) {
|
|
119
119
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.device.refreshRate;
|
|
120
|
-
if (this.platform.debugMode) {
|
|
121
|
-
this.warnLog(`Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
120
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
121
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
|
|
122
122
|
}
|
|
123
123
|
} else if (this.platform.config.options!.refreshRate) {
|
|
124
124
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
125
|
-
if (this.platform.debugMode) {
|
|
126
|
-
this.warnLog(`Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
125
|
+
if (this.platform.debugMode || (this.deviceLogging === 'debug')) {
|
|
126
|
+
this.warnLog(`Plug: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
logs() {
|
|
132
|
-
if (this.
|
|
132
|
+
if (this.platform.debugMode) {
|
|
133
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
134
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
135
|
+
} else if (this.device.logging) {
|
|
133
136
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
134
|
-
if (this.
|
|
135
|
-
this.warnLog(`Using Device Config Logging: ${this.deviceLogging}`);
|
|
137
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
138
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
136
139
|
}
|
|
137
140
|
} else if (this.platform.config.options?.logging) {
|
|
138
141
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
139
|
-
if (this.
|
|
140
|
-
this.warnLog(`Using Platform Config Logging: ${this.deviceLogging}`);
|
|
142
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
143
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
141
144
|
}
|
|
142
145
|
} else {
|
|
143
146
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
144
|
-
if (this.platform.debugMode) {
|
|
145
|
-
this.warnLog('Using Device Standard Logging');
|
|
146
|
-
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
|
|
@@ -167,10 +167,19 @@ export class AirConditioner {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
logs() {
|
|
170
|
-
if (this.
|
|
170
|
+
if (this.platform.debugMode) {
|
|
171
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
172
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
173
|
+
} else if (this.device.logging) {
|
|
171
174
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
175
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
176
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
177
|
+
}
|
|
172
178
|
} else if (this.platform.config.options?.logging) {
|
|
173
179
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
180
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
181
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
182
|
+
}
|
|
174
183
|
} else {
|
|
175
184
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
176
185
|
}
|
|
@@ -88,10 +88,19 @@ export class AirPurifier {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
logs() {
|
|
91
|
-
if (this.
|
|
91
|
+
if (this.platform.debugMode) {
|
|
92
|
+
this.deviceLogging = this.accessory.context.logging = 'debug';
|
|
93
|
+
this.warnLog(`Water Heater: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
94
|
+
} else if (this.device.logging) {
|
|
92
95
|
this.deviceLogging = this.accessory.context.logging = this.device.logging;
|
|
96
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
97
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
98
|
+
}
|
|
93
99
|
} else if (this.platform.config.options?.logging) {
|
|
94
100
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
101
|
+
if (this.deviceLogging === 'debug' || this.deviceLogging === 'standard') {
|
|
102
|
+
this.warnLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
103
|
+
}
|
|
95
104
|
} else {
|
|
96
105
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
97
106
|
}
|