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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge SwitchBot",
3
3
  "name": "@switchbot/homebridge-switchbot",
4
- "version": "2.0.0-beta.24",
4
+ "version": "2.0.0-beta.26",
5
5
  "description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
6
6
  "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
7
7
  "license": "ISC",
@@ -771,7 +771,11 @@ 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
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
774
+ if (this.On) {
775
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
776
+ } else {
777
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
778
+ }
775
779
 
776
780
  this.Brightness = value;
777
781
  this.doColorBulbUpdate.next();
@@ -781,7 +785,11 @@ export class ColorBulb {
781
785
  * Handle requests to set the value of the "ColorTemperature" characteristic
782
786
  */
783
787
  async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
784
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
788
+ if (this.On) {
789
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
790
+ } else {
791
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set ColorTemperature: ${value}`);
792
+ }
785
793
 
786
794
  // Convert mired to kelvin to nearest 100 (SwitchBot seems to need this)
787
795
  const kelvin = Math.round(1000000 / Number(value) / 100) * 100;
@@ -806,7 +814,11 @@ export class ColorBulb {
806
814
  * Handle requests to set the value of the "Hue" characteristic
807
815
  */
808
816
  async HueSet(value: CharacteristicValue): Promise<void> {
809
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
817
+ if (this.On) {
818
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
819
+ } else {
820
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
821
+ }
810
822
 
811
823
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
812
824
 
@@ -818,7 +830,11 @@ export class ColorBulb {
818
830
  * Handle requests to set the value of the "Saturation" characteristic
819
831
  */
820
832
  async SaturationSet(value: CharacteristicValue): Promise<void> {
821
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
833
+ if (this.On) {
834
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
835
+ } else {
836
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
837
+ }
822
838
 
823
839
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
824
840
 
@@ -693,7 +693,11 @@ export class StripLight {
693
693
  * Handle requests to set the value of the "Brightness" characteristic
694
694
  */
695
695
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
696
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
696
+ if (this.On) {
697
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
698
+ } else {
699
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Brightness: ${value}`);
700
+ }
697
701
 
698
702
  this.Brightness = value;
699
703
  this.doStripLightUpdate.next();
@@ -703,7 +707,11 @@ export class StripLight {
703
707
  * Handle requests to set the value of the "ColorTemperature" characteristic
704
708
  */
705
709
  async ColorTemperatureSet(value: CharacteristicValue): Promise<void> {
706
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
710
+ if (this.On) {
711
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
712
+ } else {
713
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ColorTemperature: ${value}`);
714
+ }
707
715
 
708
716
  // Convert mired to kelvin to nearest 100 (SwitchBot seems to need this)
709
717
  const kelvin = Math.round(1000000 / Number(value) / 100) * 100;
@@ -728,9 +736,13 @@ export class StripLight {
728
736
  * Handle requests to set the value of the "Hue" characteristic
729
737
  */
730
738
  async HueSet(value: CharacteristicValue): Promise<void> {
731
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
739
+ if (this.On) {
740
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
741
+ } else {
742
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Hue: ${value}`);
743
+ }
732
744
 
733
- //this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
745
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
734
746
 
735
747
  this.Hue = value;
736
748
  this.doStripLightUpdate.next();
@@ -740,9 +752,13 @@ export class StripLight {
740
752
  * Handle requests to set the value of the "Saturation" characteristic
741
753
  */
742
754
  async SaturationSet(value: CharacteristicValue): Promise<void> {
743
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
755
+ if (this.On) {
756
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
757
+ } else {
758
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Set Saturation: ${value}`);
759
+ }
744
760
 
745
- //this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
761
+ this.lightBulbService.updateCharacteristic(this.platform.Characteristic.ColorTemperature, 140);
746
762
 
747
763
  this.Saturation = value;
748
764
  this.doStripLightUpdate.next();
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 {
@@ -393,7 +393,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
393
393
  }*/
394
394
  const irDeviceBodyList = devicesAPI.body.infraredRemoteList;
395
395
  let irDeviceLists: any[];
396
-
397
396
  if (irDeviceBodyList) {
398
397
  if (irDeviceBodyList.length > 1) {
399
398
  irDeviceLists = irDeviceBodyList;
@@ -1763,26 +1762,28 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1763
1762
  device.connectionType = await this.connectionType(device);
1764
1763
  if (!device.hide_device && device.enableCloudService && device.connectionType === 'BLE/OpenAPI') {
1765
1764
  this.registeringDevice = true;
1766
- 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}`);
1767
1766
  } else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
1768
1767
  && device.connectionType === 'BLE') {
1769
1768
  this.registeringDevice = true;
1770
- this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
1769
+ this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled, Connection Type: ${device.connectionType}`);
1771
1770
  } else if (!device.hide_device && device.enableCloudService && device.connectionType === 'OpenAPI') {
1772
1771
  this.registeringDevice = true;
1773
- this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
1772
+ this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled, Connection Type: ${device.connectionType}`);
1774
1773
  } else if (!device.hide_device && device.enableCloudService && device.connectionType === 'Disable') {
1775
1774
  this.registeringDevice = true;
1776
- 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}`);
1777
1777
  } else if (!device.connectionType){
1778
1778
  this.registeringDevice = false;
1779
- 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}`);
1780
1780
  } else if (device.hide_device){
1781
1781
  this.registeringDevice = false;
1782
- 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}`);
1783
1783
  } else {
1784
1784
  this.registeringDevice = false;
1785
- 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}`);
1786
1787
  }
1787
1788
  return this.registeringDevice;
1788
1789
  }