@switchbot/homebridge-switchbot 3.1.1-beta.1 → 3.1.1-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/.github/workflows/labeler.yml +2 -2
- package/CHANGELOG.md +21 -14
- package/README.md +2 -2
- package/config.schema.json +1 -1
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +7 -9
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +19 -21
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +9 -17
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +9 -17
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +3 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +14 -14
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +31 -45
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +5 -5
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +8 -14
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +6 -6
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +8 -14
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +6 -8
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +6 -6
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +6 -6
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +5 -5
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +6 -8
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +7 -12
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +1 -4
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +1 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +1 -4
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +2 -5
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +1 -4
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +13 -16
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +1 -4
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +1 -4
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +1 -4
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +2 -2
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +21 -26
- package/dist/platform.js.map +1 -1
- package/package.json +12 -7
- package/src/device/blindtilt.ts +7 -10
- package/src/device/bot.ts +19 -21
- package/src/device/ceilinglight.ts +9 -17
- package/src/device/colorbulb.ts +9 -17
- package/src/device/contact.ts +14 -14
- package/src/device/curtain.ts +35 -48
- package/src/device/hub.ts +5 -5
- package/src/device/humidifier.ts +8 -14
- package/src/device/iosensor.ts +6 -6
- package/src/device/lightstrip.ts +8 -14
- package/src/device/lock.ts +6 -8
- package/src/device/meter.ts +6 -6
- package/src/device/meterplus.ts +6 -6
- package/src/device/motion.ts +5 -5
- package/src/device/plug.ts +6 -8
- package/src/device/robotvacuumcleaner.ts +7 -12
- package/src/irdevice/airconditioner.ts +1 -4
- package/src/irdevice/airpurifier.ts +1 -4
- package/src/irdevice/camera.ts +1 -4
- package/src/irdevice/fan.ts +2 -5
- package/src/irdevice/light.ts +1 -4
- package/src/irdevice/other.ts +13 -16
- package/src/irdevice/tv.ts +1 -4
- package/src/irdevice/vacuumcleaner.ts +1 -4
- package/src/irdevice/waterheater.ts +1 -4
- package/src/platform.ts +22 -27
- package/src/settings.ts +1 -1
package/src/device/hub.ts
CHANGED
|
@@ -428,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
435
434
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
436
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
437
435
|
const deviceStatus: any = await body.json();
|
|
438
436
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
439
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
440
437
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
441
438
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
442
439
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -550,7 +547,7 @@ export class Hub {
|
|
|
550
547
|
}
|
|
551
548
|
|
|
552
549
|
/*
|
|
553
|
-
* Setup MQTT hadler if URL is
|
|
550
|
+
* Setup MQTT hadler if URL is specified.
|
|
554
551
|
*/
|
|
555
552
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
556
553
|
if (device.mqttURL) {
|
|
@@ -722,6 +719,9 @@ export class Hub {
|
|
|
722
719
|
if (device.refreshRate !== undefined) {
|
|
723
720
|
config['refreshRate'] = device.refreshRate;
|
|
724
721
|
}
|
|
722
|
+
if (device.webhook !== undefined) {
|
|
723
|
+
config['webhook'] = device.webhook;
|
|
724
|
+
}
|
|
725
725
|
if (Object.entries(config).length !== 0) {
|
|
726
726
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
727
727
|
}
|
package/src/device/humidifier.ts
CHANGED
|
@@ -355,7 +355,7 @@ export class Humidifier {
|
|
|
355
355
|
id: this.device.bleMac,
|
|
356
356
|
})
|
|
357
357
|
.then(async () => {
|
|
358
|
-
// Set an event
|
|
358
|
+
// Set an event handler
|
|
359
359
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
360
360
|
this.debugLog(
|
|
361
361
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -402,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
409
408
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
410
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
411
409
|
const deviceStatus: any = await body.json();
|
|
412
410
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
413
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
414
411
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
415
412
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
416
413
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -506,14 +503,12 @@ export class Humidifier {
|
|
|
506
503
|
});
|
|
507
504
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
508
505
|
try {
|
|
509
|
-
const { body, statusCode
|
|
506
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
510
507
|
body: bodyChange,
|
|
511
508
|
method: 'POST',
|
|
512
509
|
headers: this.platform.generateHeaders(),
|
|
513
510
|
});
|
|
514
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
515
511
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
516
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
517
512
|
const deviceStatus: any = await body.json();
|
|
518
513
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
519
514
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -559,14 +554,12 @@ export class Humidifier {
|
|
|
559
554
|
});
|
|
560
555
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
561
556
|
try {
|
|
562
|
-
const { body, statusCode
|
|
557
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
563
558
|
body: bodyChange,
|
|
564
559
|
method: 'POST',
|
|
565
560
|
headers: this.platform.generateHeaders(),
|
|
566
561
|
});
|
|
567
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
568
562
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
569
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
570
563
|
const deviceStatus: any = await body.json();
|
|
571
564
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
572
565
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -607,14 +600,12 @@ export class Humidifier {
|
|
|
607
600
|
});
|
|
608
601
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
609
602
|
try {
|
|
610
|
-
const { body, statusCode
|
|
603
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
611
604
|
body: bodyChange,
|
|
612
605
|
method: 'POST',
|
|
613
606
|
headers: this.platform.generateHeaders(),
|
|
614
607
|
});
|
|
615
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
616
608
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
617
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
618
609
|
const deviceStatus: any = await body.json();
|
|
619
610
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
620
611
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -983,6 +974,9 @@ export class Humidifier {
|
|
|
983
974
|
if (device.offline !== undefined) {
|
|
984
975
|
config['offline'] = device.offline;
|
|
985
976
|
}
|
|
977
|
+
if (device.webhook !== undefined) {
|
|
978
|
+
config['webhook'] = device.webhook;
|
|
979
|
+
}
|
|
986
980
|
if (Object.entries(config).length !== 0) {
|
|
987
981
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
988
982
|
}
|
package/src/device/iosensor.ts
CHANGED
|
@@ -328,7 +328,7 @@ export class IOSensor {
|
|
|
328
328
|
id: this.device.bleMac,
|
|
329
329
|
})
|
|
330
330
|
.then(async () => {
|
|
331
|
-
// Set an event
|
|
331
|
+
// Set an event handler
|
|
332
332
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
333
333
|
this.debugLog(
|
|
334
334
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -381,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
388
387
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
389
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
390
388
|
const deviceStatus: any = await body.json();
|
|
391
389
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
392
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
393
390
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
394
391
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
395
392
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -498,7 +495,7 @@ export class IOSensor {
|
|
|
498
495
|
}
|
|
499
496
|
|
|
500
497
|
/*
|
|
501
|
-
* Setup MQTT hadler if URL is
|
|
498
|
+
* Setup MQTT hadler if URL is specified.
|
|
502
499
|
*/
|
|
503
500
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
504
501
|
if (device.mqttURL) {
|
|
@@ -704,6 +701,9 @@ export class IOSensor {
|
|
|
704
701
|
if (device.scanDuration !== undefined) {
|
|
705
702
|
config['scanDuration'] = device.scanDuration;
|
|
706
703
|
}
|
|
704
|
+
if (device.webhook !== undefined) {
|
|
705
|
+
config['webhook'] = device.webhook;
|
|
706
|
+
}
|
|
707
707
|
if (Object.entries(config).length !== 0) {
|
|
708
708
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
709
709
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -371,7 +371,7 @@ export class StripLight {
|
|
|
371
371
|
id: this.device.bleMac,
|
|
372
372
|
})
|
|
373
373
|
.then(async () => {
|
|
374
|
-
// Set an event
|
|
374
|
+
// Set an event handler
|
|
375
375
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
376
376
|
this.debugLog(
|
|
377
377
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -417,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
424
423
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
425
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
426
424
|
const deviceStatus: any = await body.json();
|
|
427
425
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
428
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
429
426
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
430
427
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
431
428
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -638,14 +635,12 @@ export class StripLight {
|
|
|
638
635
|
});
|
|
639
636
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
640
637
|
try {
|
|
641
|
-
const { body, statusCode
|
|
638
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
642
639
|
body: bodyChange,
|
|
643
640
|
method: 'POST',
|
|
644
641
|
headers: this.platform.generateHeaders(),
|
|
645
642
|
});
|
|
646
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
647
643
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
648
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
649
644
|
const deviceStatus: any = await body.json();
|
|
650
645
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
651
646
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -696,14 +691,12 @@ export class StripLight {
|
|
|
696
691
|
});
|
|
697
692
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
698
693
|
try {
|
|
699
|
-
const { body, statusCode
|
|
694
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
700
695
|
body: bodyChange,
|
|
701
696
|
method: 'POST',
|
|
702
697
|
headers: this.platform.generateHeaders(),
|
|
703
698
|
});
|
|
704
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
705
699
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
706
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
707
700
|
const deviceStatus: any = await body.json();
|
|
708
701
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
709
702
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -740,14 +733,12 @@ export class StripLight {
|
|
|
740
733
|
});
|
|
741
734
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
742
735
|
try {
|
|
743
|
-
const { body, statusCode
|
|
736
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
744
737
|
body: bodyChange,
|
|
745
738
|
method: 'POST',
|
|
746
739
|
headers: this.platform.generateHeaders(),
|
|
747
740
|
});
|
|
748
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
749
741
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
750
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
751
742
|
const deviceStatus: any = await body.json();
|
|
752
743
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
753
744
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -1138,6 +1129,9 @@ export class StripLight {
|
|
|
1138
1129
|
if (device.maxRetry !== undefined) {
|
|
1139
1130
|
config['maxRetry'] = device.maxRetry;
|
|
1140
1131
|
}
|
|
1132
|
+
if (device.webhook !== undefined) {
|
|
1133
|
+
config['webhook'] = device.webhook;
|
|
1134
|
+
}
|
|
1141
1135
|
if (Object.entries(config).length !== 0) {
|
|
1142
1136
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
1143
1137
|
}
|
package/src/device/lock.ts
CHANGED
|
@@ -391,7 +391,7 @@ export class Lock {
|
|
|
391
391
|
id: this.device.bleMac,
|
|
392
392
|
})
|
|
393
393
|
.then(async () => {
|
|
394
|
-
// Set an event
|
|
394
|
+
// Set an event handler
|
|
395
395
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
396
396
|
this.debugLog(
|
|
397
397
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -440,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
447
446
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
448
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
449
447
|
const deviceStatus: any = await body.json();
|
|
450
448
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
451
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
452
449
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
453
450
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
454
451
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -558,14 +555,12 @@ export class Lock {
|
|
|
558
555
|
});
|
|
559
556
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
560
557
|
try {
|
|
561
|
-
const { body, statusCode
|
|
558
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
562
559
|
body: bodyChange,
|
|
563
560
|
method: 'POST',
|
|
564
561
|
headers: this.platform.generateHeaders(),
|
|
565
562
|
});
|
|
566
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
567
563
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
568
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
569
564
|
const deviceStatus: any = await body.json();
|
|
570
565
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
571
566
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -803,6 +798,9 @@ export class Lock {
|
|
|
803
798
|
if (device.scanDuration !== undefined) {
|
|
804
799
|
config['scanDuration'] = device.scanDuration;
|
|
805
800
|
}
|
|
801
|
+
if (device.webhook !== undefined) {
|
|
802
|
+
config['webhook'] = device.webhook;
|
|
803
|
+
}
|
|
806
804
|
if (Object.entries(config).length !== 0) {
|
|
807
805
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
808
806
|
}
|
package/src/device/meter.ts
CHANGED
|
@@ -317,7 +317,7 @@ export class Meter {
|
|
|
317
317
|
id: this.device.bleMac,
|
|
318
318
|
})
|
|
319
319
|
.then(async () => {
|
|
320
|
-
// Set an event
|
|
320
|
+
// Set an event handler
|
|
321
321
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
322
322
|
this.debugLog(
|
|
323
323
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -370,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
377
376
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
378
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
379
377
|
const deviceStatus: any = await body.json();
|
|
380
378
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
381
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
382
379
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
383
380
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
384
381
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -491,7 +488,7 @@ export class Meter {
|
|
|
491
488
|
}
|
|
492
489
|
|
|
493
490
|
/*
|
|
494
|
-
* Setup MQTT hadler if URL is
|
|
491
|
+
* Setup MQTT hadler if URL is specified.
|
|
495
492
|
*/
|
|
496
493
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
497
494
|
if (device.mqttURL) {
|
|
@@ -697,6 +694,9 @@ export class Meter {
|
|
|
697
694
|
if (device.scanDuration !== undefined) {
|
|
698
695
|
config['scanDuration'] = device.scanDuration;
|
|
699
696
|
}
|
|
697
|
+
if (device.webhook !== undefined) {
|
|
698
|
+
config['webhook'] = device.webhook;
|
|
699
|
+
}
|
|
700
700
|
if (Object.entries(config).length !== 0) {
|
|
701
701
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
702
702
|
}
|
package/src/device/meterplus.ts
CHANGED
|
@@ -319,7 +319,7 @@ export class MeterPlus {
|
|
|
319
319
|
id: this.device.bleMac,
|
|
320
320
|
})
|
|
321
321
|
.then(async () => {
|
|
322
|
-
// Set an event
|
|
322
|
+
// Set an event handler
|
|
323
323
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
324
324
|
this.debugLog(
|
|
325
325
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -372,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
379
378
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
380
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
381
379
|
const deviceStatus: any = await body.json();
|
|
382
380
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
383
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
384
381
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
385
382
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
386
383
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -496,7 +493,7 @@ export class MeterPlus {
|
|
|
496
493
|
}
|
|
497
494
|
|
|
498
495
|
/*
|
|
499
|
-
* Setup MQTT hadler if URL is
|
|
496
|
+
* Setup MQTT hadler if URL is specified.
|
|
500
497
|
*/
|
|
501
498
|
async setupMqtt(device: device & devicesConfig): Promise<void> {
|
|
502
499
|
if (device.mqttURL) {
|
|
@@ -712,6 +709,9 @@ export class MeterPlus {
|
|
|
712
709
|
if (device.scanDuration !== undefined) {
|
|
713
710
|
config['scanDuration'] = device.scanDuration;
|
|
714
711
|
}
|
|
712
|
+
if (device.webhook !== undefined) {
|
|
713
|
+
config['webhook'] = device.webhook;
|
|
714
|
+
}
|
|
715
715
|
if (Object.entries(config).length !== 0) {
|
|
716
716
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
717
717
|
}
|
package/src/device/motion.ts
CHANGED
|
@@ -306,7 +306,7 @@ export class Motion {
|
|
|
306
306
|
return await this.retry({
|
|
307
307
|
max: this.maxRetry(),
|
|
308
308
|
fn: async () => {
|
|
309
|
-
// Set an event
|
|
309
|
+
// Set an event handler
|
|
310
310
|
this.scanning = true;
|
|
311
311
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
312
312
|
this.debugLog(
|
|
@@ -365,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
372
371
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
373
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
374
372
|
const deviceStatus: any = await body.json();
|
|
375
373
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
376
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
377
374
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
378
375
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
379
376
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -623,6 +620,9 @@ export class Motion {
|
|
|
623
620
|
if (device.offline !== undefined) {
|
|
624
621
|
config['offline'] = device.offline;
|
|
625
622
|
}
|
|
623
|
+
if (device.webhook !== undefined) {
|
|
624
|
+
config['webhook'] = device.webhook;
|
|
625
|
+
}
|
|
626
626
|
if (Object.entries(config).length !== 0) {
|
|
627
627
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
628
628
|
}
|
package/src/device/plug.ts
CHANGED
|
@@ -227,7 +227,7 @@ export class Plug {
|
|
|
227
227
|
id: this.device.bleMac,
|
|
228
228
|
})
|
|
229
229
|
.then(async () => {
|
|
230
|
-
// Set an event
|
|
230
|
+
// Set an event handler
|
|
231
231
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
232
232
|
this.debugLog(
|
|
233
233
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -273,15 +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
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
280
279
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
281
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
282
280
|
const deviceStatus: any = await body.json();
|
|
283
281
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
284
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
285
282
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
286
283
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
287
284
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -398,14 +395,12 @@ export class Plug {
|
|
|
398
395
|
});
|
|
399
396
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
400
397
|
try {
|
|
401
|
-
const { body, statusCode
|
|
398
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
402
399
|
body: bodyChange,
|
|
403
400
|
method: 'POST',
|
|
404
401
|
headers: this.platform.generateHeaders(),
|
|
405
402
|
});
|
|
406
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
407
403
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
408
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
409
404
|
const deviceStatus: any = await body.json();
|
|
410
405
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
411
406
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -653,6 +648,9 @@ export class Plug {
|
|
|
653
648
|
if (device.maxRetry !== undefined) {
|
|
654
649
|
config['maxRetry'] = device.maxRetry;
|
|
655
650
|
}
|
|
651
|
+
if (device.webhook !== undefined) {
|
|
652
|
+
config['webhook'] = device.webhook;
|
|
653
|
+
}
|
|
656
654
|
if (Object.entries(config).length !== 0) {
|
|
657
655
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
658
656
|
}
|
|
@@ -274,7 +274,7 @@ export class RobotVacuumCleaner {
|
|
|
274
274
|
id: this.device.bleMac,
|
|
275
275
|
})
|
|
276
276
|
.then(async () => {
|
|
277
|
-
// Set an event
|
|
277
|
+
// Set an event handler
|
|
278
278
|
switchbot.onadvertisement = async (ad: ad) => {
|
|
279
279
|
this.debugLog(
|
|
280
280
|
`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
|
|
@@ -320,15 +320,12 @@ export class RobotVacuumCleaner {
|
|
|
320
320
|
async openAPIRefreshStatus() {
|
|
321
321
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIRefreshStatus`);
|
|
322
322
|
try {
|
|
323
|
-
const { body, statusCode
|
|
323
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
324
324
|
headers: this.platform.generateHeaders(),
|
|
325
325
|
});
|
|
326
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
327
326
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
328
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
329
327
|
const deviceStatus: any = await body.json();
|
|
330
328
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
331
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
332
329
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
333
330
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
334
331
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -446,14 +443,12 @@ export class RobotVacuumCleaner {
|
|
|
446
443
|
});
|
|
447
444
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
448
445
|
try {
|
|
449
|
-
const { body, statusCode
|
|
446
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
450
447
|
body: bodyChange,
|
|
451
448
|
method: 'POST',
|
|
452
449
|
headers: this.platform.generateHeaders(),
|
|
453
450
|
});
|
|
454
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
455
451
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
456
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
457
452
|
const deviceStatus: any = await body.json();
|
|
458
453
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
459
454
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
@@ -486,16 +481,13 @@ export class RobotVacuumCleaner {
|
|
|
486
481
|
const body = await this.brightnessCommands();
|
|
487
482
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${body},`);
|
|
488
483
|
try {
|
|
489
|
-
const { body, statusCode
|
|
484
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
490
485
|
method: 'POST',
|
|
491
486
|
headers: this.platform.generateHeaders(),
|
|
492
487
|
});
|
|
493
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
494
488
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
495
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
496
489
|
const deviceStatus: any = await body.json();
|
|
497
490
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
498
|
-
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
499
491
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
500
492
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
501
493
|
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
@@ -822,6 +814,9 @@ export class RobotVacuumCleaner {
|
|
|
822
814
|
if (device.maxRetry !== undefined) {
|
|
823
815
|
config['maxRetry'] = device.maxRetry;
|
|
824
816
|
}
|
|
817
|
+
if (device.webhook !== undefined) {
|
|
818
|
+
config['webhook'] = device.webhook;
|
|
819
|
+
}
|
|
825
820
|
if (Object.entries(config).length !== 0) {
|
|
826
821
|
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
|
|
827
822
|
}
|
|
@@ -259,17 +259,14 @@ export class AirConditioner {
|
|
|
259
259
|
if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
|
|
260
260
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
261
261
|
try {
|
|
262
|
-
const { body, statusCode
|
|
262
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
263
263
|
body: bodyChange,
|
|
264
264
|
method: 'POST',
|
|
265
265
|
headers: this.platform.generateHeaders(),
|
|
266
266
|
});
|
|
267
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
268
267
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
269
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
270
268
|
const deviceStatus: any = await body.json();
|
|
271
269
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
272
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
273
270
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
274
271
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
275
272
|
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
|
@@ -215,17 +215,14 @@ export class AirPurifier {
|
|
|
215
215
|
if (this.device.connectionType === 'OpenAPI') {
|
|
216
216
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
217
217
|
try {
|
|
218
|
-
const { body, statusCode
|
|
218
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
219
219
|
body: bodyChange,
|
|
220
220
|
method: 'POST',
|
|
221
221
|
headers: this.platform.generateHeaders(),
|
|
222
222
|
});
|
|
223
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
224
223
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
225
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
226
224
|
const deviceStatus: any = await body.json();
|
|
227
225
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
228
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
229
226
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
230
227
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
231
228
|
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|
package/src/irdevice/camera.ts
CHANGED
|
@@ -120,17 +120,14 @@ export class Camera {
|
|
|
120
120
|
if (this.device.connectionType === 'OpenAPI') {
|
|
121
121
|
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
|
|
122
122
|
try {
|
|
123
|
-
const { body, statusCode
|
|
123
|
+
const { body, statusCode } = await request(`${Devices}/${this.device.deviceId}/commands`, {
|
|
124
124
|
body: bodyChange,
|
|
125
125
|
method: 'POST',
|
|
126
126
|
headers: this.platform.generateHeaders(),
|
|
127
127
|
});
|
|
128
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
129
128
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
130
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
131
129
|
const deviceStatus: any = await body.json();
|
|
132
130
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
133
|
-
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
134
131
|
this.debugWarnLog(`${this.device.remoteType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
135
132
|
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
136
133
|
this.debugErrorLog(`${this.device.remoteType}: ${this.accessory.displayName} `
|