@switchbot/homebridge-switchbot 2.1.0-beta.1 → 2.1.0-beta.11
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 -2
- package/config.schema.json +10 -0
- package/dist/device/bot.d.ts +2 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +33 -8
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +15 -11
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +15 -10
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +8 -2
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +17 -6
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +12 -3
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +15 -4
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +8 -2
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +8 -2
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +8 -2
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +15 -4
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +15 -11
- package/dist/device/striplight.js.map +1 -1
- package/dist/platform.d.ts +0 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +91 -94
- package/dist/platform.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 +3 -3
- package/src/device/bot.ts +31 -12
- package/src/device/ceilinglight.ts +12 -11
- package/src/device/colorbulb.ts +12 -10
- package/src/device/contact.ts +6 -2
- package/src/device/curtain.ts +14 -6
- package/src/device/humidifier.ts +9 -3
- package/src/device/lock.ts +12 -4
- package/src/device/meter.ts +6 -2
- package/src/device/meterplus.ts +6 -2
- package/src/device/motion.ts +6 -2
- package/src/device/plug.ts +12 -4
- package/src/device/striplight.ts +12 -11
- package/src/platform.ts +94 -99
- package/src/settings.ts +1 -0
package/src/device/bot.ts
CHANGED
|
@@ -49,13 +49,12 @@ export class Bot {
|
|
|
49
49
|
// Config
|
|
50
50
|
botMode!: string;
|
|
51
51
|
allowPush?: boolean;
|
|
52
|
+
doublePress!: number;
|
|
53
|
+
pushRatePress!: number;
|
|
52
54
|
scanDuration!: number;
|
|
53
55
|
deviceLogging!: string;
|
|
54
56
|
deviceRefreshRate!: number;
|
|
55
57
|
|
|
56
|
-
// Others
|
|
57
|
-
doublePress!: number;
|
|
58
|
-
|
|
59
58
|
// Updates
|
|
60
59
|
botUpdateInProgress!: boolean;
|
|
61
60
|
doBotUpdate!: Subject<void>;
|
|
@@ -346,11 +345,15 @@ export class Bot {
|
|
|
346
345
|
)
|
|
347
346
|
.subscribe(async () => {
|
|
348
347
|
try {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
348
|
+
if (this.doublePress > 1) {
|
|
349
|
+
interval(this.pushRatePress * 1000)
|
|
350
|
+
.pipe(take(this.doublePress!))
|
|
351
|
+
.subscribe(async () => {
|
|
352
|
+
await this.pushChanges();
|
|
353
|
+
});
|
|
354
|
+
} else {
|
|
355
|
+
await this.pushChanges();
|
|
356
|
+
}
|
|
354
357
|
} catch (e: any) {
|
|
355
358
|
this.apiError(e);
|
|
356
359
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
|
|
@@ -364,7 +367,9 @@ export class Bot {
|
|
|
364
367
|
* Parse the device status from the SwitchBot api
|
|
365
368
|
*/
|
|
366
369
|
async parseStatus(): Promise<void> {
|
|
367
|
-
if (this.
|
|
370
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
371
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
372
|
+
} else if (this.BLE) {
|
|
368
373
|
await this.BLEparseStatus();
|
|
369
374
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
370
375
|
await this.openAPIparseStatus();
|
|
@@ -419,7 +424,9 @@ export class Bot {
|
|
|
419
424
|
* Asks the SwitchBot API for the latest device information
|
|
420
425
|
*/
|
|
421
426
|
async refreshStatus(): Promise<void> {
|
|
422
|
-
if (this.
|
|
427
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
428
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
429
|
+
} else if (this.BLE) {
|
|
423
430
|
await this.BLERefreshStatus();
|
|
424
431
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
425
432
|
await this.openAPIRefreshStatus();
|
|
@@ -554,7 +561,9 @@ export class Bot {
|
|
|
554
561
|
* Bot - "command" "press" "default" = trigger press
|
|
555
562
|
*/
|
|
556
563
|
async pushChanges(): Promise<void> {
|
|
557
|
-
if (this.
|
|
564
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
565
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
566
|
+
} else if (this.BLE) {
|
|
558
567
|
await this.BLEpushChanges();
|
|
559
568
|
} else if (this.OpenAPI) {
|
|
560
569
|
await this.openAPIpushChanges();
|
|
@@ -562,7 +571,9 @@ export class Bot {
|
|
|
562
571
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
563
572
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
564
573
|
}
|
|
565
|
-
|
|
574
|
+
// Refresh the status from the API
|
|
575
|
+
interval(15000)
|
|
576
|
+
.pipe(skipWhile(() => this.botUpdateInProgress))
|
|
566
577
|
.pipe(take(1))
|
|
567
578
|
.subscribe(async () => {
|
|
568
579
|
await this.refreshStatus();
|
|
@@ -1290,6 +1301,14 @@ export class Bot {
|
|
|
1290
1301
|
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
|
|
1291
1302
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
|
|
1292
1303
|
}
|
|
1304
|
+
// pushRatePress
|
|
1305
|
+
if (device?.bot?.pushRatePress) {
|
|
1306
|
+
this.pushRatePress = device?.bot?.pushRatePress;
|
|
1307
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Bot pushRatePress: ${this.pushRatePress}`);
|
|
1308
|
+
} else {
|
|
1309
|
+
this.pushRatePress = 15;
|
|
1310
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default Bot pushRatePress: ${this.pushRatePress}`);
|
|
1311
|
+
}
|
|
1293
1312
|
}
|
|
1294
1313
|
|
|
1295
1314
|
async config(device: device & devicesConfig): Promise<void> {
|
|
@@ -206,13 +206,6 @@ export class CeilingLight {
|
|
|
206
206
|
+ ` Error Message: ${superStringify(e.message)}`);
|
|
207
207
|
}
|
|
208
208
|
this.ceilingLightUpdateInProgress = false;
|
|
209
|
-
// Refresh the status from the API
|
|
210
|
-
interval(15000)
|
|
211
|
-
.pipe(skipWhile(() => this.ceilingLightUpdateInProgress))
|
|
212
|
-
.pipe(take(1))
|
|
213
|
-
.subscribe(async () => {
|
|
214
|
-
await this.refreshStatus();
|
|
215
|
-
});
|
|
216
209
|
});
|
|
217
210
|
}
|
|
218
211
|
|
|
@@ -232,7 +225,9 @@ export class CeilingLight {
|
|
|
232
225
|
* Parse the device status from the SwitchBot api
|
|
233
226
|
*/
|
|
234
227
|
async parseStatus(): Promise<void> {
|
|
235
|
-
|
|
228
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
229
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
230
|
+
} else /*if (this.BLE) {
|
|
236
231
|
await this.BLEparseStatus();
|
|
237
232
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
238
233
|
await this.openAPIparseStatus();
|
|
@@ -307,7 +302,9 @@ export class CeilingLight {
|
|
|
307
302
|
* Asks the SwitchBot API for the latest device information
|
|
308
303
|
*/
|
|
309
304
|
async refreshStatus(): Promise<void> {
|
|
310
|
-
|
|
305
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
306
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
307
|
+
} else/*if (this.BLE) {
|
|
311
308
|
await this.BLERefreshStatus();
|
|
312
309
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
313
310
|
await this.openAPIRefreshStatus();
|
|
@@ -456,7 +453,9 @@ export class CeilingLight {
|
|
|
456
453
|
*
|
|
457
454
|
*/
|
|
458
455
|
async pushChanges(): Promise<void> {
|
|
459
|
-
|
|
456
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
457
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
458
|
+
} else /*if (this.BLE) {
|
|
460
459
|
await this.BLEpushChanges();
|
|
461
460
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
462
461
|
await this.openAPIpushChanges();
|
|
@@ -464,7 +463,9 @@ export class CeilingLight {
|
|
|
464
463
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
465
464
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
466
465
|
}
|
|
467
|
-
|
|
466
|
+
// Refresh the status from the API
|
|
467
|
+
interval(15000)
|
|
468
|
+
.pipe(skipWhile(() => this.ceilingLightUpdateInProgress))
|
|
468
469
|
.pipe(take(1))
|
|
469
470
|
.subscribe(async () => {
|
|
470
471
|
await this.refreshStatus();
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -206,13 +206,6 @@ export class ColorBulb {
|
|
|
206
206
|
+ ` Error Message: ${superStringify(e.message)}`);
|
|
207
207
|
}
|
|
208
208
|
this.colorBulbUpdateInProgress = false;
|
|
209
|
-
// Refresh the status from the API
|
|
210
|
-
interval(15000)
|
|
211
|
-
.pipe(skipWhile(() => this.colorBulbUpdateInProgress))
|
|
212
|
-
.pipe(take(1))
|
|
213
|
-
.subscribe(async () => {
|
|
214
|
-
await this.refreshStatus();
|
|
215
|
-
});
|
|
216
209
|
});
|
|
217
210
|
}
|
|
218
211
|
|
|
@@ -220,7 +213,9 @@ export class ColorBulb {
|
|
|
220
213
|
* Parse the device status from the SwitchBot api
|
|
221
214
|
*/
|
|
222
215
|
async parseStatus(): Promise<void> {
|
|
223
|
-
|
|
216
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
217
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
218
|
+
} else/*if (this.BLE) {
|
|
224
219
|
await this.BLEparseStatus();
|
|
225
220
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
226
221
|
await this.openAPIparseStatus();
|
|
@@ -295,7 +290,9 @@ export class ColorBulb {
|
|
|
295
290
|
* Asks the SwitchBot API for the latest device information
|
|
296
291
|
*/
|
|
297
292
|
async refreshStatus(): Promise<void> {
|
|
298
|
-
|
|
293
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
294
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
295
|
+
} else/*if (this.BLE) {
|
|
299
296
|
await this.BLERefreshStatus();
|
|
300
297
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
301
298
|
await this.openAPIRefreshStatus();
|
|
@@ -444,6 +441,9 @@ export class ColorBulb {
|
|
|
444
441
|
*
|
|
445
442
|
*/
|
|
446
443
|
async pushChanges(): Promise<void> {
|
|
444
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
445
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
446
|
+
} else
|
|
447
447
|
/*if (this.BLE) {
|
|
448
448
|
await this.BLEpushChanges();
|
|
449
449
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
@@ -452,7 +452,9 @@ export class ColorBulb {
|
|
|
452
452
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
453
453
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
454
454
|
}
|
|
455
|
-
|
|
455
|
+
// Refresh the status from the API
|
|
456
|
+
interval(15000)
|
|
457
|
+
.pipe(skipWhile(() => this.colorBulbUpdateInProgress))
|
|
456
458
|
.pipe(take(1))
|
|
457
459
|
.subscribe(async () => {
|
|
458
460
|
await this.refreshStatus();
|
package/src/device/contact.ts
CHANGED
|
@@ -163,7 +163,9 @@ export class Contact {
|
|
|
163
163
|
* Parse the device status from the SwitchBot api
|
|
164
164
|
*/
|
|
165
165
|
async parseStatus(): Promise<void> {
|
|
166
|
-
if (this.
|
|
166
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
167
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
168
|
+
} else if (this.BLE) {
|
|
167
169
|
await this.BLEparseStatus();
|
|
168
170
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
169
171
|
await this.openAPIparseStatus();
|
|
@@ -261,7 +263,9 @@ export class Contact {
|
|
|
261
263
|
* Asks the SwitchBot API for the latest device information
|
|
262
264
|
*/
|
|
263
265
|
async refreshStatus(): Promise<void> {
|
|
264
|
-
if (this.
|
|
266
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
267
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
268
|
+
} else if (this.BLE) {
|
|
265
269
|
await this.BLERefreshStatus();
|
|
266
270
|
} else if (this.OpenAPI) {
|
|
267
271
|
await this.openAPIRefreshStatus();
|
package/src/device/curtain.ts
CHANGED
|
@@ -214,7 +214,9 @@ export class Curtain {
|
|
|
214
214
|
* Parse the device status from the SwitchBot api
|
|
215
215
|
*/
|
|
216
216
|
async parseStatus(): Promise<void> {
|
|
217
|
-
if (this.
|
|
217
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
218
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
219
|
+
} else if (this.BLE) {
|
|
218
220
|
await this.BLEparseStatus();
|
|
219
221
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
220
222
|
await this.openAPIparseStatus();
|
|
@@ -386,7 +388,9 @@ export class Curtain {
|
|
|
386
388
|
}
|
|
387
389
|
|
|
388
390
|
async refreshStatus(): Promise<void> {
|
|
389
|
-
if (this.
|
|
391
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
392
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
393
|
+
} else if (this.BLE) {
|
|
390
394
|
await this.BLERefreshStatus();
|
|
391
395
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
392
396
|
await this.openAPIRefreshStatus();
|
|
@@ -517,7 +521,9 @@ export class Curtain {
|
|
|
517
521
|
}
|
|
518
522
|
|
|
519
523
|
async pushChanges(): Promise<void> {
|
|
520
|
-
if (this.
|
|
524
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
525
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
526
|
+
} else if (this.BLE) {
|
|
521
527
|
await this.BLEpushChanges();
|
|
522
528
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
523
529
|
await this.openAPIpushChanges();
|
|
@@ -525,7 +531,9 @@ export class Curtain {
|
|
|
525
531
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
526
532
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
527
533
|
}
|
|
528
|
-
|
|
534
|
+
// Refresh the status from the API
|
|
535
|
+
interval(15000)
|
|
536
|
+
.pipe(skipWhile(() => this.curtainUpdateInProgress))
|
|
529
537
|
.pipe(take(1))
|
|
530
538
|
.subscribe(async () => {
|
|
531
539
|
await this.refreshStatus();
|
|
@@ -1020,10 +1028,10 @@ export class Curtain {
|
|
|
1020
1028
|
// updateRate
|
|
1021
1029
|
if (device?.curtain?.updateRate) {
|
|
1022
1030
|
this.updateRate = device?.curtain?.updateRate;
|
|
1023
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Curtain
|
|
1031
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Curtain updateRate: ${this.updateRate}`);
|
|
1024
1032
|
} else {
|
|
1025
1033
|
this.updateRate = 7;
|
|
1026
|
-
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default Curtain
|
|
1034
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default Curtain updateRate: ${this.updateRate}`);
|
|
1027
1035
|
}
|
|
1028
1036
|
}
|
|
1029
1037
|
|
package/src/device/humidifier.ts
CHANGED
|
@@ -192,7 +192,9 @@ export class Humidifier {
|
|
|
192
192
|
* Parse the device status from the SwitchBot api
|
|
193
193
|
*/
|
|
194
194
|
async parseStatus(): Promise<void> {
|
|
195
|
-
if (this.
|
|
195
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
196
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
197
|
+
} else if (this.BLE) {
|
|
196
198
|
await this.BLEparseStatus();
|
|
197
199
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
198
200
|
await this.openAPIparseStatus();
|
|
@@ -279,7 +281,9 @@ export class Humidifier {
|
|
|
279
281
|
* Asks the SwitchBot API for the latest device information
|
|
280
282
|
*/
|
|
281
283
|
async refreshStatus(): Promise<void> {
|
|
282
|
-
if (this.
|
|
284
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
285
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
286
|
+
} else if (this.BLE) {
|
|
283
287
|
await this.BLERefreshStatus();
|
|
284
288
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
285
289
|
await this.openAPIRefreshStatus();
|
|
@@ -415,7 +419,9 @@ export class Humidifier {
|
|
|
415
419
|
* Pushes the requested changes to the SwitchBot API
|
|
416
420
|
*/
|
|
417
421
|
async pushChanges(): Promise<void> {
|
|
418
|
-
|
|
422
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
423
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
424
|
+
} else /*if (this.BLE) {
|
|
419
425
|
await this.BLEpushChanges();
|
|
420
426
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
421
427
|
await this.openAPIpushChanges();
|
package/src/device/lock.ts
CHANGED
|
@@ -132,7 +132,9 @@ export class Lock {
|
|
|
132
132
|
* Parse the device status from the SwitchBot api
|
|
133
133
|
*/
|
|
134
134
|
async parseStatus(): Promise<void> {
|
|
135
|
-
|
|
135
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
136
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
137
|
+
} else/*if (this.BLE) {
|
|
136
138
|
await this.BLEparseStatus();
|
|
137
139
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
138
140
|
await this.openAPIparseStatus();
|
|
@@ -190,7 +192,9 @@ export class Lock {
|
|
|
190
192
|
* Asks the SwitchBot API for the latest device information
|
|
191
193
|
*/
|
|
192
194
|
async refreshStatus(): Promise<void> {
|
|
193
|
-
|
|
195
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
196
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
197
|
+
} else/*if (this.BLE) {
|
|
194
198
|
await this.BLERefreshStatus();
|
|
195
199
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
196
200
|
await this.openAPIRefreshStatus();
|
|
@@ -260,7 +264,9 @@ export class Lock {
|
|
|
260
264
|
* Lock - "command" "unlock" "default" = set to ???? state - LockCurrentState
|
|
261
265
|
*/
|
|
262
266
|
async pushChanges(): Promise<void> {
|
|
263
|
-
|
|
267
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
268
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
269
|
+
} else /*if (this.BLE) {
|
|
264
270
|
await this.BLEpushChanges();
|
|
265
271
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
266
272
|
await this.openAPIpushChanges();
|
|
@@ -268,7 +274,9 @@ export class Lock {
|
|
|
268
274
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
269
275
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
270
276
|
}
|
|
271
|
-
|
|
277
|
+
// Refresh the status from the API
|
|
278
|
+
interval(15000)
|
|
279
|
+
.pipe(skipWhile(() => this.lockUpdateInProgress))
|
|
272
280
|
.pipe(take(1))
|
|
273
281
|
.subscribe(async () => {
|
|
274
282
|
await this.refreshStatus();
|
package/src/device/meter.ts
CHANGED
|
@@ -176,7 +176,9 @@ export class Meter {
|
|
|
176
176
|
* Parse the device status from the SwitchBot api
|
|
177
177
|
*/
|
|
178
178
|
async parseStatus(): Promise<void> {
|
|
179
|
-
if (this.
|
|
179
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
180
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
181
|
+
} else if (this.BLE) {
|
|
180
182
|
await this.BLEparseStatus();
|
|
181
183
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
182
184
|
await this.openAPIparseStatus();
|
|
@@ -231,7 +233,9 @@ export class Meter {
|
|
|
231
233
|
* Asks the SwitchBot API for the latest device information
|
|
232
234
|
*/
|
|
233
235
|
async refreshStatus(): Promise<void> {
|
|
234
|
-
if (this.
|
|
236
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
237
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
238
|
+
} else if (this.BLE) {
|
|
235
239
|
await this.BLERefreshStatus();
|
|
236
240
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
237
241
|
await this.openAPIRefreshStatus();
|
package/src/device/meterplus.ts
CHANGED
|
@@ -176,7 +176,9 @@ export class MeterPlus {
|
|
|
176
176
|
* Parse the device status from the SwitchBot api
|
|
177
177
|
*/
|
|
178
178
|
async parseStatus(): Promise<void> {
|
|
179
|
-
if (this.
|
|
179
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
180
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
181
|
+
} else if (this.BLE) {
|
|
180
182
|
await this.BLEparseStatus();
|
|
181
183
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
182
184
|
await this.openAPIparseStatus();
|
|
@@ -231,7 +233,9 @@ export class MeterPlus {
|
|
|
231
233
|
* Asks the SwitchBot API for the latest device information
|
|
232
234
|
*/
|
|
233
235
|
async refreshStatus(): Promise<void> {
|
|
234
|
-
if (this.
|
|
236
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
237
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
238
|
+
} else if (this.BLE) {
|
|
235
239
|
await this.BLERefreshStatus();
|
|
236
240
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
237
241
|
await this.openAPIRefreshStatus();
|
package/src/device/motion.ts
CHANGED
|
@@ -142,7 +142,9 @@ export class Motion {
|
|
|
142
142
|
* Parse the device status from the SwitchBot api
|
|
143
143
|
*/
|
|
144
144
|
async parseStatus(): Promise<void> {
|
|
145
|
-
if (this.
|
|
145
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
146
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
147
|
+
} else if (this.BLE) {
|
|
146
148
|
await this.BLEparseStatus();
|
|
147
149
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
148
150
|
await this.openAPIparseStatus();
|
|
@@ -213,7 +215,9 @@ export class Motion {
|
|
|
213
215
|
* Asks the SwitchBot API for the latest device information
|
|
214
216
|
*/
|
|
215
217
|
async refreshStatus(): Promise<void> {
|
|
216
|
-
if (this.
|
|
218
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
219
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
220
|
+
} else if (this.BLE) {
|
|
217
221
|
await this.BLERefreshStatus();
|
|
218
222
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
219
223
|
await this.openAPIRefreshStatus();
|
package/src/device/plug.ts
CHANGED
|
@@ -125,7 +125,9 @@ export class Plug {
|
|
|
125
125
|
* Parse the device status from the SwitchBot api
|
|
126
126
|
*/
|
|
127
127
|
async parseStatus(): Promise<void> {
|
|
128
|
-
if (this.
|
|
128
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
129
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
130
|
+
} else if (this.BLE) {
|
|
129
131
|
await this.BLEparseStatus();
|
|
130
132
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
131
133
|
await this.openAPIparseStatus();
|
|
@@ -164,7 +166,9 @@ export class Plug {
|
|
|
164
166
|
* Asks the SwitchBot API for the latest device information
|
|
165
167
|
*/
|
|
166
168
|
async refreshStatus(): Promise<void> {
|
|
167
|
-
if (this.
|
|
169
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
170
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
171
|
+
} else if (this.BLE) {
|
|
168
172
|
await this.BLERefreshStatus();
|
|
169
173
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
170
174
|
await this.openAPIRefreshStatus();
|
|
@@ -308,7 +312,9 @@ export class Plug {
|
|
|
308
312
|
*/
|
|
309
313
|
|
|
310
314
|
async pushChanges(): Promise<void> {
|
|
311
|
-
if (this.
|
|
315
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
316
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
317
|
+
} else if (this.BLE) {
|
|
312
318
|
await this.BLEpushChanges();
|
|
313
319
|
} else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
314
320
|
await this.openAPIpushChanges();
|
|
@@ -316,7 +322,9 @@ export class Plug {
|
|
|
316
322
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
317
323
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
318
324
|
}
|
|
319
|
-
|
|
325
|
+
// Refresh the status from the API
|
|
326
|
+
interval(15000)
|
|
327
|
+
.pipe(skipWhile(() => this.plugUpdateInProgress))
|
|
320
328
|
.pipe(take(1))
|
|
321
329
|
.subscribe(async () => {
|
|
322
330
|
await this.refreshStatus();
|
package/src/device/striplight.ts
CHANGED
|
@@ -205,13 +205,6 @@ export class StripLight {
|
|
|
205
205
|
+ ` Error Message: ${superStringify(e.message)}`);
|
|
206
206
|
}
|
|
207
207
|
this.stripLightUpdateInProgress = false;
|
|
208
|
-
// Refresh the status from the API
|
|
209
|
-
interval(15000)
|
|
210
|
-
.pipe(skipWhile(() => this.stripLightUpdateInProgress))
|
|
211
|
-
.pipe(take(1))
|
|
212
|
-
.subscribe(async () => {
|
|
213
|
-
await this.refreshStatus();
|
|
214
|
-
});
|
|
215
208
|
});
|
|
216
209
|
}
|
|
217
210
|
|
|
@@ -219,7 +212,9 @@ export class StripLight {
|
|
|
219
212
|
* Parse the device status from the SwitchBot api
|
|
220
213
|
*/
|
|
221
214
|
async parseStatus(): Promise<void> {
|
|
222
|
-
|
|
215
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
216
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
217
|
+
} else/*if (this.BLE) {
|
|
223
218
|
await this.BLEparseStatus();
|
|
224
219
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
225
220
|
await this.openAPIparseStatus();
|
|
@@ -283,7 +278,9 @@ export class StripLight {
|
|
|
283
278
|
* Asks the SwitchBot API for the latest device information
|
|
284
279
|
*/
|
|
285
280
|
async refreshStatus(): Promise<void> {
|
|
286
|
-
|
|
281
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
282
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
283
|
+
} else/*if (this.BLE) {
|
|
287
284
|
await this.BLERefreshStatus();
|
|
288
285
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
289
286
|
await this.openAPIRefreshStatus();
|
|
@@ -430,7 +427,9 @@ export class StripLight {
|
|
|
430
427
|
*
|
|
431
428
|
*/
|
|
432
429
|
async pushChanges(): Promise<void> {
|
|
433
|
-
|
|
430
|
+
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
431
|
+
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
432
|
+
} else /*if (this.BLE) {
|
|
434
433
|
await this.BLEpushChanges();
|
|
435
434
|
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
436
435
|
await this.openAPIpushChanges();
|
|
@@ -438,7 +437,9 @@ export class StripLight {
|
|
|
438
437
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
|
|
439
438
|
+ ` ${this.device.connectionType}, pushChanges will not happen.`);
|
|
440
439
|
}
|
|
441
|
-
|
|
440
|
+
// Refresh the status from the API
|
|
441
|
+
interval(15000)
|
|
442
|
+
.pipe(skipWhile(() => this.stripLightUpdateInProgress))
|
|
442
443
|
.pipe(take(1))
|
|
443
444
|
.subscribe(async () => {
|
|
444
445
|
await this.refreshStatus();
|