@switchbot/homebridge-switchbot 2.8.1-beta.2 → 2.8.1-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/config.schema.json +3 -3
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +37 -23
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +26 -10
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +78 -29
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +78 -29
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +22 -19
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +36 -20
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +3 -3
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +205 -172
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +66 -28
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +21 -11
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +63 -25
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +35 -19
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -2
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +41 -31
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +23 -13
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +21 -16
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +32 -16
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +48 -21
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +15 -9
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +15 -9
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +15 -9
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +15 -9
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +16 -10
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +15 -4
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +15 -9
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +15 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +15 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +48 -20
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +35 -25
- package/src/device/bot.ts +25 -10
- package/src/device/ceilinglight.ts +73 -30
- package/src/device/colorbulb.ts +73 -30
- package/src/device/contact.ts +21 -20
- package/src/device/curtain.ts +34 -21
- package/src/device/hub.ts +211 -188
- package/src/device/humidifier.ts +62 -29
- package/src/device/iosensor.ts +20 -11
- package/src/device/lightstrip.ts +59 -26
- package/src/device/lock.ts +33 -20
- package/src/device/meter.ts +42 -34
- package/src/device/meterplus.ts +22 -13
- package/src/device/motion.ts +20 -17
- package/src/device/plug.ts +30 -17
- package/src/device/robotvacuumcleaner.ts +45 -22
- package/src/irdevice/airconditioner.ts +14 -10
- package/src/irdevice/airpurifier.ts +14 -10
- package/src/irdevice/camera.ts +14 -10
- package/src/irdevice/fan.ts +14 -10
- package/src/irdevice/light.ts +15 -11
- package/src/irdevice/other.ts +14 -4
- package/src/irdevice/tv.ts +14 -10
- package/src/irdevice/vacuumcleaner.ts +14 -10
- package/src/irdevice/waterheater.ts +14 -10
- package/src/platform.ts +50 -26
|
@@ -104,12 +104,6 @@ export class CeilingLight {
|
|
|
104
104
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
108
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
109
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
110
|
-
|
|
111
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
112
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
113
107
|
this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
114
108
|
if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
115
109
|
this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -402,18 +396,27 @@ export class CeilingLight {
|
|
|
402
396
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
403
397
|
headers: this.platform.generateHeaders(),
|
|
404
398
|
});
|
|
399
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
400
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
401
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
405
402
|
const deviceStatus: any = await body.json();
|
|
406
|
-
this.
|
|
407
|
-
this.
|
|
408
|
-
this.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
403
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
404
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
405
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
406
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
407
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
408
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
409
|
+
this.OpenAPI_On = deviceStatus.body.power;
|
|
410
|
+
this.OpenAPI_RGB = deviceStatus.body.color;
|
|
411
|
+
this.OpenAPI_Brightness = deviceStatus.body.brightness;
|
|
412
|
+
this.OpenAPI_ColorTemperature = deviceStatus.body.colorTemperature;
|
|
413
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
414
|
+
this.openAPIparseStatus();
|
|
415
|
+
this.updateHomeKitCharacteristics();
|
|
416
|
+
} else {
|
|
417
|
+
this.statusCode(statusCode);
|
|
418
|
+
this.statusCode(deviceStatus.statusCode);
|
|
419
|
+
}
|
|
417
420
|
} catch (e: any) {
|
|
418
421
|
this.apiError(e);
|
|
419
422
|
this.errorLog(
|
|
@@ -525,10 +528,20 @@ export class CeilingLight {
|
|
|
525
528
|
method: 'POST',
|
|
526
529
|
headers: this.platform.generateHeaders(),
|
|
527
530
|
});
|
|
531
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
532
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
533
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
528
534
|
const deviceStatus: any = await body.json();
|
|
529
|
-
this.
|
|
530
|
-
this.
|
|
531
|
-
this.
|
|
535
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
536
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
537
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
538
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
539
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
540
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
541
|
+
} else {
|
|
542
|
+
this.statusCode(statusCode);
|
|
543
|
+
this.statusCode(deviceStatus.statusCode);
|
|
544
|
+
}
|
|
532
545
|
} catch (e: any) {
|
|
533
546
|
this.apiError(e);
|
|
534
547
|
this.errorLog(
|
|
@@ -576,10 +589,20 @@ export class CeilingLight {
|
|
|
576
589
|
method: 'POST',
|
|
577
590
|
headers: this.platform.generateHeaders(),
|
|
578
591
|
});
|
|
592
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
593
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
594
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
579
595
|
const deviceStatus: any = await body.json();
|
|
580
|
-
this.
|
|
581
|
-
this.
|
|
582
|
-
this.
|
|
596
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
597
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
598
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
599
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
600
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
601
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
602
|
+
} else {
|
|
603
|
+
this.statusCode(statusCode);
|
|
604
|
+
this.statusCode(deviceStatus.statusCode);
|
|
605
|
+
}
|
|
583
606
|
} catch (e: any) {
|
|
584
607
|
this.apiError(e);
|
|
585
608
|
this.errorLog(
|
|
@@ -612,10 +635,20 @@ export class CeilingLight {
|
|
|
612
635
|
method: 'POST',
|
|
613
636
|
headers: this.platform.generateHeaders(),
|
|
614
637
|
});
|
|
638
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
639
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
640
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
615
641
|
const deviceStatus: any = await body.json();
|
|
616
|
-
this.
|
|
617
|
-
this.
|
|
618
|
-
this.
|
|
642
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
643
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
644
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
645
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
646
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
647
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
648
|
+
} else {
|
|
649
|
+
this.statusCode(statusCode);
|
|
650
|
+
this.statusCode(deviceStatus.statusCode);
|
|
651
|
+
}
|
|
619
652
|
} catch (e: any) {
|
|
620
653
|
this.apiError(e);
|
|
621
654
|
this.errorLog(
|
|
@@ -646,10 +679,20 @@ export class CeilingLight {
|
|
|
646
679
|
method: 'POST',
|
|
647
680
|
headers: this.platform.generateHeaders(),
|
|
648
681
|
});
|
|
682
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
683
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
684
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
649
685
|
const deviceStatus: any = await body.json();
|
|
650
|
-
this.
|
|
651
|
-
this.
|
|
652
|
-
this.
|
|
686
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
687
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
688
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
689
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
690
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
691
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
692
|
+
} else {
|
|
693
|
+
this.statusCode(statusCode);
|
|
694
|
+
this.statusCode(deviceStatus.statusCode);
|
|
695
|
+
}
|
|
653
696
|
} catch (e: any) {
|
|
654
697
|
this.apiError(e);
|
|
655
698
|
this.errorLog(
|
|
@@ -807,7 +850,7 @@ export class CeilingLight {
|
|
|
807
850
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
808
851
|
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
809
852
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
810
|
-
+ `updateCharacteristic
|
|
853
|
+
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
811
854
|
}
|
|
812
855
|
}
|
|
813
856
|
|
package/src/device/colorbulb.ts
CHANGED
|
@@ -110,12 +110,6 @@ export class ColorBulb {
|
|
|
110
110
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
114
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
115
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
116
|
-
|
|
117
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
118
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
119
113
|
this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
120
114
|
if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
121
115
|
this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -429,18 +423,27 @@ export class ColorBulb {
|
|
|
429
423
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
430
424
|
headers: this.platform.generateHeaders(),
|
|
431
425
|
});
|
|
426
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
427
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
428
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
432
429
|
const deviceStatus: any = await body.json();
|
|
433
|
-
this.
|
|
434
|
-
this.
|
|
435
|
-
this.
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
430
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
431
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
432
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
433
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
434
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
435
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
436
|
+
this.OpenAPI_On = deviceStatus.body.power;
|
|
437
|
+
this.OpenAPI_RGB = deviceStatus.body.color;
|
|
438
|
+
this.OpenAPI_Brightness = deviceStatus.body.brightness;
|
|
439
|
+
this.OpenAPI_ColorTemperature = deviceStatus.body.colorTemperature;
|
|
440
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
441
|
+
this.openAPIparseStatus();
|
|
442
|
+
this.updateHomeKitCharacteristics();
|
|
443
|
+
} else {
|
|
444
|
+
this.statusCode(statusCode);
|
|
445
|
+
this.statusCode(deviceStatus.statusCode);
|
|
446
|
+
}
|
|
444
447
|
} catch (e: any) {
|
|
445
448
|
this.apiError(e);
|
|
446
449
|
this.errorLog(
|
|
@@ -688,10 +691,20 @@ export class ColorBulb {
|
|
|
688
691
|
method: 'POST',
|
|
689
692
|
headers: this.platform.generateHeaders(),
|
|
690
693
|
});
|
|
694
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
695
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
696
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
691
697
|
const deviceStatus: any = await body.json();
|
|
692
|
-
this.
|
|
693
|
-
this.
|
|
694
|
-
this.
|
|
698
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
699
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
700
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
701
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
702
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
703
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
704
|
+
} else {
|
|
705
|
+
this.statusCode(statusCode);
|
|
706
|
+
this.statusCode(deviceStatus.statusCode);
|
|
707
|
+
}
|
|
695
708
|
} catch (e: any) {
|
|
696
709
|
this.apiError(e);
|
|
697
710
|
this.errorLog(
|
|
@@ -739,10 +752,20 @@ export class ColorBulb {
|
|
|
739
752
|
method: 'POST',
|
|
740
753
|
headers: this.platform.generateHeaders(),
|
|
741
754
|
});
|
|
755
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
756
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
757
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
742
758
|
const deviceStatus: any = await body.json();
|
|
743
|
-
this.
|
|
744
|
-
this.
|
|
745
|
-
this.
|
|
759
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
760
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
761
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
762
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
763
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
764
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
765
|
+
} else {
|
|
766
|
+
this.statusCode(statusCode);
|
|
767
|
+
this.statusCode(deviceStatus.statusCode);
|
|
768
|
+
}
|
|
746
769
|
} catch (e: any) {
|
|
747
770
|
this.apiError(e);
|
|
748
771
|
this.errorLog(
|
|
@@ -775,10 +798,20 @@ export class ColorBulb {
|
|
|
775
798
|
method: 'POST',
|
|
776
799
|
headers: this.platform.generateHeaders(),
|
|
777
800
|
});
|
|
801
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
802
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
803
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
778
804
|
const deviceStatus: any = await body.json();
|
|
779
|
-
this.
|
|
780
|
-
this.
|
|
781
|
-
this.
|
|
805
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
806
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
807
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
808
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
809
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
810
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
811
|
+
} else {
|
|
812
|
+
this.statusCode(statusCode);
|
|
813
|
+
this.statusCode(deviceStatus.statusCode);
|
|
814
|
+
}
|
|
782
815
|
} catch (e: any) {
|
|
783
816
|
this.apiError(e);
|
|
784
817
|
this.errorLog(
|
|
@@ -809,10 +842,20 @@ export class ColorBulb {
|
|
|
809
842
|
method: 'POST',
|
|
810
843
|
headers: this.platform.generateHeaders(),
|
|
811
844
|
});
|
|
845
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
846
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
847
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
812
848
|
const deviceStatus: any = await body.json();
|
|
813
|
-
this.
|
|
814
|
-
this.
|
|
815
|
-
this.
|
|
849
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
850
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
851
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
852
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
853
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
854
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
855
|
+
} else {
|
|
856
|
+
this.statusCode(statusCode);
|
|
857
|
+
this.statusCode(deviceStatus.statusCode);
|
|
858
|
+
}
|
|
816
859
|
} catch (e: any) {
|
|
817
860
|
this.apiError(e);
|
|
818
861
|
this.errorLog(
|
|
@@ -970,7 +1013,7 @@ export class ColorBulb {
|
|
|
970
1013
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
971
1014
|
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
972
1015
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
973
|
-
+ `updateCharacteristic
|
|
1016
|
+
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
974
1017
|
}
|
|
975
1018
|
}
|
|
976
1019
|
|
package/src/device/contact.ts
CHANGED
|
@@ -93,18 +93,10 @@ export class Contact {
|
|
|
93
93
|
accessory.getService(this.platform.Service.ContactSensor) || accessory.addService(this.platform.Service.ContactSensor)),
|
|
94
94
|
`${accessory.displayName} Contact Sensor`;
|
|
95
95
|
|
|
96
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
97
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
98
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Contact, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
99
|
-
|
|
100
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
101
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
102
96
|
this.contactSensorservice.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
103
97
|
if (!this.contactSensorservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
104
98
|
this.contactSensorservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
105
99
|
}
|
|
106
|
-
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
107
|
-
// see https://developers.homebridge.io/#/service/ContactSensor
|
|
108
100
|
|
|
109
101
|
// Motion Sensor Service
|
|
110
102
|
if (device.contact?.hide_motionsensor) {
|
|
@@ -382,18 +374,27 @@ export class Contact {
|
|
|
382
374
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
383
375
|
headers: this.platform.generateHeaders(),
|
|
384
376
|
});
|
|
377
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
378
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
379
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
385
380
|
const deviceStatus: any = await body.json();
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
388
|
-
this.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
381
|
+
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
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
384
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
385
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
386
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
387
|
+
this.OpenAPI_ContactSensorState = deviceStatus.body.openState;
|
|
388
|
+
this.OpenAPI_MotionDetected = deviceStatus.body.moveDetected;
|
|
389
|
+
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
|
|
390
|
+
this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
|
|
391
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
392
|
+
this.openAPIparseStatus();
|
|
393
|
+
this.updateHomeKitCharacteristics();
|
|
394
|
+
} else {
|
|
395
|
+
this.statusCode(statusCode);
|
|
396
|
+
this.statusCode(deviceStatus.statusCode);
|
|
397
|
+
}
|
|
397
398
|
} catch (e: any) {
|
|
398
399
|
this.apiError(e);
|
|
399
400
|
this.errorLog(
|
|
@@ -457,7 +458,7 @@ export class Contact {
|
|
|
457
458
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
458
459
|
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
459
460
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
460
|
-
+ `updateCharacteristic
|
|
461
|
+
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
461
462
|
}
|
|
462
463
|
}
|
|
463
464
|
|
package/src/device/curtain.ts
CHANGED
|
@@ -112,12 +112,6 @@ export class Curtain {
|
|
|
112
112
|
accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
|
|
113
113
|
`${device.deviceName} ${device.deviceType}`;
|
|
114
114
|
|
|
115
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
116
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
117
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.WindowCovering, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
118
|
-
|
|
119
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
120
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
121
115
|
this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
122
116
|
if (!this.windowCoveringService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
|
|
123
117
|
this.windowCoveringService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
|
|
@@ -550,18 +544,27 @@ export class Curtain {
|
|
|
550
544
|
const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
|
|
551
545
|
headers: this.platform.generateHeaders(),
|
|
552
546
|
});
|
|
547
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
548
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
549
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
553
550
|
const deviceStatus: any = await body.json();
|
|
554
|
-
this.
|
|
555
|
-
this.
|
|
556
|
-
this.
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
551
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
552
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
553
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
554
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
555
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
556
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
557
|
+
this.OpenAPI_CurrentPosition = deviceStatus.body.slidePosition;
|
|
558
|
+
this.OpenAPI_InMotion = deviceStatus.body.moving;
|
|
559
|
+
this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
|
|
560
|
+
this.OpenAPI_BatterLevel = deviceStatus.body.battery;
|
|
561
|
+
this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
|
|
562
|
+
this.openAPIparseStatus();
|
|
563
|
+
this.updateHomeKitCharacteristics();
|
|
564
|
+
} else {
|
|
565
|
+
this.statusCode(statusCode);
|
|
566
|
+
this.statusCode(deviceStatus.statusCode);
|
|
567
|
+
}
|
|
565
568
|
} catch (e: any) {
|
|
566
569
|
this.apiError(e);
|
|
567
570
|
this.errorLog(
|
|
@@ -696,10 +699,20 @@ export class Curtain {
|
|
|
696
699
|
method: 'POST',
|
|
697
700
|
headers: this.platform.generateHeaders(),
|
|
698
701
|
});
|
|
702
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
|
|
703
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
|
|
704
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
|
|
699
705
|
const deviceStatus: any = await body.json();
|
|
700
|
-
this.
|
|
701
|
-
this.
|
|
702
|
-
this.
|
|
706
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
|
|
707
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
|
|
708
|
+
this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
|
|
709
|
+
if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
|
|
710
|
+
this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
711
|
+
+ `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
|
|
712
|
+
} else {
|
|
713
|
+
this.statusCode(statusCode);
|
|
714
|
+
this.statusCode(deviceStatus.statusCode);
|
|
715
|
+
}
|
|
703
716
|
} catch (e: any) {
|
|
704
717
|
this.apiError(e);
|
|
705
718
|
this.errorLog(
|
|
@@ -843,7 +856,7 @@ export class Curtain {
|
|
|
843
856
|
this.accessory.getService(this.platform.Service.AccessoryInformation)!
|
|
844
857
|
.updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
|
|
845
858
|
this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
|
|
846
|
-
+ `updateCharacteristic
|
|
859
|
+
+ `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
|
|
847
860
|
}
|
|
848
861
|
}
|
|
849
862
|
|