@switchbot/homebridge-switchbot 2.0.0-beta.25 → 2.0.0-beta.27

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 (42) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +4 -10
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/colorbulb.d.ts.map +1 -1
  5. package/dist/device/colorbulb.js +44 -7
  6. package/dist/device/colorbulb.js.map +1 -1
  7. package/dist/device/contact.js +1 -1
  8. package/dist/device/curtain.d.ts.map +1 -1
  9. package/dist/device/curtain.js +8 -3
  10. package/dist/device/curtain.js.map +1 -1
  11. package/dist/device/humidifier.d.ts +4 -4
  12. package/dist/device/humidifier.d.ts.map +1 -1
  13. package/dist/device/humidifier.js +26 -11
  14. package/dist/device/humidifier.js.map +1 -1
  15. package/dist/device/lock.d.ts.map +1 -1
  16. package/dist/device/lock.js +8 -3
  17. package/dist/device/lock.js.map +1 -1
  18. package/dist/device/meter.js +1 -1
  19. package/dist/device/meterplus.js +1 -1
  20. package/dist/device/motion.js +1 -1
  21. package/dist/device/plug.d.ts.map +1 -1
  22. package/dist/device/plug.js +8 -3
  23. package/dist/device/plug.js.map +1 -1
  24. package/dist/device/striplight.d.ts.map +1 -1
  25. package/dist/device/striplight.js +46 -9
  26. package/dist/device/striplight.js.map +1 -1
  27. package/dist/platform.d.ts.map +1 -1
  28. package/dist/platform.js +10 -8
  29. package/dist/platform.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/device/bot.ts +4 -10
  32. package/src/device/colorbulb.ts +35 -7
  33. package/src/device/contact.ts +1 -1
  34. package/src/device/curtain.ts +7 -3
  35. package/src/device/humidifier.ts +23 -11
  36. package/src/device/lock.ts +7 -3
  37. package/src/device/meter.ts +1 -1
  38. package/src/device/meterplus.ts +1 -1
  39. package/src/device/motion.ts +1 -1
  40. package/src/device/plug.ts +7 -3
  41. package/src/device/striplight.ts +37 -9
  42. package/src/platform.ts +10 -8
@@ -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
  }
@@ -491,7 +491,7 @@ export class Meter {
491
491
 
492
492
  async BLERefreshConnection(switchbot: any): Promise<void> {
493
493
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
494
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
494
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
495
495
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
496
496
  await this.openAPIRefreshStatus();
497
497
  }
@@ -490,7 +490,7 @@ export class MeterPlus {
490
490
 
491
491
  async BLERefreshConnection(switchbot: any): Promise<void> {
492
492
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
493
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
493
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
494
494
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
495
495
  await this.openAPIRefreshStatus();
496
496
  }
@@ -407,7 +407,7 @@ export class Motion {
407
407
 
408
408
  async BLERefreshConnection(switchbot: any): Promise<void> {
409
409
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
410
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
410
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
411
411
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
412
412
  await this.openAPIRefreshStatus();
413
413
  }
@@ -436,7 +436,11 @@ export class Plug {
436
436
  * Handle requests to set the value of the "On" characteristic
437
437
  */
438
438
  async OnSet(value: CharacteristicValue): Promise<void> {
439
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
439
+ if (this.On === this.accessory.context.On) {
440
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set On: ${value}`);
441
+ } else {
442
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
443
+ }
440
444
 
441
445
  this.On = value;
442
446
  this.doPlugUpdate.next();
@@ -479,7 +483,7 @@ export class Plug {
479
483
  }
480
484
 
481
485
  async BLEPushConnection() {
482
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
486
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
483
487
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
484
488
  await this.openAPIpushChanges();
485
489
  }
@@ -487,7 +491,7 @@ export class Plug {
487
491
 
488
492
  async BLERefreshConnection(switchbot: any): Promise<void> {
489
493
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
490
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
494
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
491
495
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
492
496
  await this.openAPIRefreshStatus();
493
497
  }
@@ -683,7 +683,11 @@ export class StripLight {
683
683
  * Handle requests to set the value of the "On" characteristic
684
684
  */
685
685
  async OnSet(value: CharacteristicValue): Promise<void> {
686
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
686
+ if (this.On === this.accessory.context.On) {
687
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set On: ${value}`);
688
+ } else {
689
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set On: ${value}`);
690
+ }
687
691
 
688
692
  this.On = value;
689
693
  this.doStripLightUpdate.next();
@@ -693,7 +697,13 @@ export class StripLight {
693
697
  * Handle requests to set the value of the "Brightness" characteristic
694
698
  */
695
699
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
696
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
700
+ if (this.Brightness === this.accessory.context.Brightness) {
701
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Brightness: ${value}`);
702
+ } else if (this.On) {
703
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
704
+ } else {
705
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
706
+ }
697
707
 
698
708
  this.Brightness = value;
699
709
  this.doStripLightUpdate.next();
@@ -703,7 +713,13 @@ export class StripLight {
703
713
  * Handle requests to set the value of the "ColorTemperature" characteristic
704
714
  */
705
715
  async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
706
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
716
+ if (this.ColorTemperature === this.accessory.context.ColorTemperature) {
717
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set ColorTemperature: ${value}`);
718
+ } else if (this.On) {
719
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
720
+ } else {
721
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
722
+ }
707
723
 
708
724
  // Convert mired to kelvin to nearest 100 (SwitchBot seems to need this)
709
725
  const kelvin = Math.round(1000000 / Number(value) / 100) * 100;
@@ -728,9 +744,15 @@ export class StripLight {
728
744
  * Handle requests to set the value of the "Hue" characteristic
729
745
  */
730
746
  async HueSet(value: CharacteristicValue): Promise<void> {
731
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
747
+ if (this.Hue === this.accessory.context.Hue) {
748
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Hue: ${value}`);
749
+ } else if (this.On) {
750
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
751
+ } else {
752
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
753
+ }
732
754
 
733
- //this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
755
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
734
756
 
735
757
  this.Hue = value;
736
758
  this.doStripLightUpdate.next();
@@ -740,9 +762,15 @@ export class StripLight {
740
762
  * Handle requests to set the value of the "Saturation" characteristic
741
763
  */
742
764
  async SaturationSet(value: CharacteristicValue): Promise<void> {
743
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
765
+ if (this.Saturation === this.accessory.context.Saturation) {
766
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No Changes, Set Saturation: ${value}`);
767
+ } else if (this.On) {
768
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
769
+ } else {
770
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
771
+ }
744
772
 
745
- //this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
773
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
746
774
 
747
775
  this.Saturation = value;
748
776
  this.doStripLightUpdate.next();
@@ -806,7 +834,7 @@ export class StripLight {
806
834
  }
807
835
 
808
836
  async BLEPushConnection() {
809
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
837
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
810
838
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Push Changes`);
811
839
  await this.openAPIpushChanges();
812
840
  }
@@ -814,7 +842,7 @@ export class StripLight {
814
842
 
815
843
  async BLERefreshConnection(switchbot: any): Promise<void> {
816
844
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
817
- if (this.platform.config.credentials?.token && this.device.connectionType !== 'BLE/OpenAPI') {
845
+ if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
818
846
  this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection to Refresh Status`);
819
847
  await this.openAPIRefreshStatus();
820
848
  }
package/src/platform.ts CHANGED
@@ -88,7 +88,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
88
88
  try {
89
89
  if (this.config.credentials?.openToken && !this.config.credentials.token) {
90
90
  await this.updateToken();
91
- } else if (!this.config.credentials?.secret) {
91
+ } else if (this.config.credentials?.token && !this.config.credentials?.secret) {
92
92
  // eslint-disable-next-line no-useless-escape
93
93
  this.errorLog('\"secret\" config is not populated, you must populate then please restart Homebridge.');
94
94
  } else {
@@ -1762,26 +1762,28 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1762
1762
  device.connectionType = await this.connectionType(device);
1763
1763
  if (!device.hide_device && device.enableCloudService && device.connectionType === 'BLE/OpenAPI') {
1764
1764
  this.registeringDevice = true;
1765
- this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
1765
+ this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled, Connection Type: ${device.connectionType}`);
1766
1766
  } else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
1767
1767
  && device.connectionType === 'BLE') {
1768
1768
  this.registeringDevice = true;
1769
- this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
1769
+ this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled, Connection Type: ${device.connectionType}`);
1770
1770
  } else if (!device.hide_device && device.enableCloudService && device.connectionType === 'OpenAPI') {
1771
1771
  this.registeringDevice = true;
1772
- this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
1772
+ this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled, Connection Type: ${device.connectionType}`);
1773
1773
  } else if (!device.hide_device && device.enableCloudService && device.connectionType === 'Disable') {
1774
1774
  this.registeringDevice = true;
1775
- this.debugLog(`Device: ${device.deviceName} Device connection Disabled, will continue to display in HomeKit`);
1775
+ this.debugLog(`Device: ${device.deviceName} Device connection Disabled, will continue to display in HomeKit,`
1776
+ + ` Connection Type: ${device.connectionType}`);
1776
1777
  } else if (!device.connectionType){
1777
1778
  this.registeringDevice = false;
1778
- this.errorLog(`Device: ${device.deviceName} Connection Type not Set, will not display in HomeKit`);
1779
+ this.errorLog(`Device: ${device.deviceName} Connection Type not Set, will not display in HomeKit, Connection Type: ${device.connectionType}`);
1779
1780
  } else if (device.hide_device){
1780
1781
  this.registeringDevice = false;
1781
- this.errorLog(`Device: ${device.deviceName} Device Set to Hidden, will not display in HomeKit`);
1782
+ this.errorLog(`Device: ${device.deviceName} Device Set to Hidden, will not display in HomeKit, hide_device: ${device.hide_device}`);
1782
1783
  } else {
1783
1784
  this.registeringDevice = false;
1784
- this.errorLog(`Device: ${device.deviceName} OpenAPI or BLE Are Not Enabled`);
1785
+ this.errorLog(`Device: ${device.deviceName} OpenAPI or BLE Are Not Enabled, Connection Type: ${device.connectionType},`
1786
+ + ` hide_device: ${device.hide_device}`);
1785
1787
  }
1786
1788
  return this.registeringDevice;
1787
1789
  }