@switchbot/homebridge-switchbot 3.1.1-beta.2 → 3.1.1-beta.4
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/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +5 -5
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +5 -5
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +8 -11
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +8 -11
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -2
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +8 -7
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +5 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +4 -3
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +7 -9
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +4 -3
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +7 -9
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +5 -5
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +4 -3
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +4 -3
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +4 -3
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +5 -5
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +6 -8
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +1 -3
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -3
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +1 -3
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +1 -3
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +1 -3
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +1 -3
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +1 -3
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -3
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +1 -3
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +5 -10
- package/dist/platform.js.map +1 -1
- package/package.json +10 -3
- package/src/device/blindtilt.ts +5 -6
- package/src/device/bot.ts +5 -5
- package/src/device/ceilinglight.ts +8 -11
- package/src/device/colorbulb.ts +8 -11
- package/src/device/contact.ts +8 -7
- package/src/device/curtain.ts +5 -5
- package/src/device/hub.ts +4 -3
- package/src/device/humidifier.ts +7 -9
- package/src/device/iosensor.ts +4 -3
- package/src/device/lightstrip.ts +7 -9
- package/src/device/lock.ts +5 -5
- package/src/device/meter.ts +4 -3
- package/src/device/meterplus.ts +4 -3
- package/src/device/motion.ts +4 -3
- package/src/device/plug.ts +5 -5
- package/src/device/robotvacuumcleaner.ts +6 -8
- package/src/irdevice/airconditioner.ts +1 -3
- package/src/irdevice/airpurifier.ts +1 -3
- package/src/irdevice/camera.ts +1 -3
- package/src/irdevice/fan.ts +1 -3
- package/src/irdevice/light.ts +1 -3
- package/src/irdevice/other.ts +1 -3
- package/src/irdevice/tv.ts +1 -3
- package/src/irdevice/vacuumcleaner.ts +1 -3
- package/src/irdevice/waterheater.ts +1 -3
- package/src/platform.ts +5 -10
|
@@ -431,14 +431,12 @@ export class CeilingLight {
|
|
|
431
431
|
async openAPIRefreshStatus() {
|
|
432
432
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
433
433
|
try {
|
|
434
|
-
const { body, statusCode
|
|
434
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
435
435
|
headers: this.platform.generateHeaders(),
|
|
436
436
|
});
|
|
437
437
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
438
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
439
438
|
const deviceStatus: any = await body.json();
|
|
440
439
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
441
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
442
440
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
443
441
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
444
442
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -560,13 +558,12 @@ export class CeilingLight {
|
|
|
560
558
|
});
|
|
561
559
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
562
560
|
try {
|
|
563
|
-
const { body, statusCode
|
|
561
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
564
562
|
body: bodyChange,
|
|
565
563
|
method: 'POST',
|
|
566
564
|
headers: this.platform.generateHeaders(),
|
|
567
565
|
});
|
|
568
566
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
569
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
570
567
|
const deviceStatus: any = await body.json();
|
|
571
568
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
572
569
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -620,13 +617,12 @@ export class CeilingLight {
|
|
|
620
617
|
});
|
|
621
618
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
622
619
|
try {
|
|
623
|
-
const { body, statusCode
|
|
620
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
624
621
|
body: bodyChange,
|
|
625
622
|
method: 'POST',
|
|
626
623
|
headers: this.platform.generateHeaders(),
|
|
627
624
|
});
|
|
628
625
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
629
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
630
626
|
const deviceStatus: any = await body.json();
|
|
631
627
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
632
628
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -665,13 +661,12 @@ export class CeilingLight {
|
|
|
665
661
|
});
|
|
666
662
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
667
663
|
try {
|
|
668
|
-
const { body, statusCode
|
|
664
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
669
665
|
body: bodyChange,
|
|
670
666
|
method: 'POST',
|
|
671
667
|
headers: this.platform.generateHeaders(),
|
|
672
668
|
});
|
|
673
669
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
674
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
675
670
|
const deviceStatus: any = await body.json();
|
|
676
671
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
677
672
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -708,13 +703,12 @@ export class CeilingLight {
|
|
|
708
703
|
});
|
|
709
704
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
710
705
|
try {
|
|
711
|
-
const { body, statusCode
|
|
706
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
712
707
|
body: bodyChange,
|
|
713
708
|
method: 'POST',
|
|
714
709
|
headers: this.platform.generateHeaders(),
|
|
715
710
|
});
|
|
716
711
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
717
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
718
712
|
const deviceStatus: any = await body.json();
|
|
719
713
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
720
714
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -1101,6 +1095,9 @@ export class CeilingLight {
|
|
|
1101
1095
|
if (device.maxRetry !== undefined) {
|
|
1102
1096
|
config['maxRetry'] = device.maxRetry;
|
|
1103
1097
|
}
|
|
1098
|
+
if (device.webhook !== undefined) {
|
|
1099
|
+
config['webhook'] = device.webhook;
|
|
1100
|
+
}
|
|
1104
1101
|
if (Object.entries(config).length !== 0) {
|
|
1105
1102
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1106
1103
|
}
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -478,14 +478,12 @@ export class ColorBulb {
|
|
|
478
478
|
async openAPIRefreshStatus() {
|
|
479
479
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
480
480
|
try {
|
|
481
|
-
const { body, statusCode
|
|
481
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
482
482
|
headers: this.platform.generateHeaders(),
|
|
483
483
|
});
|
|
484
484
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
485
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
486
485
|
const deviceStatus: any = await body.json();
|
|
487
486
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
488
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
489
487
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
490
488
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
491
489
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -743,13 +741,12 @@ export class ColorBulb {
|
|
|
743
741
|
});
|
|
744
742
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
745
743
|
try {
|
|
746
|
-
const { body, statusCode
|
|
744
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
747
745
|
body: bodyChange,
|
|
748
746
|
method: 'POST',
|
|
749
747
|
headers: this.platform.generateHeaders(),
|
|
750
748
|
});
|
|
751
749
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
752
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
753
750
|
const deviceStatus: any = await body.json();
|
|
754
751
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
755
752
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -803,13 +800,12 @@ export class ColorBulb {
|
|
|
803
800
|
});
|
|
804
801
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
805
802
|
try {
|
|
806
|
-
const { body, statusCode
|
|
803
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
807
804
|
body: bodyChange,
|
|
808
805
|
method: 'POST',
|
|
809
806
|
headers: this.platform.generateHeaders(),
|
|
810
807
|
});
|
|
811
808
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
812
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
813
809
|
const deviceStatus: any = await body.json();
|
|
814
810
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
815
811
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -848,13 +844,12 @@ export class ColorBulb {
|
|
|
848
844
|
});
|
|
849
845
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
850
846
|
try {
|
|
851
|
-
const { body, statusCode
|
|
847
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
852
848
|
body: bodyChange,
|
|
853
849
|
method: 'POST',
|
|
854
850
|
headers: this.platform.generateHeaders(),
|
|
855
851
|
});
|
|
856
852
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
857
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
858
853
|
const deviceStatus: any = await body.json();
|
|
859
854
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
860
855
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -891,13 +886,12 @@ export class ColorBulb {
|
|
|
891
886
|
});
|
|
892
887
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
893
888
|
try {
|
|
894
|
-
const { body, statusCode
|
|
889
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
895
890
|
body: bodyChange,
|
|
896
891
|
method: 'POST',
|
|
897
892
|
headers: this.platform.generateHeaders(),
|
|
898
893
|
});
|
|
899
894
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
900
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
901
895
|
const deviceStatus: any = await body.json();
|
|
902
896
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
903
897
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -1289,6 +1283,9 @@ export class ColorBulb {
|
|
|
1289
1283
|
if (device.maxRetry !== undefined) {
|
|
1290
1284
|
config['maxRetry'] = device.maxRetry;
|
|
1291
1285
|
}
|
|
1286
|
+
if (device.webhook !== undefined) {
|
|
1287
|
+
config['webhook'] = device.webhook;
|
|
1288
|
+
}
|
|
1292
1289
|
if (Object.entries(config).length !== 0) {
|
|
1293
1290
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1294
1291
|
}
|
package/src/device/contact.ts
CHANGED
|
@@ -75,11 +75,11 @@ export class Contact {
|
|
|
75
75
|
this.BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
|
|
76
76
|
this.OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
|
|
77
77
|
// default placeholders
|
|
78
|
-
this.
|
|
78
|
+
this.deviceLogs(device);
|
|
79
79
|
this.scan(device);
|
|
80
80
|
this.refreshRate(device);
|
|
81
81
|
this.context();
|
|
82
|
-
this.
|
|
82
|
+
this.deviceConfig(device);
|
|
83
83
|
|
|
84
84
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
85
85
|
this.doContactUpdate = new Subject();
|
|
@@ -411,14 +411,12 @@ export class Contact {
|
|
|
411
411
|
async openAPIRefreshStatus(): Promise<void> {
|
|
412
412
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
413
413
|
try {
|
|
414
|
-
const { body, statusCode
|
|
414
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
415
415
|
headers: this.platform.generateHeaders(),
|
|
416
416
|
});
|
|
417
417
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
418
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
419
418
|
const deviceStatus: any = await body.json();
|
|
420
419
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
421
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
422
420
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
423
421
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
424
422
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -647,7 +645,7 @@ export class Contact {
|
|
|
647
645
|
}
|
|
648
646
|
}
|
|
649
647
|
|
|
650
|
-
async
|
|
648
|
+
async deviceConfig(device: device & devicesConfig): Promise<void> {
|
|
651
649
|
let config = {};
|
|
652
650
|
if (device.contact) {
|
|
653
651
|
config = device.contact;
|
|
@@ -667,12 +665,15 @@ export class Contact {
|
|
|
667
665
|
if (device.scanDuration !== undefined) {
|
|
668
666
|
config['scanDuration'] = device.scanDuration;
|
|
669
667
|
}
|
|
668
|
+
if (device.webhook !== undefined) {
|
|
669
|
+
config['webhook'] = device.webhook;
|
|
670
|
+
}
|
|
670
671
|
if (Object.entries(config).length !== 0) {
|
|
671
672
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
675
|
|
|
675
|
-
async
|
|
676
|
+
async deviceLogs(device: device & devicesConfig): Promise<void> {
|
|
676
677
|
if (this.platform.debugMode) {
|
|
677
678
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
678
679
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
package/src/device/curtain.ts
CHANGED
|
@@ -609,14 +609,12 @@ export class Curtain {
|
|
|
609
609
|
async openAPIRefreshStatus(): Promise<void> {
|
|
610
610
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
611
611
|
try {
|
|
612
|
-
const { body, statusCode
|
|
612
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
613
613
|
headers: this.platform.generateHeaders(),
|
|
614
614
|
});
|
|
615
615
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
616
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
617
616
|
const deviceStatus: any = await body.json();
|
|
618
617
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
619
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
620
618
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
621
619
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
622
620
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -773,13 +771,12 @@ export class Curtain {
|
|
|
773
771
|
});
|
|
774
772
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
775
773
|
try {
|
|
776
|
-
const { body, statusCode
|
|
774
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
777
775
|
body: bodyChange,
|
|
778
776
|
method: 'POST',
|
|
779
777
|
headers: this.platform.generateHeaders(),
|
|
780
778
|
});
|
|
781
779
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
782
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
783
780
|
const deviceStatus: any = await body.json();
|
|
784
781
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
785
782
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -1278,6 +1275,9 @@ export class Curtain {
|
|
|
1278
1275
|
if (device.maxRetry !== undefined) {
|
|
1279
1276
|
config['maxRetry'] = device.maxRetry;
|
|
1280
1277
|
}
|
|
1278
|
+
if (device.webhook !== undefined) {
|
|
1279
|
+
config['webhook'] = device.webhook;
|
|
1280
|
+
}
|
|
1281
1281
|
if (Object.entries(config).length !== 0) {
|
|
1282
1282
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1283
1283
|
}
|
package/src/device/hub.ts
CHANGED
|
@@ -428,14 +428,12 @@ export class Hub {
|
|
|
428
428
|
async openAPIRefreshStatus(): Promise<void> {
|
|
429
429
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
430
430
|
try {
|
|
431
|
-
const { body, statusCode
|
|
431
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
432
432
|
headers: this.platform.generateHeaders(),
|
|
433
433
|
});
|
|
434
434
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
435
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
436
435
|
const deviceStatus: any = await body.json();
|
|
437
436
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
438
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
439
437
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
440
438
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
441
439
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -721,6 +719,9 @@ export class Hub {
|
|
|
721
719
|
if (device.refreshRate !== undefined) {
|
|
722
720
|
config['refreshRate'] = device.refreshRate;
|
|
723
721
|
}
|
|
722
|
+
if (device.webhook !== undefined) {
|
|
723
|
+
config['webhook'] = device.webhook;
|
|
724
|
+
}
|
|
724
725
|
if (Object.entries(config).length !== 0) {
|
|
725
726
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
726
727
|
}
|
package/src/device/humidifier.ts
CHANGED
|
@@ -402,14 +402,12 @@ export class Humidifier {
|
|
|
402
402
|
async openAPIRefreshStatus(): Promise<void> {
|
|
403
403
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
404
404
|
try {
|
|
405
|
-
const { body, statusCode
|
|
405
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
406
406
|
headers: this.platform.generateHeaders(),
|
|
407
407
|
});
|
|
408
408
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
409
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
410
409
|
const deviceStatus: any = await body.json();
|
|
411
410
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
412
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
413
411
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
414
412
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
415
413
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -505,13 +503,12 @@ export class Humidifier {
|
|
|
505
503
|
});
|
|
506
504
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
507
505
|
try {
|
|
508
|
-
const { body, statusCode
|
|
506
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
509
507
|
body: bodyChange,
|
|
510
508
|
method: 'POST',
|
|
511
509
|
headers: this.platform.generateHeaders(),
|
|
512
510
|
});
|
|
513
511
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
514
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
515
512
|
const deviceStatus: any = await body.json();
|
|
516
513
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
517
514
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -557,13 +554,12 @@ export class Humidifier {
|
|
|
557
554
|
});
|
|
558
555
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
559
556
|
try {
|
|
560
|
-
const { body, statusCode
|
|
557
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
561
558
|
body: bodyChange,
|
|
562
559
|
method: 'POST',
|
|
563
560
|
headers: this.platform.generateHeaders(),
|
|
564
561
|
});
|
|
565
562
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
566
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
567
563
|
const deviceStatus: any = await body.json();
|
|
568
564
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
569
565
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -604,13 +600,12 @@ export class Humidifier {
|
|
|
604
600
|
});
|
|
605
601
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
606
602
|
try {
|
|
607
|
-
const { body, statusCode
|
|
603
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
608
604
|
body: bodyChange,
|
|
609
605
|
method: 'POST',
|
|
610
606
|
headers: this.platform.generateHeaders(),
|
|
611
607
|
});
|
|
612
608
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
613
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
614
609
|
const deviceStatus: any = await body.json();
|
|
615
610
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
616
611
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -979,6 +974,9 @@ export class Humidifier {
|
|
|
979
974
|
if (device.offline !== undefined) {
|
|
980
975
|
config['offline'] = device.offline;
|
|
981
976
|
}
|
|
977
|
+
if (device.webhook !== undefined) {
|
|
978
|
+
config['webhook'] = device.webhook;
|
|
979
|
+
}
|
|
982
980
|
if (Object.entries(config).length !== 0) {
|
|
983
981
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
984
982
|
}
|
package/src/device/iosensor.ts
CHANGED
|
@@ -381,14 +381,12 @@ export class IOSensor {
|
|
|
381
381
|
async openAPIRefreshStatus(): Promise<void> {
|
|
382
382
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
383
383
|
try {
|
|
384
|
-
const { body, statusCode
|
|
384
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
385
385
|
headers: this.platform.generateHeaders(),
|
|
386
386
|
});
|
|
387
387
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
388
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
389
388
|
const deviceStatus: any = await body.json();
|
|
390
389
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
391
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
392
390
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
393
391
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
394
392
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -703,6 +701,9 @@ export class IOSensor {
|
|
|
703
701
|
if (device.scanDuration !== undefined) {
|
|
704
702
|
config['scanDuration'] = device.scanDuration;
|
|
705
703
|
}
|
|
704
|
+
if (device.webhook !== undefined) {
|
|
705
|
+
config['webhook'] = device.webhook;
|
|
706
|
+
}
|
|
706
707
|
if (Object.entries(config).length !== 0) {
|
|
707
708
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
708
709
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -417,14 +417,12 @@ export class StripLight {
|
|
|
417
417
|
async openAPIRefreshStatus(): Promise<void> {
|
|
418
418
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
419
419
|
try {
|
|
420
|
-
const { body, statusCode
|
|
420
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
421
421
|
headers: this.platform.generateHeaders(),
|
|
422
422
|
});
|
|
423
423
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
424
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
425
424
|
const deviceStatus: any = await body.json();
|
|
426
425
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
427
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
428
426
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
429
427
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
430
428
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -637,13 +635,12 @@ export class StripLight {
|
|
|
637
635
|
});
|
|
638
636
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
639
637
|
try {
|
|
640
|
-
const { body, statusCode
|
|
638
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
641
639
|
body: bodyChange,
|
|
642
640
|
method: 'POST',
|
|
643
641
|
headers: this.platform.generateHeaders(),
|
|
644
642
|
});
|
|
645
643
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
646
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
647
644
|
const deviceStatus: any = await body.json();
|
|
648
645
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
649
646
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -694,13 +691,12 @@ export class StripLight {
|
|
|
694
691
|
});
|
|
695
692
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
696
693
|
try {
|
|
697
|
-
const { body, statusCode
|
|
694
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
698
695
|
body: bodyChange,
|
|
699
696
|
method: 'POST',
|
|
700
697
|
headers: this.platform.generateHeaders(),
|
|
701
698
|
});
|
|
702
699
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
703
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
704
700
|
const deviceStatus: any = await body.json();
|
|
705
701
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
706
702
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -737,13 +733,12 @@ export class StripLight {
|
|
|
737
733
|
});
|
|
738
734
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
739
735
|
try {
|
|
740
|
-
const { body, statusCode
|
|
736
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
741
737
|
body: bodyChange,
|
|
742
738
|
method: 'POST',
|
|
743
739
|
headers: this.platform.generateHeaders(),
|
|
744
740
|
});
|
|
745
741
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
746
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
747
742
|
const deviceStatus: any = await body.json();
|
|
748
743
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
749
744
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -1134,6 +1129,9 @@ export class StripLight {
|
|
|
1134
1129
|
if (device.maxRetry !== undefined) {
|
|
1135
1130
|
config['maxRetry'] = device.maxRetry;
|
|
1136
1131
|
}
|
|
1132
|
+
if (device.webhook !== undefined) {
|
|
1133
|
+
config['webhook'] = device.webhook;
|
|
1134
|
+
}
|
|
1137
1135
|
if (Object.entries(config).length !== 0) {
|
|
1138
1136
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1139
1137
|
}
|
package/src/device/lock.ts
CHANGED
|
@@ -440,14 +440,12 @@ export class Lock {
|
|
|
440
440
|
async openAPIRefreshStatus(): Promise<void> {
|
|
441
441
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
442
442
|
try {
|
|
443
|
-
const { body, statusCode
|
|
443
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
444
444
|
headers: this.platform.generateHeaders(),
|
|
445
445
|
});
|
|
446
446
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
447
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
448
447
|
const deviceStatus: any = await body.json();
|
|
449
448
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
450
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
451
449
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
452
450
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
453
451
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -557,13 +555,12 @@ export class Lock {
|
|
|
557
555
|
});
|
|
558
556
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
559
557
|
try {
|
|
560
|
-
const { body, statusCode
|
|
558
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
561
559
|
body: bodyChange,
|
|
562
560
|
method: 'POST',
|
|
563
561
|
headers: this.platform.generateHeaders(),
|
|
564
562
|
});
|
|
565
563
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
566
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
567
564
|
const deviceStatus: any = await body.json();
|
|
568
565
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
569
566
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -801,6 +798,9 @@ export class Lock {
|
|
|
801
798
|
if (device.scanDuration !== undefined) {
|
|
802
799
|
config['scanDuration'] = device.scanDuration;
|
|
803
800
|
}
|
|
801
|
+
if (device.webhook !== undefined) {
|
|
802
|
+
config['webhook'] = device.webhook;
|
|
803
|
+
}
|
|
804
804
|
if (Object.entries(config).length !== 0) {
|
|
805
805
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
806
806
|
}
|
package/src/device/meter.ts
CHANGED
|
@@ -370,14 +370,12 @@ export class Meter {
|
|
|
370
370
|
async openAPIRefreshStatus(): Promise<void> {
|
|
371
371
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
372
372
|
try {
|
|
373
|
-
const { body, statusCode
|
|
373
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
374
374
|
headers: this.platform.generateHeaders(),
|
|
375
375
|
});
|
|
376
376
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
377
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
378
377
|
const deviceStatus: any = await body.json();
|
|
379
378
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
380
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
381
379
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
382
380
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
383
381
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -696,6 +694,9 @@ export class Meter {
|
|
|
696
694
|
if (device.scanDuration !== undefined) {
|
|
697
695
|
config['scanDuration'] = device.scanDuration;
|
|
698
696
|
}
|
|
697
|
+
if (device.webhook !== undefined) {
|
|
698
|
+
config['webhook'] = device.webhook;
|
|
699
|
+
}
|
|
699
700
|
if (Object.entries(config).length !== 0) {
|
|
700
701
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
701
702
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -372,14 +372,12 @@ export class MeterPlus {
|
|
|
372
372
|
async openAPIRefreshStatus(): Promise<void> {
|
|
373
373
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
374
374
|
try {
|
|
375
|
-
const { body, statusCode
|
|
375
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
376
376
|
headers: this.platform.generateHeaders(),
|
|
377
377
|
});
|
|
378
378
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
379
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
380
379
|
const deviceStatus: any = await body.json();
|
|
381
380
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
382
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
383
381
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
384
382
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
385
383
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -711,6 +709,9 @@ export class MeterPlus {
|
|
|
711
709
|
if (device.scanDuration !== undefined) {
|
|
712
710
|
config['scanDuration'] = device.scanDuration;
|
|
713
711
|
}
|
|
712
|
+
if (device.webhook !== undefined) {
|
|
713
|
+
config['webhook'] = device.webhook;
|
|
714
|
+
}
|
|
714
715
|
if (Object.entries(config).length !== 0) {
|
|
715
716
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
716
717
|
}
|
package/src/device/motion.ts
CHANGED
|
@@ -365,14 +365,12 @@ export class Motion {
|
|
|
365
365
|
async openAPIRefreshStatus(): Promise<void> {
|
|
366
366
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
367
367
|
try {
|
|
368
|
-
const { body, statusCode
|
|
368
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
369
369
|
headers: this.platform.generateHeaders(),
|
|
370
370
|
});
|
|
371
371
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
372
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
373
372
|
const deviceStatus: any = await body.json();
|
|
374
373
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
375
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
376
374
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
377
375
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
378
376
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -622,6 +620,9 @@ export class Motion {
|
|
|
622
620
|
if (device.offline !== undefined) {
|
|
623
621
|
config['offline'] = device.offline;
|
|
624
622
|
}
|
|
623
|
+
if (device.webhook !== undefined) {
|
|
624
|
+
config['webhook'] = device.webhook;
|
|
625
|
+
}
|
|
625
626
|
if (Object.entries(config).length !== 0) {
|
|
626
627
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
627
628
|
}
|
package/src/device/plug.ts
CHANGED
|
@@ -273,14 +273,12 @@ export class Plug {
|
|
|
273
273
|
async openAPIRefreshStatus() {
|
|
274
274
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
275
275
|
try {
|
|
276
|
-
const { body, statusCode
|
|
276
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
277
277
|
headers: this.platform.generateHeaders(),
|
|
278
278
|
});
|
|
279
279
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
280
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
281
280
|
const deviceStatus: any = await body.json();
|
|
282
281
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
283
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
284
282
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
285
283
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
286
284
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -397,13 +395,12 @@ export class Plug {
|
|
|
397
395
|
});
|
|
398
396
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
399
397
|
try {
|
|
400
|
-
const { body, statusCode
|
|
398
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
401
399
|
body: bodyChange,
|
|
402
400
|
method: 'POST',
|
|
403
401
|
headers: this.platform.generateHeaders(),
|
|
404
402
|
});
|
|
405
403
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
406
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
407
404
|
const deviceStatus: any = await body.json();
|
|
408
405
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
409
406
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -651,6 +648,9 @@ export class Plug {
|
|
|
651
648
|
if (device.maxRetry !== undefined) {
|
|
652
649
|
config['maxRetry'] = device.maxRetry;
|
|
653
650
|
}
|
|
651
|
+
if (device.webhook !== undefined) {
|
|
652
|
+
config['webhook'] = device.webhook;
|
|
653
|
+
}
|
|
654
654
|
if (Object.entries(config).length !== 0) {
|
|
655
655
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
656
656
|
}
|