@switchbot/homebridge-switchbot 2.0.0-beta.26 → 2.0.0-beta.28

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 (112) hide show
  1. package/CHANGELOG.md +0 -2
  2. package/config.schema.json +2 -29
  3. package/dist/device/bot.d.ts +2 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +23 -19
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +2 -0
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +43 -16
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +2 -0
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +19 -9
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +2 -0
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +27 -12
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts +6 -4
  20. package/dist/device/humidifier.d.ts.map +1 -1
  21. package/dist/device/humidifier.js +45 -20
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/lock.d.ts +2 -0
  24. package/dist/device/lock.d.ts.map +1 -1
  25. package/dist/device/lock.js +25 -6
  26. package/dist/device/lock.js.map +1 -1
  27. package/dist/device/meter.d.ts +2 -0
  28. package/dist/device/meter.d.ts.map +1 -1
  29. package/dist/device/meter.js +19 -9
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.d.ts +2 -0
  32. package/dist/device/meterplus.d.ts.map +1 -1
  33. package/dist/device/meterplus.js +19 -9
  34. package/dist/device/meterplus.js.map +1 -1
  35. package/dist/device/motion.d.ts +2 -0
  36. package/dist/device/motion.d.ts.map +1 -1
  37. package/dist/device/motion.js +19 -9
  38. package/dist/device/motion.js.map +1 -1
  39. package/dist/device/plug.d.ts +2 -0
  40. package/dist/device/plug.d.ts.map +1 -1
  41. package/dist/device/plug.js +27 -12
  42. package/dist/device/plug.js.map +1 -1
  43. package/dist/device/striplight.d.ts +2 -0
  44. package/dist/device/striplight.d.ts.map +1 -1
  45. package/dist/device/striplight.js +45 -18
  46. package/dist/device/striplight.js.map +1 -1
  47. package/dist/irdevice/airconditioner.d.ts +2 -0
  48. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  49. package/dist/irdevice/airconditioner.js +14 -0
  50. package/dist/irdevice/airconditioner.js.map +1 -1
  51. package/dist/irdevice/airpurifier.d.ts +2 -0
  52. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  53. package/dist/irdevice/airpurifier.js +14 -0
  54. package/dist/irdevice/airpurifier.js.map +1 -1
  55. package/dist/irdevice/camera.d.ts +2 -0
  56. package/dist/irdevice/camera.d.ts.map +1 -1
  57. package/dist/irdevice/camera.js +14 -0
  58. package/dist/irdevice/camera.js.map +1 -1
  59. package/dist/irdevice/fan.d.ts +2 -0
  60. package/dist/irdevice/fan.d.ts.map +1 -1
  61. package/dist/irdevice/fan.js +14 -0
  62. package/dist/irdevice/fan.js.map +1 -1
  63. package/dist/irdevice/light.d.ts +2 -0
  64. package/dist/irdevice/light.d.ts.map +1 -1
  65. package/dist/irdevice/light.js +14 -0
  66. package/dist/irdevice/light.js.map +1 -1
  67. package/dist/irdevice/other.d.ts +2 -0
  68. package/dist/irdevice/other.d.ts.map +1 -1
  69. package/dist/irdevice/other.js +14 -0
  70. package/dist/irdevice/other.js.map +1 -1
  71. package/dist/irdevice/tv.d.ts +2 -0
  72. package/dist/irdevice/tv.d.ts.map +1 -1
  73. package/dist/irdevice/tv.js +14 -0
  74. package/dist/irdevice/tv.js.map +1 -1
  75. package/dist/irdevice/vacuumcleaner.d.ts +2 -0
  76. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  77. package/dist/irdevice/vacuumcleaner.js +14 -0
  78. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  79. package/dist/irdevice/waterheater.d.ts +2 -0
  80. package/dist/irdevice/waterheater.d.ts.map +1 -1
  81. package/dist/irdevice/waterheater.js +14 -0
  82. package/dist/irdevice/waterheater.js.map +1 -1
  83. package/dist/platform.d.ts +4 -5
  84. package/dist/platform.d.ts.map +1 -1
  85. package/dist/platform.js +148 -180
  86. package/dist/platform.js.map +1 -1
  87. package/dist/settings.d.ts +1 -0
  88. package/dist/settings.d.ts.map +1 -1
  89. package/dist/settings.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/device/bot.ts +25 -19
  92. package/src/device/colorbulb.ts +40 -16
  93. package/src/device/contact.ts +21 -9
  94. package/src/device/curtain.ts +28 -12
  95. package/src/device/humidifier.ts +44 -20
  96. package/src/device/lock.ts +26 -6
  97. package/src/device/meter.ts +21 -9
  98. package/src/device/meterplus.ts +21 -9
  99. package/src/device/motion.ts +21 -9
  100. package/src/device/plug.ts +28 -12
  101. package/src/device/striplight.ts +42 -18
  102. package/src/irdevice/airconditioner.ts +16 -0
  103. package/src/irdevice/airpurifier.ts +16 -0
  104. package/src/irdevice/camera.ts +16 -0
  105. package/src/irdevice/fan.ts +16 -0
  106. package/src/irdevice/light.ts +16 -0
  107. package/src/irdevice/other.ts +16 -0
  108. package/src/irdevice/tv.ts +16 -0
  109. package/src/irdevice/vacuumcleaner.ts +16 -0
  110. package/src/irdevice/waterheater.ts +16 -0
  111. package/src/platform.ts +146 -181
  112. package/src/settings.ts +1 -0
package/src/device/bot.ts CHANGED
@@ -369,7 +369,7 @@ export class Bot {
369
369
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
370
370
  await this.openAPIparseStatus();
371
371
  } else {
372
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
372
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
373
373
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
374
374
  }
375
375
  }
@@ -424,7 +424,7 @@ export class Bot {
424
424
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
425
425
  await this.openAPIRefreshStatus();
426
426
  } else {
427
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
427
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
428
428
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
429
429
  }
430
430
  }
@@ -450,12 +450,8 @@ export class Bot {
450
450
  // Set an event hander
451
451
  switchbot.onadvertisement = (ad: ad) => {
452
452
  this.address = ad.address;
453
- if (this.deviceLogging.includes('debug')) {
454
- this.infoLog(this.address);
455
- this.infoLog(this.device.bleMac);
456
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
457
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
458
- }
453
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
454
+ + ` BLE Address Found: ${this.address}`);
459
455
  this.serviceData = ad.serviceData;
460
456
  this.mode = ad.serviceData.mode;
461
457
  this.state = ad.serviceData.state;
@@ -563,7 +559,7 @@ export class Bot {
563
559
  } else if (this.OpenAPI) {
564
560
  await this.openAPIpushChanges();
565
561
  } else {
566
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
562
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
567
563
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
568
564
  }
569
565
  interval(5000)
@@ -609,10 +605,7 @@ export class Bot {
609
605
  this.apiError(e);
610
606
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
611
607
  + ` Connection & botMode: ${this.botMode}, Error Message: ${superStringify(e.message)}`);
612
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
613
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
614
- await this.openAPIpushChanges();
615
- }
608
+ await this.BLEPushConnection();
616
609
  });
617
610
  } else if (this.botMode === 'switch') {
618
611
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
@@ -630,10 +623,7 @@ export class Bot {
630
623
  this.apiError(e);
631
624
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
632
625
  + ` Connection & botMode: ${this.botMode}, Error Message: ${superStringify(e.message)}`);
633
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
634
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
635
- await this.openAPIpushChanges();
636
- }
626
+ await this.BLEPushConnection();
637
627
  });
638
628
  } else {
639
629
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
@@ -1085,7 +1075,7 @@ export class Bot {
1085
1075
  }
1086
1076
 
1087
1077
  async BLEPushConnection() {
1088
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
1078
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
1089
1079
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
1090
1080
  await this.openAPIpushChanges();
1091
1081
  }
@@ -1093,7 +1083,7 @@ export class Bot {
1093
1083
 
1094
1084
  async BLERefreshConnection(switchbot: any): Promise<void> {
1095
1085
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
1096
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
1086
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
1097
1087
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
1098
1088
  await this.openAPIRefreshStatus();
1099
1089
  }
@@ -1358,12 +1348,28 @@ export class Bot {
1358
1348
  }
1359
1349
  }
1360
1350
 
1351
+ debugWarnLog(...log: any[]): void {
1352
+ if (this.enablingDeviceLogging()) {
1353
+ if (this.deviceLogging?.includes('debug')) {
1354
+ this.platform.log.warn('[DEBUG]', String(...log));
1355
+ }
1356
+ }
1357
+ }
1358
+
1361
1359
  errorLog(...log: any[]): void {
1362
1360
  if (this.enablingDeviceLogging()) {
1363
1361
  this.platform.log.error(String(...log));
1364
1362
  }
1365
1363
  }
1366
1364
 
1365
+ debugErrorLog(...log: any[]): void {
1366
+ if (this.enablingDeviceLogging()) {
1367
+ if (this.deviceLogging?.includes('debug')) {
1368
+ this.platform.log.error('[DEBUG]', String(...log));
1369
+ }
1370
+ }
1371
+ }
1372
+
1367
1373
  debugLog(...log: any[]): void {
1368
1374
  if (this.enablingDeviceLogging()) {
1369
1375
  if (this.deviceLogging === 'debug') {
@@ -225,7 +225,7 @@ export class ColorBulb {
225
225
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
226
226
  await this.openAPIparseStatus();
227
227
  } else {
228
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
228
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
229
229
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
230
230
  }
231
231
  }
@@ -300,7 +300,7 @@ export class ColorBulb {
300
300
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
301
301
  await this.openAPIRefreshStatus();
302
302
  } else {
303
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
303
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
304
304
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
305
305
  }
306
306
  }
@@ -326,12 +326,8 @@ export class ColorBulb {
326
326
  // Set an event hander
327
327
  switchbot.onadvertisement = (ad: any) => {
328
328
  this.address = ad.address;
329
- if (this.deviceLogging.includes('debug')) {
330
- this.infoLog(this.address);
331
- this.infoLog(this.device.bleMac);
332
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
333
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
334
- }
329
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
330
+ + ` BLE Address Found: ${this.address}`);
335
331
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
336
332
  this.serviceData = ad.serviceData;
337
333
  //this.state = ad.serviceData.state;
@@ -453,7 +449,7 @@ export class ColorBulb {
453
449
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
454
450
  await this.openAPIpushChanges();
455
451
  } else {
456
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
452
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
457
453
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
458
454
  }
459
455
  interval(5000)
@@ -761,7 +757,11 @@ export class ColorBulb {
761
757
  * Handle requests to set the value of the "On" characteristic
762
758
  */
763
759
  async OnSet(value: CharacteristicValue): Promise<void> {
764
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
760
+ if (this.On === this.accessory.context.On) {
761
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set On: ${value}`);
762
+ } else {
763
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
764
+ }
765
765
 
766
766
  this.On = value;
767
767
  this.doColorBulbUpdate.next();
@@ -771,7 +771,9 @@ export class ColorBulb {
771
771
  * Handle requests to set the value of the "Brightness" characteristic
772
772
  */
773
773
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
774
- if (this.On) {
774
+ if (this.Brightness === this.accessory.context.Brightness) {
775
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Brightness: ${value}`);
776
+ } else if (this.On) {
775
777
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
776
778
  } else {
777
779
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
@@ -785,7 +787,9 @@ export class ColorBulb {
785
787
  * Handle requests to set the value of the "ColorTemperature" characteristic
786
788
  */
787
789
  async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
788
- if (this.On) {
790
+ if (this.ColorTemperature === this.accessory.context.ColorTemperature) {
791
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set ColorTemperature: ${value}`);
792
+ } else if (this.On) {
789
793
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
790
794
  } else {
791
795
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
@@ -814,7 +818,9 @@ export class ColorBulb {
814
818
  * Handle requests to set the value of the "Hue" characteristic
815
819
  */
816
820
  async HueSet(value: CharacteristicValue): Promise<void> {
817
- if (this.On) {
821
+ if (this.Hue === this.accessory.context.Hue) {
822
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Hue: ${value}`);
823
+ } else if (this.On) {
818
824
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
819
825
  } else {
820
826
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
@@ -830,7 +836,9 @@ export class ColorBulb {
830
836
  * Handle requests to set the value of the "Saturation" characteristic
831
837
  */
832
838
  async SaturationSet(value: CharacteristicValue): Promise<void> {
833
- if (this.On) {
839
+ if (this.Saturation === this.accessory.context.Saturation) {
840
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Saturation: ${value}`);
841
+ } else if (this.On) {
834
842
  this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
835
843
  } else {
836
844
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
@@ -910,7 +918,7 @@ export class ColorBulb {
910
918
  }
911
919
 
912
920
  async BLEPushConnection() {
913
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
921
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
914
922
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
915
923
  await this.openAPIpushChanges();
916
924
  }
@@ -918,7 +926,7 @@ export class ColorBulb {
918
926
 
919
927
  async BLERefreshConnection(switchbot: any): Promise<void> {
920
928
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
921
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
929
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
922
930
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
923
931
  await this.openAPIRefreshStatus();
924
932
  }
@@ -1147,12 +1155,28 @@ export class ColorBulb {
1147
1155
  }
1148
1156
  }
1149
1157
 
1158
+ debugWarnLog(...log: any[]): void {
1159
+ if (this.enablingDeviceLogging()) {
1160
+ if (this.deviceLogging?.includes('debug')) {
1161
+ this.platform.log.warn('[DEBUG]', String(...log));
1162
+ }
1163
+ }
1164
+ }
1165
+
1150
1166
  errorLog(...log: any[]): void {
1151
1167
  if (this.enablingDeviceLogging()) {
1152
1168
  this.platform.log.error(String(...log));
1153
1169
  }
1154
1170
  }
1155
1171
 
1172
+ debugErrorLog(...log: any[]): void {
1173
+ if (this.enablingDeviceLogging()) {
1174
+ if (this.deviceLogging?.includes('debug')) {
1175
+ this.platform.log.error('[DEBUG]', String(...log));
1176
+ }
1177
+ }
1178
+ }
1179
+
1156
1180
  debugLog(...log: any[]): void {
1157
1181
  if (this.enablingDeviceLogging()) {
1158
1182
  if (this.deviceLogging === 'debug') {
@@ -168,7 +168,7 @@ export class Contact {
168
168
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
169
169
  await this.openAPIparseStatus();
170
170
  } else {
171
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
171
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
172
172
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
173
173
  }
174
174
  }
@@ -266,7 +266,7 @@ export class Contact {
266
266
  } else if (this.OpenAPI) {
267
267
  await this.openAPIRefreshStatus();
268
268
  } else {
269
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
269
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
270
270
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
271
271
  }
272
272
  }
@@ -294,12 +294,8 @@ export class Contact {
294
294
  // Set an event hander
295
295
  switchbot.onadvertisement = (ad: any) => {
296
296
  this.address = ad.address;
297
- if (this.deviceLogging.includes('debug')) {
298
- this.infoLog(this.address);
299
- this.infoLog(this.device.bleMac);
300
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
301
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
302
- }
297
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
298
+ + ` BLE Address Found: ${this.address}`);
303
299
  this.serviceData = ad.serviceData;
304
300
  this.movement = ad.serviceData.movement;
305
301
  this.doorState = ad.serviceData.doorState;
@@ -466,7 +462,7 @@ export class Contact {
466
462
 
467
463
  async BLERefreshConnection(switchbot: any): Promise<void> {
468
464
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
469
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
465
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
470
466
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
471
467
  await this.openAPIRefreshStatus();
472
468
  }
@@ -655,12 +651,28 @@ export class Contact {
655
651
  }
656
652
  }
657
653
 
654
+ debugWarnLog(...log: any[]): void {
655
+ if (this.enablingDeviceLogging()) {
656
+ if (this.deviceLogging?.includes('debug')) {
657
+ this.platform.log.warn('[DEBUG]', String(...log));
658
+ }
659
+ }
660
+ }
661
+
658
662
  errorLog(...log: any[]): void {
659
663
  if (this.enablingDeviceLogging()) {
660
664
  this.platform.log.error(String(...log));
661
665
  }
662
666
  }
663
667
 
668
+ debugErrorLog(...log: any[]): void {
669
+ if (this.enablingDeviceLogging()) {
670
+ if (this.deviceLogging?.includes('debug')) {
671
+ this.platform.log.error('[DEBUG]', String(...log));
672
+ }
673
+ }
674
+ }
675
+
664
676
  debugLog(...log: any[]): void {
665
677
  if (this.enablingDeviceLogging()) {
666
678
  if (this.deviceLogging === 'debug') {
@@ -219,7 +219,7 @@ export class Curtain {
219
219
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
220
220
  await this.openAPIparseStatus();
221
221
  } else {
222
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
222
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
223
223
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
224
224
  }
225
225
  }
@@ -391,7 +391,7 @@ export class Curtain {
391
391
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
392
392
  await this.openAPIRefreshStatus();
393
393
  } else {
394
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
394
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
395
395
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
396
396
  }
397
397
  }
@@ -417,12 +417,8 @@ export class Curtain {
417
417
  // Set an event hander
418
418
  switchbot.onadvertisement = (ad: any) => {
419
419
  this.address = ad.address;
420
- if (this.deviceLogging.includes('debug')) {
421
- this.infoLog(this.address);
422
- this.infoLog(this.device.bleMac);
423
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
424
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
425
- }
420
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
421
+ + ` BLE Address Found: ${this.address}`);
426
422
  this.serviceData = ad.serviceData;
427
423
  this.calibration = ad.serviceData.calibration;
428
424
  this.battery = ad.serviceData.battery;
@@ -526,7 +522,7 @@ export class Curtain {
526
522
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
527
523
  await this.openAPIpushChanges();
528
524
  } else {
529
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
525
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
530
526
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
531
527
  }
532
528
  interval(this.updateRate * 1000)
@@ -658,7 +654,11 @@ export class Curtain {
658
654
  * Handle requests to set the value of the "Target Position" characteristic
659
655
  */
660
656
  async TargetPositionSet(value: CharacteristicValue): Promise<void> {
661
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
657
+ if (this.TargetPosition === this.accessory.context.TargetPosition) {
658
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set TargetPosition: ${value}`);
659
+ } else {
660
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetPosition: ${value}`);
661
+ }
662
662
 
663
663
  this.TargetPosition = value;
664
664
  this.mqttPublish('TargetPosition', this.TargetPosition);
@@ -803,7 +803,7 @@ export class Curtain {
803
803
  }
804
804
 
805
805
  async BLEPushConnection() {
806
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
806
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
807
807
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
808
808
  await this.openAPIpushChanges();
809
809
  }
@@ -811,7 +811,7 @@ export class Curtain {
811
811
 
812
812
  async BLERefreshConnection(switchbot: any): Promise<void> {
813
813
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
814
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
814
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
815
815
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
816
816
  await this.openAPIRefreshStatus();
817
817
  }
@@ -1066,12 +1066,28 @@ export class Curtain {
1066
1066
  }
1067
1067
  }
1068
1068
 
1069
+ debugWarnLog(...log: any[]): void {
1070
+ if (this.enablingDeviceLogging()) {
1071
+ if (this.deviceLogging?.includes('debug')) {
1072
+ this.platform.log.warn('[DEBUG]', String(...log));
1073
+ }
1074
+ }
1075
+ }
1076
+
1069
1077
  errorLog(...log: any[]): void {
1070
1078
  if (this.enablingDeviceLogging()) {
1071
1079
  this.platform.log.error(String(...log));
1072
1080
  }
1073
1081
  }
1074
1082
 
1083
+ debugErrorLog(...log: any[]): void {
1084
+ if (this.enablingDeviceLogging()) {
1085
+ if (this.deviceLogging?.includes('debug')) {
1086
+ this.platform.log.error('[DEBUG]', String(...log));
1087
+ }
1088
+ }
1089
+ }
1090
+
1075
1091
  debugLog(...log: any[]): void {
1076
1092
  if (this.enablingDeviceLogging()) {
1077
1093
  if (this.deviceLogging === 'debug') {
@@ -197,7 +197,7 @@ export class Humidifier {
197
197
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
198
198
  await this.openAPIparseStatus();
199
199
  } else {
200
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
200
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
201
201
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
202
202
  }
203
203
  }
@@ -284,7 +284,7 @@ export class Humidifier {
284
284
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
285
285
  await this.openAPIRefreshStatus();
286
286
  } else {
287
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
287
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
288
288
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
289
289
  }
290
290
  }
@@ -310,12 +310,8 @@ export class Humidifier {
310
310
  // Set an event hander
311
311
  switchbot.onadvertisement = (ad: ad) => {
312
312
  this.address = ad.address;
313
- if (this.deviceLogging.includes('debug')) {
314
- this.infoLog(this.address);
315
- this.infoLog(this.device.bleMac);
316
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
317
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
318
- }
313
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
314
+ + ` BLE Address Found: ${this.address}`);
319
315
  this.serviceData = ad.serviceData;
320
316
  this.autoMode = ad.serviceData.autoMode;
321
317
  this.onState = ad.serviceData.onState;
@@ -424,7 +420,7 @@ export class Humidifier {
424
420
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
425
421
  await this.openAPIpushChanges();
426
422
  } else {
427
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
423
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
428
424
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
429
425
  }
430
426
  interval(5000)
@@ -651,22 +647,30 @@ export class Humidifier {
651
647
  }
652
648
 
653
649
  /**
654
- * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
650
+ * Handle requests to set the "Active" characteristic
655
651
  */
656
- async TargetHumidifierDehumidifierStateSet(value: CharacteristicValue): Promise<void> {
657
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
652
+ async ActiveSet(value: CharacteristicValue): Promise<void> {
653
+ if (this.Active === this.accessory.context.Active) {
654
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Active: ${value}`);
655
+ } else {
656
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
657
+ }
658
658
 
659
- this.TargetHumidifierDehumidifierState = value;
659
+ this.Active = value;
660
660
  this.doHumidifierUpdate.next();
661
661
  }
662
662
 
663
663
  /**
664
- * Handle requests to set the "Active" characteristic
664
+ * Handle requests to set the "Target Humidifier Dehumidifier State" characteristic
665
665
  */
666
- async ActiveSet(value: CharacteristicValue): Promise<void> {
667
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Active: ${value}`);
666
+ async TargetHumidifierDehumidifierStateSet(value: CharacteristicValue): Promise<void> {
667
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
668
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
669
+ } else {
670
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set TargetHumidifierDehumidifierState: ${value}`);
671
+ }
668
672
 
669
- this.Active = value;
673
+ this.TargetHumidifierDehumidifierState = value;
670
674
  this.doHumidifierUpdate.next();
671
675
  }
672
676
 
@@ -674,7 +678,11 @@ export class Humidifier {
674
678
  * Handle requests to set the "Relative Humidity Humidifier Threshold" characteristic
675
679
  */
676
680
  async RelativeHumidityHumidifierThresholdSet(value: CharacteristicValue): Promise<void> {
677
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
681
+ if (this.Active === this.platform.Characteristic.Active.ACTIVE) {
682
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
683
+ } else {
684
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set RelativeHumidityHumidifierThreshold: ${value}`);
685
+ }
678
686
 
679
687
  this.RelativeHumidityHumidifierThreshold = value;
680
688
  if (this.Active === this.platform.Characteristic.Active.INACTIVE) {
@@ -773,7 +781,7 @@ export class Humidifier {
773
781
  }
774
782
 
775
783
  async BLEPushConnection() {
776
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
784
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
777
785
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
778
786
  await this.openAPIpushChanges();
779
787
  }
@@ -781,7 +789,7 @@ export class Humidifier {
781
789
 
782
790
  async BLERefreshConnection(switchbot: any): Promise<void> {
783
791
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
784
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
792
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
785
793
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
786
794
  await this.openAPIRefreshStatus();
787
795
  }
@@ -985,12 +993,28 @@ export class Humidifier {
985
993
  }
986
994
  }
987
995
 
996
+ debugWarnLog(...log: any[]): void {
997
+ if (this.enablingDeviceLogging()) {
998
+ if (this.deviceLogging?.includes('debug')) {
999
+ this.platform.log.warn('[DEBUG]', String(...log));
1000
+ }
1001
+ }
1002
+ }
1003
+
988
1004
  errorLog(...log: any[]): void {
989
1005
  if (this.enablingDeviceLogging()) {
990
1006
  this.platform.log.error(String(...log));
991
1007
  }
992
1008
  }
993
1009
 
1010
+ debugErrorLog(...log: any[]): void {
1011
+ if (this.enablingDeviceLogging()) {
1012
+ if (this.deviceLogging?.includes('debug')) {
1013
+ this.platform.log.error('[DEBUG]', String(...log));
1014
+ }
1015
+ }
1016
+ }
1017
+
994
1018
  debugLog(...log: any[]): void {
995
1019
  if (this.enablingDeviceLogging()) {
996
1020
  if (this.deviceLogging === 'debug') {
@@ -137,7 +137,7 @@ export class Lock {
137
137
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
138
138
  await this.openAPIparseStatus();
139
139
  } else {
140
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
140
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
141
141
  + ` ${this.device.connectionType}, parseStatus will not happen.`);
142
142
  }
143
143
  }
@@ -195,7 +195,7 @@ export class Lock {
195
195
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
196
196
  await this.openAPIRefreshStatus();
197
197
  } else {
198
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
198
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
199
199
  + ` ${this.device.connectionType}, refreshStatus will not happen.`);
200
200
  }
201
201
  }
@@ -265,7 +265,7 @@ export class Lock {
265
265
  } else*/ if (this.OpenAPI && this.platform.config.credentials?.token) {
266
266
  await this.openAPIpushChanges();
267
267
  } else {
268
- this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
268
+ this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
269
269
  + ` ${this.device.connectionType}, pushChanges will not happen.`);
270
270
  }
271
271
  interval(5000)
@@ -380,7 +380,11 @@ export class Lock {
380
380
  * Handle requests to set the value of the "On" characteristic
381
381
  */
382
382
  async LockTargetStateSet(value: CharacteristicValue): Promise<void> {
383
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
383
+ if (this.LockTargetState === this.accessory.context.LockTargetState) {
384
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set LockTargetState: ${value}`);
385
+ } else {
386
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set LockTargetState: ${value}`);
387
+ }
384
388
 
385
389
  this.LockTargetState = value;
386
390
  this.doLockUpdate.next();
@@ -413,7 +417,7 @@ export class Lock {
413
417
  }
414
418
 
415
419
  async BLEPushConnection() {
416
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
420
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
417
421
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
418
422
  await this.openAPIpushChanges();
419
423
  }
@@ -421,7 +425,7 @@ export class Lock {
421
425
 
422
426
  async BLERefreshConnection(switchbot: any): Promise<void> {
423
427
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
424
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
428
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
425
429
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
426
430
  await this.openAPIRefreshStatus();
427
431
  }
@@ -577,12 +581,28 @@ export class Lock {
577
581
  }
578
582
  }
579
583
 
584
+ debugWarnLog(...log: any[]): void {
585
+ if (this.enablingDeviceLogging()) {
586
+ if (this.deviceLogging?.includes('debug')) {
587
+ this.platform.log.warn('[DEBUG]', String(...log));
588
+ }
589
+ }
590
+ }
591
+
580
592
  errorLog(...log: any[]): void {
581
593
  if (this.enablingDeviceLogging()) {
582
594
  this.platform.log.error(String(...log));
583
595
  }
584
596
  }
585
597
 
598
+ debugErrorLog(...log: any[]): void {
599
+ if (this.enablingDeviceLogging()) {
600
+ if (this.deviceLogging?.includes('debug')) {
601
+ this.platform.log.error('[DEBUG]', String(...log));
602
+ }
603
+ }
604
+ }
605
+
586
606
  debugLog(...log: any[]): void {
587
607
  if (this.enablingDeviceLogging()) {
588
608
  if (this.deviceLogging === 'debug') {