@switchbot/homebridge-switchbot 2.8.1-beta.8 → 2.8.1

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.
Files changed (111) hide show
  1. package/.github/dependabot.yml +2 -2
  2. package/CHANGELOG.md +9 -0
  3. package/config.schema.json +4 -4
  4. package/dist/device/blindtilt.d.ts.map +1 -1
  5. package/dist/device/blindtilt.js +37 -23
  6. package/dist/device/blindtilt.js.map +1 -1
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +26 -10
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +78 -29
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts.map +1 -1
  14. package/dist/device/colorbulb.js +78 -29
  15. package/dist/device/colorbulb.js.map +1 -1
  16. package/dist/device/contact.d.ts.map +1 -1
  17. package/dist/device/contact.js +22 -19
  18. package/dist/device/contact.js.map +1 -1
  19. package/dist/device/curtain.d.ts.map +1 -1
  20. package/dist/device/curtain.js +36 -20
  21. package/dist/device/curtain.js.map +1 -1
  22. package/dist/device/hub.d.ts +3 -3
  23. package/dist/device/hub.d.ts.map +1 -1
  24. package/dist/device/hub.js +205 -172
  25. package/dist/device/hub.js.map +1 -1
  26. package/dist/device/humidifier.d.ts.map +1 -1
  27. package/dist/device/humidifier.js +66 -28
  28. package/dist/device/humidifier.js.map +1 -1
  29. package/dist/device/iosensor.d.ts.map +1 -1
  30. package/dist/device/iosensor.js +21 -11
  31. package/dist/device/iosensor.js.map +1 -1
  32. package/dist/device/lightstrip.d.ts.map +1 -1
  33. package/dist/device/lightstrip.js +63 -25
  34. package/dist/device/lightstrip.js.map +1 -1
  35. package/dist/device/lock.d.ts.map +1 -1
  36. package/dist/device/lock.js +35 -19
  37. package/dist/device/lock.js.map +1 -1
  38. package/dist/device/meter.d.ts +2 -2
  39. package/dist/device/meter.d.ts.map +1 -1
  40. package/dist/device/meter.js +41 -31
  41. package/dist/device/meter.js.map +1 -1
  42. package/dist/device/meterplus.d.ts.map +1 -1
  43. package/dist/device/meterplus.js +21 -11
  44. package/dist/device/meterplus.js.map +1 -1
  45. package/dist/device/motion.d.ts.map +1 -1
  46. package/dist/device/motion.js +21 -16
  47. package/dist/device/motion.js.map +1 -1
  48. package/dist/device/plug.d.ts.map +1 -1
  49. package/dist/device/plug.js +32 -16
  50. package/dist/device/plug.js.map +1 -1
  51. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  52. package/dist/device/robotvacuumcleaner.js +48 -21
  53. package/dist/device/robotvacuumcleaner.js.map +1 -1
  54. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  55. package/dist/irdevice/airconditioner.js +15 -9
  56. package/dist/irdevice/airconditioner.js.map +1 -1
  57. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  58. package/dist/irdevice/airpurifier.js +15 -9
  59. package/dist/irdevice/airpurifier.js.map +1 -1
  60. package/dist/irdevice/camera.d.ts.map +1 -1
  61. package/dist/irdevice/camera.js +15 -9
  62. package/dist/irdevice/camera.js.map +1 -1
  63. package/dist/irdevice/fan.d.ts.map +1 -1
  64. package/dist/irdevice/fan.js +15 -9
  65. package/dist/irdevice/fan.js.map +1 -1
  66. package/dist/irdevice/light.d.ts.map +1 -1
  67. package/dist/irdevice/light.js +16 -10
  68. package/dist/irdevice/light.js.map +1 -1
  69. package/dist/irdevice/other.d.ts.map +1 -1
  70. package/dist/irdevice/other.js +15 -4
  71. package/dist/irdevice/other.js.map +1 -1
  72. package/dist/irdevice/tv.d.ts.map +1 -1
  73. package/dist/irdevice/tv.js +15 -9
  74. package/dist/irdevice/tv.js.map +1 -1
  75. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.js +15 -9
  77. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  78. package/dist/irdevice/waterheater.d.ts.map +1 -1
  79. package/dist/irdevice/waterheater.js +15 -9
  80. package/dist/irdevice/waterheater.js.map +1 -1
  81. package/dist/platform.d.ts.map +1 -1
  82. package/dist/platform.js +28 -11
  83. package/dist/platform.js.map +1 -1
  84. package/package.json +3 -3
  85. package/src/device/blindtilt.ts +35 -25
  86. package/src/device/bot.ts +25 -10
  87. package/src/device/ceilinglight.ts +73 -30
  88. package/src/device/colorbulb.ts +73 -30
  89. package/src/device/contact.ts +21 -20
  90. package/src/device/curtain.ts +34 -21
  91. package/src/device/hub.ts +211 -188
  92. package/src/device/humidifier.ts +62 -29
  93. package/src/device/iosensor.ts +20 -11
  94. package/src/device/lightstrip.ts +59 -26
  95. package/src/device/lock.ts +33 -20
  96. package/src/device/meter.ts +42 -34
  97. package/src/device/meterplus.ts +20 -11
  98. package/src/device/motion.ts +20 -17
  99. package/src/device/plug.ts +30 -17
  100. package/src/device/robotvacuumcleaner.ts +45 -22
  101. package/src/irdevice/airconditioner.ts +14 -10
  102. package/src/irdevice/airpurifier.ts +14 -10
  103. package/src/irdevice/camera.ts +14 -10
  104. package/src/irdevice/fan.ts +14 -10
  105. package/src/irdevice/light.ts +15 -11
  106. package/src/irdevice/other.ts +14 -4
  107. package/src/irdevice/tv.ts +14 -10
  108. package/src/irdevice/vacuumcleaner.ts +14 -10
  109. package/src/irdevice/waterheater.ts +14 -10
  110. package/src/platform.ts +25 -11
  111. package/.github/npm-version-script.js +0 -81
@@ -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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
407
- this.statusCode(statusCode);
408
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
409
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
410
- this.OpenAPI_On = deviceStatus.body.power;
411
- this.OpenAPI_RGB = deviceStatus.body.color;
412
- this.OpenAPI_Brightness = deviceStatus.body.brightness;
413
- this.OpenAPI_ColorTemperature = deviceStatus.body.colorTemperature;
414
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
415
- this.openAPIparseStatus();
416
- this.updateHomeKitCharacteristics();
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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
530
- this.statusCode(statusCode);
531
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
581
- this.statusCode(statusCode);
582
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
617
- this.statusCode(statusCode);
618
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
651
- this.statusCode(statusCode);
652
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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 CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
853
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
811
854
  }
812
855
  }
813
856
 
@@ -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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
434
- this.statusCode(statusCode);
435
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
436
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
437
- this.OpenAPI_On = deviceStatus.body.power;
438
- this.OpenAPI_RGB = deviceStatus.body.color;
439
- this.OpenAPI_Brightness = deviceStatus.body.brightness;
440
- this.OpenAPI_ColorTemperature = deviceStatus.body.colorTemperature;
441
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
442
- this.openAPIparseStatus();
443
- this.updateHomeKitCharacteristics();
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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
693
- this.statusCode(statusCode);
694
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
744
- this.statusCode(statusCode);
745
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
780
- this.statusCode(statusCode);
781
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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.debugLog(`Devices: ${JSON.stringify(deviceStatus.body)}`);
814
- this.statusCode(statusCode);
815
- this.debugLog(`Headers: ${JSON.stringify(headers)}`);
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 CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
1016
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
974
1017
  }
975
1018
  }
976
1019
 
@@ -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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
387
- this.statusCode(statusCode);
388
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
389
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
390
- this.OpenAPI_ContactSensorState = deviceStatus.body.openState;
391
- this.OpenAPI_MotionDetected = deviceStatus.body.moveDetected;
392
- this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
393
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
394
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
395
- this.openAPIparseStatus();
396
- this.updateHomeKitCharacteristics();
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 CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
461
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
461
462
  }
462
463
  }
463
464
 
@@ -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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
555
- this.statusCode(statusCode);
556
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
557
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
558
- this.OpenAPI_CurrentPosition = deviceStatus.body.slidePosition;
559
- this.OpenAPI_InMotion = deviceStatus.body.moving;
560
- this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
561
- this.OpenAPI_BatterLevel = deviceStatus.body.battery;
562
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
563
- this.openAPIparseStatus();
564
- this.updateHomeKitCharacteristics();
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.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
701
- this.statusCode(statusCode);
702
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
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 CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
859
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
847
860
  }
848
861
  }
849
862