@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
@@ -333,17 +333,26 @@ export class IOSensor {
333
333
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
334
334
  headers: this.platform.generateHeaders(),
335
335
  });
336
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
337
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
338
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
336
339
  const deviceStatus: any = await body.json();
337
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
338
- this.statusCode(statusCode);
339
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
340
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
341
- this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
342
- this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
343
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
344
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
345
- this.openAPIparseStatus();
346
- this.updateHomeKitCharacteristics();
340
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
341
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
342
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
343
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
344
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
345
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
346
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
347
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
348
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
349
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
350
+ this.openAPIparseStatus();
351
+ this.updateHomeKitCharacteristics();
352
+ } else {
353
+ this.statusCode(statusCode);
354
+ this.statusCode(deviceStatus.statusCode);
355
+ }
347
356
  } catch (e: any) {
348
357
  this.apiError(e);
349
358
  this.errorLog(
@@ -429,7 +438,7 @@ export class IOSensor {
429
438
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
430
439
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
431
440
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
432
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
441
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
433
442
  }
434
443
  }
435
444
 
@@ -102,12 +102,6 @@ export class StripLight {
102
102
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} adaptiveLighting: ${this.accessory.context.adaptiveLighting}`);
103
103
  }
104
104
 
105
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
106
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
107
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
108
-
109
- // set the service name, this is what is displayed as the default name on the Home app
110
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
111
105
  this.lightBulbService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
112
106
  if (!this.lightBulbService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
113
107
  this.lightBulbService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -369,17 +363,26 @@ export class StripLight {
369
363
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
370
364
  headers: this.platform.generateHeaders(),
371
365
  });
366
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
367
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
368
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
372
369
  const deviceStatus: any = await body.json();
373
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
374
- this.statusCode(statusCode);
375
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
376
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
377
- this.OpenAPI_On = deviceStatus.body.power;
378
- this.OpenAPI_RGB = deviceStatus.body.color;
379
- this.OpenAPI_Brightness = deviceStatus.body.brightness;
380
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
381
- this.openAPIparseStatus();
382
- this.updateHomeKitCharacteristics();
370
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
371
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
372
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
373
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
374
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
375
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
376
+ this.OpenAPI_On = deviceStatus.body.power;
377
+ this.OpenAPI_RGB = deviceStatus.body.color;
378
+ this.OpenAPI_Brightness = deviceStatus.body.brightness;
379
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
380
+ this.openAPIparseStatus();
381
+ this.updateHomeKitCharacteristics();
382
+ } else {
383
+ this.statusCode(statusCode);
384
+ this.statusCode(deviceStatus.statusCode);
385
+ }
383
386
  } catch (e: any) {
384
387
  this.apiError(e);
385
388
  this.errorLog(
@@ -583,10 +586,20 @@ export class StripLight {
583
586
  method: 'POST',
584
587
  headers: this.platform.generateHeaders(),
585
588
  });
589
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
590
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
591
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
586
592
  const deviceStatus: any = await body.json();
587
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
588
- this.statusCode(statusCode);
589
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
593
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
594
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
595
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
596
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
597
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
598
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
599
+ } else {
600
+ this.statusCode(statusCode);
601
+ this.statusCode(deviceStatus.statusCode);
602
+ }
590
603
  } catch (e: any) {
591
604
  this.apiError(e);
592
605
  this.errorLog(
@@ -631,10 +644,20 @@ export class StripLight {
631
644
  method: 'POST',
632
645
  headers: this.platform.generateHeaders(),
633
646
  });
647
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
648
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
649
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
634
650
  const deviceStatus: any = await body.json();
635
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
636
- this.statusCode(statusCode);
637
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
651
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
652
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
653
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
654
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
655
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
656
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
657
+ } else {
658
+ this.statusCode(statusCode);
659
+ this.statusCode(deviceStatus.statusCode);
660
+ }
638
661
  } catch (e: any) {
639
662
  this.apiError(e);
640
663
  this.errorLog(
@@ -665,10 +688,20 @@ export class StripLight {
665
688
  method: 'POST',
666
689
  headers: this.platform.generateHeaders(),
667
690
  });
691
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
692
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
693
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
668
694
  const deviceStatus: any = await body.json();
669
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
670
- this.statusCode(statusCode);
671
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
695
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
696
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
697
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
698
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
699
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
700
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
701
+ } else {
702
+ this.statusCode(statusCode);
703
+ this.statusCode(deviceStatus.statusCode);
704
+ }
672
705
  } catch (e: any) {
673
706
  this.apiError(e);
674
707
  this.errorLog(
@@ -826,7 +859,7 @@ export class StripLight {
826
859
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
827
860
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
828
861
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
829
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
862
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
830
863
  }
831
864
  }
832
865
 
@@ -83,12 +83,6 @@ export class Lock {
83
83
  (this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
84
84
  `${device.deviceName} ${device.deviceType}`;
85
85
 
86
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
87
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
88
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.LockMechanism, 'NAME', 'USER_DEFINED_SUBTYPE');
89
-
90
- // set the service name, this is what is displayed as the default name on the Home app
91
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
92
86
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
93
87
  if (!this.lockService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
94
88
  this.lockService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -333,17 +327,26 @@ export class Lock {
333
327
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
334
328
  headers: this.platform.generateHeaders(),
335
329
  });
330
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
331
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
332
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
336
333
  const deviceStatus: any = await body.json();
337
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
338
- this.statusCode(statusCode);
339
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
340
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
341
- this.OpenAPI_LockCurrentState = deviceStatus.body.lockState;
342
- this.OpenAPI_ContactSensorState = deviceStatus.body.doorState;
343
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
344
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
345
- this.openAPIparseStatus();
346
- this.updateHomeKitCharacteristics();
334
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
335
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
336
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
337
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
338
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
339
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
340
+ this.OpenAPI_LockCurrentState = deviceStatus.body.lockState;
341
+ this.OpenAPI_ContactSensorState = deviceStatus.body.doorState;
342
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
343
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
344
+ this.openAPIparseStatus();
345
+ this.updateHomeKitCharacteristics();
346
+ } else {
347
+ this.statusCode(statusCode);
348
+ this.statusCode(deviceStatus.statusCode);
349
+ }
347
350
  } catch (e: any) {
348
351
  this.apiError(e);
349
352
  this.errorLog(
@@ -442,10 +445,20 @@ export class Lock {
442
445
  method: 'POST',
443
446
  headers: this.platform.generateHeaders(),
444
447
  });
448
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
449
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
450
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
445
451
  const deviceStatus: any = await body.json();
446
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
447
- this.statusCode(statusCode);
448
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
452
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
453
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
454
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
455
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
456
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
457
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
458
+ } else {
459
+ this.statusCode(statusCode);
460
+ this.statusCode(deviceStatus.statusCode);
461
+ }
449
462
  } catch (e: any) {
450
463
  this.apiError(e);
451
464
  this.errorLog(
@@ -522,7 +535,7 @@ export class Lock {
522
535
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
523
536
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
524
537
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
525
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
538
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
526
539
  }
527
540
  }
528
541
 
@@ -18,8 +18,8 @@ import { sleep } from '../utils';
18
18
  export class Meter {
19
19
  // Services
20
20
  batteryService: Service;
21
- humidityservice?: Service;
22
- temperatureservice?: Service;
21
+ humidityService?: Service;
22
+ temperatureService?: Service;
23
23
 
24
24
  // Characteristic Values
25
25
  BatteryLevel!: CharacteristicValue;
@@ -96,19 +96,19 @@ export class Meter {
96
96
  // Temperature Sensor Service
97
97
  if (device.meter?.hide_temperature) {
98
98
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Temperature Sensor Service`);
99
- this.temperatureservice = this.accessory.getService(this.platform.Service.TemperatureSensor);
100
- accessory.removeService(this.temperatureservice!);
101
- } else if (!this.temperatureservice) {
99
+ this.temperatureService = this.accessory.getService(this.platform.Service.TemperatureSensor);
100
+ accessory.removeService(this.temperatureService!);
101
+ } else if (!this.temperatureService) {
102
102
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Temperature Sensor Service`);
103
- (this.temperatureservice =
103
+ (this.temperatureService =
104
104
  this.accessory.getService(this.platform.Service.TemperatureSensor) || this.accessory.addService(this.platform.Service.TemperatureSensor)),
105
105
  `${accessory.displayName} Temperature Sensor`;
106
106
 
107
- this.temperatureservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
108
- if (!this.temperatureservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
109
- this.temperatureservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
107
+ this.temperatureService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Temperature Sensor`);
108
+ if (!this.temperatureService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
109
+ this.temperatureService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Temperature Sensor`);
110
110
  }
111
- this.temperatureservice
111
+ this.temperatureService
112
112
  .getCharacteristic(this.platform.Characteristic.CurrentTemperature)
113
113
  .setProps({
114
114
  unit: Units['CELSIUS'],
@@ -127,19 +127,19 @@ export class Meter {
127
127
  // Humidity Sensor Service
128
128
  if (device.meter?.hide_humidity) {
129
129
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Humidity Sensor Service`);
130
- this.humidityservice = this.accessory.getService(this.platform.Service.HumiditySensor);
131
- accessory.removeService(this.humidityservice!);
132
- } else if (!this.humidityservice) {
130
+ this.humidityService = this.accessory.getService(this.platform.Service.HumiditySensor);
131
+ accessory.removeService(this.humidityService!);
132
+ } else if (!this.humidityService) {
133
133
  this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Humidity Sensor Service`);
134
- (this.humidityservice =
134
+ (this.humidityService =
135
135
  this.accessory.getService(this.platform.Service.HumiditySensor) || this.accessory.addService(this.platform.Service.HumiditySensor)),
136
136
  `${accessory.displayName} Humidity Sensor`;
137
137
 
138
- this.humidityservice.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
139
- if (!this.humidityservice.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
140
- this.humidityservice.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
138
+ this.humidityService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Humidity Sensor`);
139
+ if (!this.humidityService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
140
+ this.humidityService.addCharacteristic(this.platform.Characteristic.ConfiguredName, `${accessory.displayName} Humidity Sensor`);
141
141
  }
142
- this.humidityservice
142
+ this.humidityService
143
143
  .getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity)
144
144
  .setProps({
145
145
  minStep: 0.1,
@@ -334,17 +334,26 @@ export class Meter {
334
334
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
335
335
  headers: this.platform.generateHeaders(),
336
336
  });
337
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
338
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
339
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
337
340
  const deviceStatus: any = await body.json();
338
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
339
- this.statusCode(statusCode);
340
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
341
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
342
- this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
343
- this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
344
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
345
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
346
- this.openAPIparseStatus();
347
- this.updateHomeKitCharacteristics();
341
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
342
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
343
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
344
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
345
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
346
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
347
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
348
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
349
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
350
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
351
+ this.openAPIparseStatus();
352
+ this.updateHomeKitCharacteristics();
353
+ } else {
354
+ this.statusCode(statusCode);
355
+ this.statusCode(deviceStatus.statusCode);
356
+ }
348
357
  } catch (e: any) {
349
358
  this.apiError(e);
350
359
  this.errorLog(
@@ -365,7 +374,7 @@ export class Meter {
365
374
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`);
366
375
  } else {
367
376
  this.accessory.context.CurrentRelativeHumidity = this.CurrentRelativeHumidity;
368
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
377
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.CurrentRelativeHumidity);
369
378
  this.debugLog(
370
379
  `${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic` +
371
380
  ` CurrentRelativeHumidity: ${this.CurrentRelativeHumidity}`,
@@ -389,11 +398,10 @@ export class Meter {
389
398
  entry['temp'] = this.CurrentTemperature;
390
399
  }
391
400
  this.accessory.context.CurrentTemperature = this.CurrentTemperature;
392
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
401
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, this.CurrentTemperature);
393
402
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic CurrentTemperature: ${this.CurrentTemperature}`);
394
403
  }
395
404
  }
396
-
397
405
  if (this.BatteryLevel === undefined) {
398
406
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
399
407
  } else {
@@ -432,7 +440,7 @@ export class Meter {
432
440
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
433
441
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
434
442
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
435
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
443
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
436
444
  }
437
445
  }
438
446
 
@@ -586,10 +594,10 @@ export class Meter {
586
594
 
587
595
  async apiError(e: any): Promise<void> {
588
596
  if (!this.device.meter?.hide_humidity) {
589
- this.humidityservice?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
597
+ this.humidityService?.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, e);
590
598
  }
591
599
  if (!this.device.meter?.hide_temperature) {
592
- this.temperatureservice?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
600
+ this.temperatureService?.updateCharacteristic(this.platform.Characteristic.CurrentTemperature, e);
593
601
  }
594
602
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, e);
595
603
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, e);
@@ -334,17 +334,26 @@ export class MeterPlus {
334
334
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
335
335
  headers: this.platform.generateHeaders(),
336
336
  });
337
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
338
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
339
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
337
340
  const deviceStatus: any = await body.json();
338
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
339
- this.statusCode(statusCode);
340
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
341
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
342
- this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
343
- this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
344
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
345
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
346
- this.openAPIparseStatus();
347
- this.updateHomeKitCharacteristics();
341
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
342
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
343
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
344
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
345
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
346
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
347
+ this.OpenAPI_CurrentRelativeHumidity = deviceStatus.body.humidity!;
348
+ this.OpenAPI_CurrentTemperature = deviceStatus.body.temperature!;
349
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
350
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
351
+ this.openAPIparseStatus();
352
+ this.updateHomeKitCharacteristics();
353
+ } else {
354
+ this.statusCode(statusCode);
355
+ this.statusCode(deviceStatus.statusCode);
356
+ }
348
357
  } catch (e: any) {
349
358
  this.apiError(e);
350
359
  this.errorLog(
@@ -432,7 +441,7 @@ export class MeterPlus {
432
441
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
433
442
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
434
443
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
435
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
444
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
436
445
  }
437
446
  }
438
447
 
@@ -93,12 +93,6 @@ export class Motion {
93
93
  (this.motionSensorService = accessory.getService(this.platform.Service.MotionSensor) || accessory.addService(this.platform.Service.MotionSensor)),
94
94
  `${accessory.displayName} Motion 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.Motion, '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.motionSensorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
103
97
  if (!this.motionSensorService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
104
98
  this.motionSensorService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -343,17 +337,26 @@ export class Motion {
343
337
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
344
338
  headers: this.platform.generateHeaders(),
345
339
  });
340
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
341
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
342
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
346
343
  const deviceStatus: any = await body.json();
347
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
348
- this.statusCode(statusCode);
349
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
350
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
351
- this.OpenAPI_MotionDetected = deviceStatus.body.moveDetected;
352
- this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
353
- this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
354
- this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
355
- this.openAPIparseStatus();
356
- this.updateHomeKitCharacteristics();
344
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
345
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
346
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
347
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
348
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
349
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
350
+ this.OpenAPI_MotionDetected = deviceStatus.body.moveDetected;
351
+ this.OpenAPI_CurrentAmbientLightLevel = deviceStatus.body.brightness;
352
+ this.OpenAPI_BatteryLevel = deviceStatus.body.battery;
353
+ this.OpenAPI_FirmwareRevision = deviceStatus.body.version;
354
+ this.openAPIparseStatus();
355
+ this.updateHomeKitCharacteristics();
356
+ } else {
357
+ this.statusCode(statusCode);
358
+ this.statusCode(deviceStatus.statusCode);
359
+ }
357
360
  } catch (e: any) {
358
361
  this.apiError(e);
359
362
  this.errorLog(
@@ -408,7 +411,7 @@ export class Motion {
408
411
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
409
412
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
410
413
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
411
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
414
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
412
415
  }
413
416
  }
414
417
 
@@ -69,12 +69,6 @@ export class Plug {
69
69
  (this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
70
70
  `${device.deviceName} ${device.deviceType}`;
71
71
 
72
- // To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
73
- // when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
74
- // accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Outlet, 'NAME', 'USER_DEFINED_SUBTYPE');
75
-
76
- // set the service name, this is what is displayed as the default name on the Home app
77
- // in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
78
72
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
79
73
  if (!this.outletService.testCharacteristic(this.platform.Characteristic.ConfiguredName)) {
80
74
  this.outletService.addCharacteristic(this.platform.Characteristic.ConfiguredName, accessory.displayName);
@@ -247,14 +241,23 @@ export class Plug {
247
241
  const { body, statusCode, headers } = await request(`${Devices}/${this.device.deviceId}/status`, {
248
242
  headers: this.platform.generateHeaders(),
249
243
  });
244
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
245
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
246
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
250
247
  const deviceStatus: any = await body.json();
251
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
252
- this.statusCode(statusCode);
253
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
254
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
255
- this.OpenAPI_On = deviceStatus.body.power;
256
- this.openAPIparseStatus();
257
- this.updateHomeKitCharacteristics();
248
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus: ${JSON.stringify(deviceStatus)}`);
249
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus body: ${JSON.stringify(deviceStatus.body)}`);
250
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
251
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
252
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
253
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
254
+ this.OpenAPI_On = deviceStatus.body.power;
255
+ this.openAPIparseStatus();
256
+ this.updateHomeKitCharacteristics();
257
+ } else {
258
+ this.statusCode(statusCode);
259
+ this.statusCode(deviceStatus.statusCode);
260
+ }
258
261
  } catch (e: any) {
259
262
  this.apiError(e);
260
263
  this.errorLog(
@@ -365,10 +368,20 @@ export class Plug {
365
368
  method: 'POST',
366
369
  headers: this.platform.generateHeaders(),
367
370
  });
371
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} body: ${JSON.stringify(body)}`);
372
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${statusCode}`);
373
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} headers: ${JSON.stringify(headers)}`);
368
374
  const deviceStatus: any = await body.json();
369
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
370
- this.statusCode(statusCode);
371
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
375
+ 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
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} deviceStatus statusCode: ${deviceStatus.statusCode}`);
378
+ if ((statusCode === 200 || statusCode === 100) && (deviceStatus.statusCode === 200 || deviceStatus.statusCode === 100)) {
379
+ this.debugErrorLog(`${this.device.deviceType}: ${this.accessory.displayName} `
380
+ + `statusCode: ${statusCode} & deviceStatus StatusCode: ${deviceStatus.statusCode}`);
381
+ } else {
382
+ this.statusCode(statusCode);
383
+ this.statusCode(deviceStatus.statusCode);
384
+ }
372
385
  } catch (e: any) {
373
386
  this.apiError(e);
374
387
  this.errorLog(
@@ -415,7 +428,7 @@ export class Plug {
415
428
  this.accessory.getService(this.platform.Service.AccessoryInformation)!
416
429
  .updateCharacteristic(this.platform.Characteristic.FirmwareRevision, this.OpenAPI_FirmwareRevision);
417
430
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
418
- + `updateCharacteristic CurrentTemperature: ${this.OpenAPI_FirmwareRevision}`);
431
+ + `updateCharacteristic FirmwareRevision: ${this.OpenAPI_FirmwareRevision}`);
419
432
  }
420
433
  }
421
434