@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.10
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/.prettierrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/blindtilt.d.ts +1 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +58 -65
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +52 -55
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +1 -0
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +68 -68
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +1 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +76 -75
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +67 -59
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +81 -94
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +9 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +197 -30
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +58 -62
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +1 -0
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +28 -26
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +1 -0
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +68 -67
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +51 -47
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +5 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +75 -74
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +4 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +74 -74
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +66 -54
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +1 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +39 -39
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +1 -0
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +74 -53
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +64 -66
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +32 -34
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +20 -23
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -2
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +30 -32
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +26 -29
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +22 -23
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -2
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +47 -50
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +20 -23
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +22 -23
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +46 -44
- 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/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/device/blindtilt.ts +114 -78
- package/src/device/bot.ts +102 -63
- package/src/device/ceilinglight.ts +113 -73
- package/src/device/colorbulb.ts +144 -87
- package/src/device/contact.ts +98 -63
- package/src/device/curtain.ts +160 -134
- package/src/device/hub.ts +228 -39
- package/src/device/humidifier.ts +136 -85
- package/src/device/iosensor.ts +52 -32
- package/src/device/lightstrip.ts +118 -72
- package/src/device/lock.ts +85 -50
- package/src/device/meter.ts +104 -80
- package/src/device/meterplus.ts +103 -80
- package/src/device/motion.ts +95 -59
- package/src/device/plug.ts +70 -44
- package/src/device/robotvacuumcleaner.ts +107 -56
- package/src/irdevice/airconditioner.ts +116 -86
- package/src/irdevice/airpurifier.ts +60 -39
- package/src/irdevice/camera.ts +40 -28
- package/src/irdevice/fan.ts +52 -38
- package/src/irdevice/light.ts +48 -34
- package/src/irdevice/other.ts +44 -28
- package/src/irdevice/tv.ts +70 -56
- package/src/irdevice/vacuumcleaner.ts +40 -28
- package/src/irdevice/waterheater.ts +48 -32
- package/src/platform.ts +87 -56
- package/src/settings.ts +41 -40
- package/src/utils.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable brace-style */
|
|
1
2
|
import { Context } from 'vm';
|
|
2
3
|
import { request } from 'undici';
|
|
3
4
|
import { sleep } from '../utils';
|
|
@@ -24,6 +25,7 @@ export class CeilingLight {
|
|
|
24
25
|
ColorTemperature?: CharacteristicValue;
|
|
25
26
|
|
|
26
27
|
// OpenAPI Others
|
|
28
|
+
Version: deviceStatus['version'];
|
|
27
29
|
power: deviceStatus['power'];
|
|
28
30
|
color: deviceStatus['color'];
|
|
29
31
|
brightness: deviceStatus['brightness'];
|
|
@@ -59,17 +61,22 @@ export class CeilingLight {
|
|
|
59
61
|
doCeilingLightUpdate!: Subject<void>;
|
|
60
62
|
|
|
61
63
|
// Connection
|
|
62
|
-
private readonly BLE =
|
|
63
|
-
private readonly OpenAPI =
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
64
|
+
private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
65
|
+
private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
private readonly platform: SwitchBotPlatform,
|
|
69
|
+
private accessory: PlatformAccessory,
|
|
70
|
+
public device: device & devicesConfig,
|
|
71
|
+
) {
|
|
66
72
|
// default placeholders
|
|
67
73
|
this.logs(device);
|
|
68
74
|
this.scan(device);
|
|
69
75
|
this.refreshRate(device);
|
|
70
76
|
this.adaptiveLighting(device);
|
|
71
|
-
this.config(device);
|
|
72
77
|
this.context();
|
|
78
|
+
this.config(device);
|
|
79
|
+
|
|
73
80
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
74
81
|
this.doCeilingLightUpdate = new Subject();
|
|
75
82
|
this.ceilingLightUpdateInProgress = false;
|
|
@@ -202,8 +209,10 @@ export class CeilingLight {
|
|
|
202
209
|
await this.pushChanges();
|
|
203
210
|
} catch (e: any) {
|
|
204
211
|
this.apiError(e);
|
|
205
|
-
this.errorLog(
|
|
206
|
-
|
|
212
|
+
this.errorLog(
|
|
213
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
|
|
214
|
+
` Error Message: ${JSON.stringify(e.message)}`,
|
|
215
|
+
);
|
|
207
216
|
}
|
|
208
217
|
this.ceilingLightUpdateInProgress = false;
|
|
209
218
|
});
|
|
@@ -227,14 +236,16 @@ export class CeilingLight {
|
|
|
227
236
|
async parseStatus(): Promise<void> {
|
|
228
237
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
229
238
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
230
|
-
}
|
|
239
|
+
}
|
|
240
|
+
/*if (this.BLE) {
|
|
231
241
|
await this.BLEparseStatus();
|
|
232
|
-
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
242
|
+
} else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
233
243
|
await this.openAPIparseStatus();
|
|
234
244
|
} else {
|
|
235
245
|
await this.offlineOff();
|
|
236
|
-
this.debugWarnLog(
|
|
237
|
-
|
|
246
|
+
this.debugWarnLog(
|
|
247
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
|
|
248
|
+
);
|
|
238
249
|
}
|
|
239
250
|
}
|
|
240
251
|
|
|
@@ -275,8 +286,9 @@ export class CeilingLight {
|
|
|
275
286
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${JSON.stringify(blue)}`);
|
|
276
287
|
|
|
277
288
|
const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
|
|
278
|
-
this.debugLog(
|
|
279
|
-
+ ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}
|
|
289
|
+
this.debugLog(
|
|
290
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` + ` hs: ${JSON.stringify(rgb2hs(Number(red), Number(green), Number(blue)))}`,
|
|
291
|
+
);
|
|
280
292
|
|
|
281
293
|
// Hue
|
|
282
294
|
this.Hue = hue;
|
|
@@ -305,14 +317,16 @@ export class CeilingLight {
|
|
|
305
317
|
async refreshStatus(): Promise<void> {
|
|
306
318
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
307
319
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
|
|
308
|
-
}
|
|
320
|
+
} /*if (this.BLE) {
|
|
309
321
|
await this.BLERefreshStatus();
|
|
310
|
-
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
322
|
+
} else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
311
323
|
await this.openAPIRefreshStatus();
|
|
312
324
|
} else {
|
|
313
325
|
await this.offlineOff();
|
|
314
|
-
this.debugWarnLog(
|
|
315
|
-
|
|
326
|
+
this.debugWarnLog(
|
|
327
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
|
|
328
|
+
` ${this.device.connectionType}, refreshStatus will not happen.`,
|
|
329
|
+
);
|
|
316
330
|
}
|
|
317
331
|
}
|
|
318
332
|
|
|
@@ -337,8 +351,10 @@ export class CeilingLight {
|
|
|
337
351
|
// Set an event hander
|
|
338
352
|
switchbot.onadvertisement = async (ad: any) => {
|
|
339
353
|
this.address = ad.address;
|
|
340
|
-
this.debugLog(
|
|
341
|
-
|
|
354
|
+
this.debugLog(
|
|
355
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
356
|
+
` BLE Address Found: ${this.address}`,
|
|
357
|
+
);
|
|
342
358
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
343
359
|
this.serviceData = ad.serviceData;
|
|
344
360
|
//this.state = ad.serviceData.state;
|
|
@@ -373,8 +389,10 @@ export class CeilingLight {
|
|
|
373
389
|
})
|
|
374
390
|
.catch(async (e: any) => {
|
|
375
391
|
this.apiError(e);
|
|
376
|
-
this.errorLog(
|
|
377
|
-
|
|
392
|
+
this.errorLog(
|
|
393
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
|
|
394
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
395
|
+
);
|
|
378
396
|
await this.BLERefreshConnection(switchbot);
|
|
379
397
|
});
|
|
380
398
|
} else {
|
|
@@ -392,10 +410,7 @@ export class CeilingLight {
|
|
|
392
410
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
|
|
393
411
|
this.statusCode(statusCode);
|
|
394
412
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
395
|
-
this.debugLog(
|
|
396
|
-
`${this.device.deviceType}: ${this.accessory.displayName
|
|
397
|
-
} refreshStatus: ${JSON.stringify(deviceStatus)}`,
|
|
398
|
-
);
|
|
413
|
+
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
|
|
399
414
|
this.power = deviceStatus.body.power;
|
|
400
415
|
this.color = deviceStatus.body.color;
|
|
401
416
|
this.brightness = deviceStatus.body.brightness;
|
|
@@ -404,8 +419,10 @@ export class CeilingLight {
|
|
|
404
419
|
this.updateHomeKitCharacteristics();
|
|
405
420
|
} catch (e: any) {
|
|
406
421
|
this.apiError(e);
|
|
407
|
-
this.errorLog(
|
|
408
|
-
|
|
422
|
+
this.errorLog(
|
|
423
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
|
|
424
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
425
|
+
);
|
|
409
426
|
}
|
|
410
427
|
}
|
|
411
428
|
|
|
@@ -423,14 +440,15 @@ export class CeilingLight {
|
|
|
423
440
|
async pushChanges(): Promise<void> {
|
|
424
441
|
if (!this.device.enableCloudService && this.OpenAPI) {
|
|
425
442
|
this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
|
|
426
|
-
}
|
|
443
|
+
} /*if (this.BLE) {
|
|
427
444
|
await this.BLEpushChanges();
|
|
428
|
-
} else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
445
|
+
} else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
|
|
429
446
|
await this.openAPIpushChanges();
|
|
430
447
|
} else {
|
|
431
448
|
await this.offlineOff();
|
|
432
|
-
this.debugWarnLog(
|
|
433
|
-
|
|
449
|
+
this.debugWarnLog(
|
|
450
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
|
|
451
|
+
);
|
|
434
452
|
}
|
|
435
453
|
// Refresh the status from the API
|
|
436
454
|
interval(15000)
|
|
@@ -476,14 +494,15 @@ export class CeilingLight {
|
|
|
476
494
|
})
|
|
477
495
|
.catch(async (e: any) => {
|
|
478
496
|
this.apiError(e);
|
|
479
|
-
this.errorLog(
|
|
480
|
-
|
|
497
|
+
this.errorLog(
|
|
498
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
|
|
499
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
500
|
+
);
|
|
481
501
|
await this.BLEPushConnection();
|
|
482
502
|
});
|
|
483
503
|
} else {
|
|
484
504
|
this.debugLog(
|
|
485
|
-
`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
|
|
486
|
-
+ `OnCached: ${this.accessory.context.On}`,
|
|
505
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
|
|
487
506
|
);
|
|
488
507
|
}
|
|
489
508
|
}
|
|
@@ -498,9 +517,9 @@ export class CeilingLight {
|
|
|
498
517
|
command = 'turnOff';
|
|
499
518
|
}
|
|
500
519
|
const bodyChange = JSON.stringify({
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
520
|
+
command: `${command}`,
|
|
521
|
+
parameter: 'default',
|
|
522
|
+
commandType: 'command',
|
|
504
523
|
});
|
|
505
524
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
506
525
|
try {
|
|
@@ -515,13 +534,17 @@ export class CeilingLight {
|
|
|
515
534
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
|
|
516
535
|
} catch (e: any) {
|
|
517
536
|
this.apiError(e);
|
|
518
|
-
this.errorLog(
|
|
519
|
-
|
|
537
|
+
this.errorLog(
|
|
538
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
|
|
539
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
520
540
|
);
|
|
521
541
|
}
|
|
522
542
|
} else {
|
|
523
|
-
this.debugLog(
|
|
524
|
-
|
|
543
|
+
this.debugLog(
|
|
544
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
|
|
545
|
+
`On: ${this.On}, ` +
|
|
546
|
+
`OnCached: ${this.accessory.context.On}`,
|
|
547
|
+
);
|
|
525
548
|
}
|
|
526
549
|
// Push Hue & Saturation Update
|
|
527
550
|
if (this.On) {
|
|
@@ -545,9 +568,9 @@ export class CeilingLight {
|
|
|
545
568
|
const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
|
|
546
569
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${JSON.stringify([red, green, blue])}`);
|
|
547
570
|
const bodyChange = JSON.stringify({
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
571
|
+
command: 'setColor',
|
|
572
|
+
parameter: `${red}:${green}:${blue}`,
|
|
573
|
+
commandType: 'command',
|
|
551
574
|
});
|
|
552
575
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
553
576
|
try {
|
|
@@ -562,13 +585,16 @@ export class CeilingLight {
|
|
|
562
585
|
this.debugLog(`Headers: ${JSON.stringify(headers)}`);
|
|
563
586
|
} catch (e: any) {
|
|
564
587
|
this.apiError(e);
|
|
565
|
-
this.errorLog(
|
|
566
|
-
|
|
588
|
+
this.errorLog(
|
|
589
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushHueSaturationChanges with ${this.device.connectionType}` +
|
|
590
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
567
591
|
);
|
|
568
592
|
}
|
|
569
593
|
} else {
|
|
570
|
-
this.debugLog(
|
|
571
|
-
|
|
594
|
+
this.debugLog(
|
|
595
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No pushHueSaturationChanges. Hue: ${this.Hue}, ` +
|
|
596
|
+
`HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`,
|
|
597
|
+
);
|
|
572
598
|
}
|
|
573
599
|
}
|
|
574
600
|
|
|
@@ -578,9 +604,9 @@ export class CeilingLight {
|
|
|
578
604
|
const kelvin = Math.round(1000000 / Number(this.ColorTemperature));
|
|
579
605
|
this.cacheKelvin = kelvin;
|
|
580
606
|
const bodyChange = JSON.stringify({
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
607
|
+
command: 'setColorTemperature',
|
|
608
|
+
parameter: `${kelvin}`,
|
|
609
|
+
commandType: 'command',
|
|
584
610
|
});
|
|
585
611
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
586
612
|
try {
|
|
@@ -595,13 +621,16 @@ export class CeilingLight {
|
|
|
595
621
|
this.debugLog(`Headers: ${JSON.stringify(headers)}`);
|
|
596
622
|
} catch (e: any) {
|
|
597
623
|
this.apiError(e);
|
|
598
|
-
this.errorLog(
|
|
599
|
-
|
|
624
|
+
this.errorLog(
|
|
625
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushColorTemperatureChanges with ${this.device.connectionType}` +
|
|
626
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
600
627
|
);
|
|
601
628
|
}
|
|
602
629
|
} else {
|
|
603
|
-
this.debugLog(
|
|
604
|
-
|
|
630
|
+
this.debugLog(
|
|
631
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No pushColorTemperatureChanges.` +
|
|
632
|
+
`ColorTemperature: ${this.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`,
|
|
633
|
+
);
|
|
605
634
|
}
|
|
606
635
|
}
|
|
607
636
|
|
|
@@ -609,9 +638,9 @@ export class CeilingLight {
|
|
|
609
638
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges`);
|
|
610
639
|
if (this.Brightness !== this.accessory.context.Brightness) {
|
|
611
640
|
const bodyChange = JSON.stringify({
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
641
|
+
command: 'setBrightness',
|
|
642
|
+
parameter: `${this.Brightness}`,
|
|
643
|
+
commandType: 'command',
|
|
615
644
|
});
|
|
616
645
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
617
646
|
try {
|
|
@@ -626,13 +655,17 @@ export class CeilingLight {
|
|
|
626
655
|
this.debugLog(`Headers: ${JSON.stringify(headers)}`);
|
|
627
656
|
} catch (e: any) {
|
|
628
657
|
this.apiError(e);
|
|
629
|
-
this.errorLog(
|
|
630
|
-
|
|
658
|
+
this.errorLog(
|
|
659
|
+
`${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with ${this.device.connectionType}` +
|
|
660
|
+
` Connection, Error Message: ${JSON.stringify(e.message)}`,
|
|
631
661
|
);
|
|
632
662
|
}
|
|
633
663
|
} else {
|
|
634
|
-
this.debugLog(
|
|
635
|
-
|
|
664
|
+
this.debugLog(
|
|
665
|
+
`${this.device.deviceType}: ${this.accessory.displayName} No pushBrightnessChanges.` +
|
|
666
|
+
`Brightness: ${this.Brightness}, ` +
|
|
667
|
+
`BrightnessCached: ${this.accessory.context.Brightness}`,
|
|
668
|
+
);
|
|
636
669
|
}
|
|
637
670
|
}
|
|
638
671
|
|
|
@@ -884,8 +917,10 @@ export class CeilingLight {
|
|
|
884
917
|
this.offlineOff();
|
|
885
918
|
break;
|
|
886
919
|
case 171:
|
|
887
|
-
this.errorLog(
|
|
888
|
-
|
|
920
|
+
this.errorLog(
|
|
921
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
|
|
922
|
+
`Hub: ${this.device.hubDeviceId}`,
|
|
923
|
+
);
|
|
889
924
|
this.offlineOff();
|
|
890
925
|
break;
|
|
891
926
|
case 190:
|
|
@@ -901,8 +936,10 @@ export class CeilingLight {
|
|
|
901
936
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
|
|
902
937
|
break;
|
|
903
938
|
default:
|
|
904
|
-
this.infoLog(
|
|
905
|
-
|
|
939
|
+
this.infoLog(
|
|
940
|
+
`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
|
|
941
|
+
`${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
|
|
942
|
+
);
|
|
906
943
|
}
|
|
907
944
|
}
|
|
908
945
|
|
|
@@ -923,14 +960,17 @@ export class CeilingLight {
|
|
|
923
960
|
|
|
924
961
|
FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
|
|
925
962
|
let FirmwareRevision: string;
|
|
926
|
-
this.debugLog(
|
|
927
|
-
+ ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}
|
|
963
|
+
this.debugLog(
|
|
964
|
+
`${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
|
|
965
|
+
);
|
|
928
966
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
|
|
929
967
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
|
|
930
|
-
if (
|
|
931
|
-
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
932
|
-
} else if (device.firmware) {
|
|
968
|
+
if (device.firmware) {
|
|
933
969
|
FirmwareRevision = device.firmware;
|
|
970
|
+
} else if (device.version) {
|
|
971
|
+
FirmwareRevision = JSON.stringify(device.version);
|
|
972
|
+
} else if (accessory.context.FirmwareRevision) {
|
|
973
|
+
FirmwareRevision = accessory.context.FirmwareRevision;
|
|
934
974
|
} else {
|
|
935
975
|
FirmwareRevision = this.platform.version;
|
|
936
976
|
}
|
|
@@ -1004,7 +1044,7 @@ export class CeilingLight {
|
|
|
1004
1044
|
config['maxRetry'] = device.maxRetry;
|
|
1005
1045
|
}
|
|
1006
1046
|
if (Object.entries(config).length !== 0) {
|
|
1007
|
-
this.
|
|
1047
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1008
1048
|
}
|
|
1009
1049
|
}
|
|
1010
1050
|
|