@switchbot/homebridge-switchbot 2.0.0-beta.21 → 2.0.0-beta.22

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 (62) hide show
  1. package/config.schema.json +4 -4
  2. package/dist/device/bot.d.ts +0 -1
  3. package/dist/device/bot.d.ts.map +1 -1
  4. package/dist/device/bot.js +8 -10
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/colorbulb.d.ts +0 -1
  7. package/dist/device/colorbulb.d.ts.map +1 -1
  8. package/dist/device/colorbulb.js +6 -9
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.d.ts +0 -1
  11. package/dist/device/contact.d.ts.map +1 -1
  12. package/dist/device/contact.js +6 -8
  13. package/dist/device/contact.js.map +1 -1
  14. package/dist/device/curtain.d.ts +0 -1
  15. package/dist/device/curtain.d.ts.map +1 -1
  16. package/dist/device/curtain.js +7 -9
  17. package/dist/device/curtain.js.map +1 -1
  18. package/dist/device/humidifier.d.ts +0 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +7 -9
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/lock.d.ts +1 -0
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +26 -7
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/meter.d.ts +0 -1
  27. package/dist/device/meter.d.ts.map +1 -1
  28. package/dist/device/meter.js +6 -8
  29. package/dist/device/meter.js.map +1 -1
  30. package/dist/device/meterplus.d.ts +0 -1
  31. package/dist/device/meterplus.d.ts.map +1 -1
  32. package/dist/device/meterplus.js +4 -6
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts +0 -1
  35. package/dist/device/motion.d.ts.map +1 -1
  36. package/dist/device/motion.js +6 -8
  37. package/dist/device/motion.js.map +1 -1
  38. package/dist/device/plug.d.ts +0 -1
  39. package/dist/device/plug.d.ts.map +1 -1
  40. package/dist/device/plug.js +7 -9
  41. package/dist/device/plug.js.map +1 -1
  42. package/dist/device/striplight.d.ts +2 -1
  43. package/dist/device/striplight.d.ts.map +1 -1
  44. package/dist/device/striplight.js +73 -68
  45. package/dist/device/striplight.js.map +1 -1
  46. package/dist/platform.d.ts +2 -3
  47. package/dist/platform.d.ts.map +1 -1
  48. package/dist/platform.js +68 -70
  49. package/dist/platform.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/device/bot.ts +8 -11
  52. package/src/device/colorbulb.ts +6 -10
  53. package/src/device/contact.ts +6 -9
  54. package/src/device/curtain.ts +7 -10
  55. package/src/device/humidifier.ts +7 -10
  56. package/src/device/lock.ts +27 -7
  57. package/src/device/meter.ts +6 -9
  58. package/src/device/meterplus.ts +4 -7
  59. package/src/device/motion.ts +6 -9
  60. package/src/device/plug.ts +7 -10
  61. package/src/device/striplight.ts +33 -24
  62. package/src/platform.ts +68 -71
package/dist/platform.js CHANGED
@@ -587,7 +587,7 @@ class SwitchBotPlatform {
587
587
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
588
588
  if (existingAccessory) {
589
589
  // the accessory already exists
590
- if (this.registerDevice(device)) {
590
+ if (await this.registerDevice(device)) {
591
591
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
592
592
  existingAccessory.context.model = device.deviceType;
593
593
  existingAccessory.context.deviceID = device.deviceId;
@@ -595,7 +595,7 @@ class SwitchBotPlatform {
595
595
  existingAccessory.context.firmwareRevision = device.firmware;
596
596
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
597
597
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
598
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
598
+ existingAccessory.context.connectionType = await this.connectionType(device);
599
599
  this.api.updatePlatformAccessories([existingAccessory]);
600
600
  // create the accessory handler for the restored accessory
601
601
  // this is imported from `platformAccessory.ts`
@@ -606,7 +606,7 @@ class SwitchBotPlatform {
606
606
  this.unregisterPlatformAccessories(existingAccessory);
607
607
  }
608
608
  }
609
- else if (this.registerDevice(device)) {
609
+ else if (await this.registerDevice(device)) {
610
610
  // the accessory does not yet exist, so we need to create it
611
611
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
612
612
  // create a new accessory
@@ -618,7 +618,7 @@ class SwitchBotPlatform {
618
618
  accessory.context.deviceID = device.deviceId;
619
619
  accessory.context.firmwareRevision = device.firmware;
620
620
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
621
- accessory.context.connectionType = await this.connectionTypeNew(device);
621
+ accessory.context.connectionType = await this.connectionType(device);
622
622
  // create the accessory handler for the newly create accessory
623
623
  // this is imported from `platformAccessory.ts`
624
624
  new humidifier_1.Humidifier(this, accessory, device);
@@ -638,7 +638,7 @@ class SwitchBotPlatform {
638
638
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
639
639
  if (existingAccessory) {
640
640
  // the accessory already exists
641
- if (this.registerDevice(device)) {
641
+ if (await this.registerDevice(device)) {
642
642
  this.debugLog((0, super_stringify_1.default)(device.bot?.mode));
643
643
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
644
644
  existingAccessory.context.model = device.deviceType;
@@ -647,7 +647,7 @@ class SwitchBotPlatform {
647
647
  existingAccessory.context.firmwareRevision = device.firmware;
648
648
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
649
649
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
650
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
650
+ existingAccessory.context.connectionType = await this.connectionType(device);
651
651
  this.api.updatePlatformAccessories([existingAccessory]);
652
652
  // create the accessory handler for the restored accessory
653
653
  // this is imported from `platformAccessory.ts`
@@ -658,7 +658,7 @@ class SwitchBotPlatform {
658
658
  this.unregisterPlatformAccessories(existingAccessory);
659
659
  }
660
660
  }
661
- else if (this.registerDevice(device)) {
661
+ else if (await this.registerDevice(device)) {
662
662
  // the accessory does not yet exist, so we need to create it
663
663
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
664
664
  this.debugLog((0, super_stringify_1.default)(device.bot?.mode));
@@ -671,7 +671,7 @@ class SwitchBotPlatform {
671
671
  accessory.context.deviceID = device.deviceId;
672
672
  accessory.context.firmwareRevision = device.firmware;
673
673
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
674
- accessory.context.connectionType = await this.connectionTypeNew(device);
674
+ accessory.context.connectionType = await this.connectionType(device);
675
675
  // accessory.context.firmwareRevision = findaccessories.accessoryAttribute.softwareRevision;
676
676
  // create the accessory handler for the newly create accessory
677
677
  // this is imported from `platformAccessory.ts`
@@ -692,7 +692,7 @@ class SwitchBotPlatform {
692
692
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
693
693
  if (existingAccessory) {
694
694
  // the accessory already exists
695
- if (this.registerDevice(device)) {
695
+ if (await this.registerDevice(device)) {
696
696
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
697
697
  existingAccessory.context.model = device.deviceType;
698
698
  existingAccessory.context.deviceID = device.deviceId;
@@ -700,7 +700,7 @@ class SwitchBotPlatform {
700
700
  existingAccessory.context.firmwareRevision = device.firmware;
701
701
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
702
702
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
703
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
703
+ existingAccessory.context.connectionType = await this.connectionType(device);
704
704
  this.api.updatePlatformAccessories([existingAccessory]);
705
705
  // create the accessory handler for the restored accessory
706
706
  // this is imported from `platformAccessory.ts`
@@ -711,7 +711,7 @@ class SwitchBotPlatform {
711
711
  this.unregisterPlatformAccessories(existingAccessory);
712
712
  }
713
713
  }
714
- else if (this.registerDevice(device)) {
714
+ else if (await this.registerDevice(device)) {
715
715
  // the accessory does not yet exist, so we need to create it
716
716
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
717
717
  // create a new accessory
@@ -723,7 +723,7 @@ class SwitchBotPlatform {
723
723
  accessory.context.deviceID = device.deviceId;
724
724
  accessory.context.firmwareRevision = device.firmware;
725
725
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
726
- accessory.context.connectionType = await this.connectionTypeNew(device);
726
+ accessory.context.connectionType = await this.connectionType(device);
727
727
  // create the accessory handler for the newly create accessory
728
728
  // this is imported from `platformAccessory.ts`
729
729
  new meter_1.Meter(this, accessory, device);
@@ -743,7 +743,7 @@ class SwitchBotPlatform {
743
743
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
744
744
  if (existingAccessory) {
745
745
  // the accessory already exists
746
- if (this.registerDevice(device)) {
746
+ if (await this.registerDevice(device)) {
747
747
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
748
748
  existingAccessory.context.model = device.deviceType;
749
749
  existingAccessory.context.deviceID = device.deviceId;
@@ -751,7 +751,7 @@ class SwitchBotPlatform {
751
751
  existingAccessory.context.firmwareRevision = device.firmware;
752
752
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
753
753
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
754
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
754
+ existingAccessory.context.connectionType = await this.connectionType(device);
755
755
  this.api.updatePlatformAccessories([existingAccessory]);
756
756
  // create the accessory handler for the restored accessory
757
757
  // this is imported from `platformAccessory.ts`
@@ -762,7 +762,7 @@ class SwitchBotPlatform {
762
762
  this.unregisterPlatformAccessories(existingAccessory);
763
763
  }
764
764
  }
765
- else if (this.registerDevice(device)) {
765
+ else if (await this.registerDevice(device)) {
766
766
  // the accessory does not yet exist, so we need to create it
767
767
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
768
768
  // create a new accessory
@@ -774,7 +774,7 @@ class SwitchBotPlatform {
774
774
  accessory.context.deviceID = device.deviceId;
775
775
  accessory.context.firmwareRevision = device.firmware;
776
776
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
777
- accessory.context.connectionType = await this.connectionTypeNew(device);
777
+ accessory.context.connectionType = await this.connectionType(device);
778
778
  // create the accessory handler for the newly create accessory
779
779
  // this is imported from `platformAccessory.ts`
780
780
  new meterplus_1.MeterPlus(this, accessory, device);
@@ -794,7 +794,7 @@ class SwitchBotPlatform {
794
794
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
795
795
  if (existingAccessory) {
796
796
  // the accessory already exists
797
- if (this.registerDevice(device)) {
797
+ if (await this.registerDevice(device)) {
798
798
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
799
799
  existingAccessory.context.model = device.deviceType;
800
800
  existingAccessory.context.deviceID = device.deviceId;
@@ -802,7 +802,7 @@ class SwitchBotPlatform {
802
802
  existingAccessory.context.firmwareRevision = device.firmware;
803
803
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
804
804
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
805
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
805
+ existingAccessory.context.connectionType = await this.connectionType(device);
806
806
  this.api.updatePlatformAccessories([existingAccessory]);
807
807
  // create the accessory handler for the restored accessory
808
808
  // this is imported from `platformAccessory.ts`
@@ -813,7 +813,7 @@ class SwitchBotPlatform {
813
813
  this.unregisterPlatformAccessories(existingAccessory);
814
814
  }
815
815
  }
816
- else if (this.registerDevice(device)) {
816
+ else if (await this.registerDevice(device)) {
817
817
  // the accessory does not yet exist, so we need to create it
818
818
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
819
819
  // create a new accessory
@@ -825,7 +825,7 @@ class SwitchBotPlatform {
825
825
  accessory.context.deviceID = device.deviceId;
826
826
  accessory.context.firmwareRevision = device.firmware;
827
827
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
828
- accessory.context.connectionType = await this.connectionTypeNew(device);
828
+ accessory.context.connectionType = await this.connectionType(device);
829
829
  // create the accessory handler for the newly create accessory
830
830
  // this is imported from `platformAccessory.ts`
831
831
  new motion_1.Motion(this, accessory, device);
@@ -845,7 +845,7 @@ class SwitchBotPlatform {
845
845
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
846
846
  if (existingAccessory) {
847
847
  // the accessory already exists
848
- if (this.registerDevice(device)) {
848
+ if (await this.registerDevice(device)) {
849
849
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
850
850
  existingAccessory.context.model = device.deviceType;
851
851
  existingAccessory.context.deviceID = device.deviceId;
@@ -853,7 +853,7 @@ class SwitchBotPlatform {
853
853
  existingAccessory.context.firmwareRevision = device.firmware;
854
854
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
855
855
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
856
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
856
+ existingAccessory.context.connectionType = await this.connectionType(device);
857
857
  this.api.updatePlatformAccessories([existingAccessory]);
858
858
  // create the accessory handler for the restored accessory
859
859
  // this is imported from `platformAccessory.ts`
@@ -864,7 +864,7 @@ class SwitchBotPlatform {
864
864
  this.unregisterPlatformAccessories(existingAccessory);
865
865
  }
866
866
  }
867
- else if (this.registerDevice(device)) {
867
+ else if (await this.registerDevice(device)) {
868
868
  // the accessory does not yet exist, so we need to create it
869
869
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
870
870
  // create a new accessory
@@ -876,7 +876,7 @@ class SwitchBotPlatform {
876
876
  accessory.context.deviceID = device.deviceId;
877
877
  accessory.context.firmwareRevision = device.firmware;
878
878
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
879
- accessory.context.connectionType = await this.connectionTypeNew(device);
879
+ accessory.context.connectionType = await this.connectionType(device);
880
880
  // create the accessory handler for the newly create accessory
881
881
  // this is imported from `platformAccessory.ts`
882
882
  new contact_1.Contact(this, accessory, device);
@@ -904,7 +904,7 @@ class SwitchBotPlatform {
904
904
  existingAccessory.context.firmwareRevision = device.firmware;
905
905
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
906
906
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
907
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
907
+ existingAccessory.context.connectionType = await this.connectionType(device);
908
908
  this.api.updatePlatformAccessories([existingAccessory]);
909
909
  // create the accessory handler for the restored accessory
910
910
  // this is imported from `platformAccessory.ts`
@@ -939,7 +939,7 @@ class SwitchBotPlatform {
939
939
  accessory.context.deviceID = device.deviceId;
940
940
  accessory.context.firmwareRevision = device.firmware;
941
941
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
942
- accessory.context.connectionType = await this.connectionTypeNew(device);
942
+ accessory.context.connectionType = await this.connectionType(device);
943
943
  // create the accessory handler for the newly create accessory
944
944
  // this is imported from `platformAccessory.ts`
945
945
  new curtain_1.Curtain(this, accessory, device);
@@ -971,7 +971,7 @@ class SwitchBotPlatform {
971
971
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
972
972
  if (existingAccessory) {
973
973
  // the accessory already exists
974
- if (this.registerDevice(device)) {
974
+ if (await this.registerDevice(device)) {
975
975
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
976
976
  existingAccessory.context.model = device.deviceType;
977
977
  existingAccessory.context.deviceID = device.deviceId;
@@ -979,7 +979,7 @@ class SwitchBotPlatform {
979
979
  existingAccessory.context.firmwareRevision = device.firmware;
980
980
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
981
981
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
982
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
982
+ existingAccessory.context.connectionType = await this.connectionType(device);
983
983
  this.api.updatePlatformAccessories([existingAccessory]);
984
984
  // create the accessory handler for the restored accessory
985
985
  // this is imported from `platformAccessory.ts`
@@ -990,7 +990,7 @@ class SwitchBotPlatform {
990
990
  this.unregisterPlatformAccessories(existingAccessory);
991
991
  }
992
992
  }
993
- else if (this.registerDevice(device)) {
993
+ else if (await this.registerDevice(device)) {
994
994
  // the accessory does not yet exist, so we need to create it
995
995
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
996
996
  // create a new accessory
@@ -1002,7 +1002,7 @@ class SwitchBotPlatform {
1002
1002
  accessory.context.deviceID = device.deviceId;
1003
1003
  accessory.context.firmwareRevision = device.firmware;
1004
1004
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1005
- accessory.context.connectionType = await this.connectionTypeNew(device);
1005
+ accessory.context.connectionType = await this.connectionType(device);
1006
1006
  // create the accessory handler for the newly create accessory
1007
1007
  // this is imported from `platformAccessory.ts`
1008
1008
  new plug_1.Plug(this, accessory, device);
@@ -1022,7 +1022,7 @@ class SwitchBotPlatform {
1022
1022
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1023
1023
  if (existingAccessory) {
1024
1024
  // the accessory already exists
1025
- if (this.registerDevice(device)) {
1025
+ if (await this.registerDevice(device)) {
1026
1026
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1027
1027
  existingAccessory.context.model = device.deviceType;
1028
1028
  existingAccessory.context.deviceID = device.deviceId;
@@ -1030,7 +1030,7 @@ class SwitchBotPlatform {
1030
1030
  existingAccessory.context.firmwareRevision = device.firmware;
1031
1031
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1032
1032
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1033
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1033
+ existingAccessory.context.connectionType = await this.connectionType(device);
1034
1034
  this.api.updatePlatformAccessories([existingAccessory]);
1035
1035
  // create the accessory handler for the restored accessory
1036
1036
  // this is imported from `platformAccessory.ts`
@@ -1041,7 +1041,7 @@ class SwitchBotPlatform {
1041
1041
  this.unregisterPlatformAccessories(existingAccessory);
1042
1042
  }
1043
1043
  }
1044
- else if (this.registerDevice(device)) {
1044
+ else if (await this.registerDevice(device)) {
1045
1045
  // the accessory does not yet exist, so we need to create it
1046
1046
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1047
1047
  // create a new accessory
@@ -1053,7 +1053,7 @@ class SwitchBotPlatform {
1053
1053
  accessory.context.deviceID = device.deviceId;
1054
1054
  accessory.context.firmwareRevision = device.firmware;
1055
1055
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1056
- accessory.context.connectionType = await this.connectionTypeNew(device);
1056
+ accessory.context.connectionType = await this.connectionType(device);
1057
1057
  // create the accessory handler for the newly create accessory
1058
1058
  // this is imported from `platformAccessory.ts`
1059
1059
  new lock_1.Lock(this, accessory, device);
@@ -1073,7 +1073,7 @@ class SwitchBotPlatform {
1073
1073
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1074
1074
  if (existingAccessory) {
1075
1075
  // the accessory already exists
1076
- if (this.registerDevice(device)) {
1076
+ if (await this.registerDevice(device)) {
1077
1077
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1078
1078
  existingAccessory.context.model = device.deviceType;
1079
1079
  existingAccessory.context.deviceID = device.deviceId;
@@ -1081,7 +1081,7 @@ class SwitchBotPlatform {
1081
1081
  existingAccessory.context.firmwareRevision = device.firmware;
1082
1082
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1083
1083
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1084
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1084
+ existingAccessory.context.connectionType = await this.connectionType(device);
1085
1085
  this.api.updatePlatformAccessories([existingAccessory]);
1086
1086
  // create the accessory handler for the restored accessory
1087
1087
  // this is imported from `platformAccessory.ts`
@@ -1092,7 +1092,7 @@ class SwitchBotPlatform {
1092
1092
  this.unregisterPlatformAccessories(existingAccessory);
1093
1093
  }
1094
1094
  }
1095
- else if (this.registerDevice(device)) {
1095
+ else if (await this.registerDevice(device)) {
1096
1096
  // the accessory does not yet exist, so we need to create it
1097
1097
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1098
1098
  // create a new accessory
@@ -1104,7 +1104,7 @@ class SwitchBotPlatform {
1104
1104
  accessory.context.deviceID = device.deviceId;
1105
1105
  accessory.context.firmwareRevision = device.firmware;
1106
1106
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1107
- accessory.context.connectionType = await this.connectionTypeNew(device);
1107
+ accessory.context.connectionType = await this.connectionType(device);
1108
1108
  // create the accessory handler for the newly create accessory
1109
1109
  // this is imported from `platformAccessory.ts`
1110
1110
  new colorbulb_1.ColorBulb(this, accessory, device);
@@ -1124,7 +1124,7 @@ class SwitchBotPlatform {
1124
1124
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1125
1125
  if (existingAccessory) {
1126
1126
  // the accessory already exists
1127
- if (this.registerDevice(device)) {
1127
+ if (await this.registerDevice(device)) {
1128
1128
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1129
1129
  existingAccessory.context.model = device.deviceType;
1130
1130
  existingAccessory.context.deviceID = device.deviceId;
@@ -1132,7 +1132,7 @@ class SwitchBotPlatform {
1132
1132
  existingAccessory.context.firmwareRevision = device.firmware;
1133
1133
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1134
1134
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1135
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1135
+ existingAccessory.context.connectionType = await this.connectionType(device);
1136
1136
  this.api.updatePlatformAccessories([existingAccessory]);
1137
1137
  // create the accessory handler for the restored accessory
1138
1138
  // this is imported from `platformAccessory.ts`
@@ -1143,7 +1143,7 @@ class SwitchBotPlatform {
1143
1143
  this.unregisterPlatformAccessories(existingAccessory);
1144
1144
  }
1145
1145
  }
1146
- else if (this.registerDevice(device)) {
1146
+ else if (await this.registerDevice(device)) {
1147
1147
  // the accessory does not yet exist, so we need to create it
1148
1148
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
1149
1149
  // create a new accessory
@@ -1155,7 +1155,7 @@ class SwitchBotPlatform {
1155
1155
  accessory.context.deviceID = device.deviceId;
1156
1156
  accessory.context.firmwareRevision = device.firmware;
1157
1157
  accessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1158
- accessory.context.connectionType = await this.connectionTypeNew(device);
1158
+ accessory.context.connectionType = await this.connectionType(device);
1159
1159
  // create the accessory handler for the newly create accessory
1160
1160
  // this is imported from `platformAccessory.ts`
1161
1161
  new striplight_1.StripLight(this, accessory, device);
@@ -1181,7 +1181,7 @@ class SwitchBotPlatform {
1181
1181
  existingAccessory.context.firmwareRevision = device.firmware;
1182
1182
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1183
1183
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1184
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1184
+ existingAccessory.context.connectionType = await this.connectionType(device);
1185
1185
  this.api.updatePlatformAccessories([existingAccessory]);
1186
1186
  // create the accessory handler for the restored accessory
1187
1187
  // this is imported from `platformAccessory.ts`
@@ -1200,7 +1200,7 @@ class SwitchBotPlatform {
1200
1200
  accessory.context.deviceID = device.deviceId;
1201
1201
  accessory.context.firmwareRevision = device.firmware;
1202
1202
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1203
- accessory.context.connectionType = await this.connectionTypeNew(device);
1203
+ accessory.context.connectionType = await this.connectionType(device);
1204
1204
  // create the accessory handler for the newly create accessory
1205
1205
  // this is imported from `platformAccessory.ts`
1206
1206
  new tv_1.TV(this, accessory, device);
@@ -1232,7 +1232,7 @@ class SwitchBotPlatform {
1232
1232
  existingAccessory.context.firmwareRevision = device.firmware;
1233
1233
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1234
1234
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1235
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1235
+ existingAccessory.context.connectionType = await this.connectionType(device);
1236
1236
  this.api.updatePlatformAccessories([existingAccessory]);
1237
1237
  // create the accessory handler for the restored accessory
1238
1238
  // this is imported from `platformAccessory.ts`
@@ -1255,7 +1255,7 @@ class SwitchBotPlatform {
1255
1255
  accessory.context.deviceID = device.deviceId;
1256
1256
  accessory.context.firmwareRevision = device.firmware;
1257
1257
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1258
- accessory.context.connectionType = await this.connectionTypeNew(device);
1258
+ accessory.context.connectionType = await this.connectionType(device);
1259
1259
  // create the accessory handler for the newly create accessory
1260
1260
  // this is imported from `platformAccessory.ts`
1261
1261
  new fan_1.Fan(this, accessory, device);
@@ -1283,7 +1283,7 @@ class SwitchBotPlatform {
1283
1283
  existingAccessory.context.firmwareRevision = device.firmware;
1284
1284
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1285
1285
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1286
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1286
+ existingAccessory.context.connectionType = await this.connectionType(device);
1287
1287
  this.api.updatePlatformAccessories([existingAccessory]);
1288
1288
  // create the accessory handler for the restored accessory
1289
1289
  // this is imported from `platformAccessory.ts`
@@ -1306,7 +1306,7 @@ class SwitchBotPlatform {
1306
1306
  accessory.context.deviceID = device.deviceId;
1307
1307
  accessory.context.firmwareRevision = device.firmware;
1308
1308
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1309
- accessory.context.connectionType = await this.connectionTypeNew(device);
1309
+ accessory.context.connectionType = await this.connectionType(device);
1310
1310
  // create the accessory handler for the newly create accessory
1311
1311
  // this is imported from `platformAccessory.ts`
1312
1312
  new light_1.Light(this, accessory, device);
@@ -1334,7 +1334,7 @@ class SwitchBotPlatform {
1334
1334
  existingAccessory.context.firmwareRevision = device.firmware;
1335
1335
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1336
1336
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1337
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1337
+ existingAccessory.context.connectionType = await this.connectionType(device);
1338
1338
  this.api.updatePlatformAccessories([existingAccessory]);
1339
1339
  // create the accessory handler for the restored accessory
1340
1340
  // this is imported from `platformAccessory.ts`
@@ -1357,7 +1357,7 @@ class SwitchBotPlatform {
1357
1357
  accessory.context.deviceID = device.deviceId;
1358
1358
  accessory.context.firmwareRevision = device.firmware;
1359
1359
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1360
- accessory.context.connectionType = await this.connectionTypeNew(device);
1360
+ accessory.context.connectionType = await this.connectionType(device);
1361
1361
  // create the accessory handler for the newly create accessory
1362
1362
  // this is imported from `platformAccessory.ts`
1363
1363
  new airconditioner_1.AirConditioner(this, accessory, device);
@@ -1385,7 +1385,7 @@ class SwitchBotPlatform {
1385
1385
  existingAccessory.context.firmwareRevision = device.firmware;
1386
1386
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1387
1387
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1388
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1388
+ existingAccessory.context.connectionType = await this.connectionType(device);
1389
1389
  this.api.updatePlatformAccessories([existingAccessory]);
1390
1390
  // create the accessory handler for the restored accessory
1391
1391
  // this is imported from `platformAccessory.ts`
@@ -1408,7 +1408,7 @@ class SwitchBotPlatform {
1408
1408
  accessory.context.deviceID = device.deviceId;
1409
1409
  accessory.context.firmwareRevision = device.firmware;
1410
1410
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1411
- accessory.context.connectionType = await this.connectionTypeNew(device);
1411
+ accessory.context.connectionType = await this.connectionType(device);
1412
1412
  // create the accessory handler for the newly create accessory
1413
1413
  // this is imported from `platformAccessory.ts`
1414
1414
  new airpurifier_1.AirPurifier(this, accessory, device);
@@ -1436,7 +1436,7 @@ class SwitchBotPlatform {
1436
1436
  existingAccessory.context.firmwareRevision = device.firmware;
1437
1437
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1438
1438
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1439
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1439
+ existingAccessory.context.connectionType = await this.connectionType(device);
1440
1440
  this.api.updatePlatformAccessories([existingAccessory]);
1441
1441
  // create the accessory handler for the restored accessory
1442
1442
  // this is imported from `platformAccessory.ts`
@@ -1459,7 +1459,7 @@ class SwitchBotPlatform {
1459
1459
  accessory.context.deviceID = device.deviceId;
1460
1460
  accessory.context.firmwareRevision = device.firmware;
1461
1461
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1462
- accessory.context.connectionType = await this.connectionTypeNew(device);
1462
+ accessory.context.connectionType = await this.connectionType(device);
1463
1463
  // create the accessory handler for the newly create accessory
1464
1464
  // this is imported from `platformAccessory.ts`
1465
1465
  new waterheater_1.WaterHeater(this, accessory, device);
@@ -1487,7 +1487,7 @@ class SwitchBotPlatform {
1487
1487
  existingAccessory.context.firmwareRevision = device.firmware;
1488
1488
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1489
1489
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1490
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1490
+ existingAccessory.context.connectionType = await this.connectionType(device);
1491
1491
  this.api.updatePlatformAccessories([existingAccessory]);
1492
1492
  // create the accessory handler for the restored accessory
1493
1493
  // this is imported from `platformAccessory.ts`
@@ -1510,7 +1510,7 @@ class SwitchBotPlatform {
1510
1510
  accessory.context.deviceID = device.deviceId;
1511
1511
  accessory.context.firmwareRevision = device.firmware;
1512
1512
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1513
- accessory.context.connectionType = await this.connectionTypeNew(device);
1513
+ accessory.context.connectionType = await this.connectionType(device);
1514
1514
  // create the accessory handler for the newly create accessory
1515
1515
  // this is imported from `platformAccessory.ts`
1516
1516
  new vacuumcleaner_1.VacuumCleaner(this, accessory, device);
@@ -1538,7 +1538,7 @@ class SwitchBotPlatform {
1538
1538
  existingAccessory.context.firmwareRevision = device.firmware;
1539
1539
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1540
1540
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1541
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1541
+ existingAccessory.context.connectionType = await this.connectionType(device);
1542
1542
  this.api.updatePlatformAccessories([existingAccessory]);
1543
1543
  // create the accessory handler for the restored accessory
1544
1544
  // this is imported from `platformAccessory.ts`
@@ -1561,7 +1561,7 @@ class SwitchBotPlatform {
1561
1561
  accessory.context.deviceID = device.deviceId;
1562
1562
  accessory.context.firmwareRevision = device.firmware;
1563
1563
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1564
- accessory.context.connectionType = await this.connectionTypeNew(device);
1564
+ accessory.context.connectionType = await this.connectionType(device);
1565
1565
  // create the accessory handler for the newly create accessory
1566
1566
  // this is imported from `platformAccessory.ts`
1567
1567
  new camera_1.Camera(this, accessory, device);
@@ -1589,7 +1589,7 @@ class SwitchBotPlatform {
1589
1589
  existingAccessory.context.firmwareRevision = device.firmware;
1590
1590
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1591
1591
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1592
- existingAccessory.context.connectionType = await this.connectionTypeExisting(device);
1592
+ existingAccessory.context.connectionType = await this.connectionType(device);
1593
1593
  this.api.updatePlatformAccessories([existingAccessory]);
1594
1594
  // create the accessory handler for the restored accessory
1595
1595
  // this is imported from `platformAccessory.ts`
@@ -1612,7 +1612,7 @@ class SwitchBotPlatform {
1612
1612
  accessory.context.deviceID = device.deviceId;
1613
1613
  accessory.context.firmwareRevision = device.firmware;
1614
1614
  accessory.context.deviceType = `IR: ${device.remoteType}`;
1615
- accessory.context.connectionType = await this.connectionTypeNew(device);
1615
+ accessory.context.connectionType = await this.connectionType(device);
1616
1616
  // create the accessory handler for the newly create accessory
1617
1617
  // this is imported from `platformAccessory.ts`
1618
1618
  new other_1.Others(this, accessory, device);
@@ -1625,7 +1625,7 @@ class SwitchBotPlatform {
1625
1625
  this.debugLog(`Unable to Register new device: ${device.deviceName} ${device.remoteType} - ${device.deviceId}`);
1626
1626
  }
1627
1627
  }
1628
- connectionTypeNew(device) {
1628
+ async connectionType(device) {
1629
1629
  let connectionType = '';
1630
1630
  if (!device.connectionType && this.config.credentials?.token && this.config.credentials.secret) {
1631
1631
  connectionType = 'OpenAPI';
@@ -1635,16 +1635,14 @@ class SwitchBotPlatform {
1635
1635
  }
1636
1636
  return connectionType;
1637
1637
  }
1638
- connectionTypeExisting(device) {
1639
- return device.connectionType || 'OpenAPI';
1640
- }
1641
- registerDevice(device) {
1642
- if (!device.hide_device && device.enableCloudService && device.connectionType === 'OpenAPI & BLE') {
1638
+ async registerDevice(device) {
1639
+ device.connectionType = await this.connectionType(device);
1640
+ if (!device.hide_device && device.enableCloudService && device.connectionType === 'BLE/OpenAPI') {
1643
1641
  this.registeringDevice = true;
1644
1642
  this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
1645
1643
  }
1646
1644
  else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
1647
- && !device.enableCloudService && device.connectionType === 'BLE') {
1645
+ && device.connectionType === 'BLE') {
1648
1646
  this.registeringDevice = true;
1649
1647
  this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
1650
1648
  }
@@ -1658,15 +1656,15 @@ class SwitchBotPlatform {
1658
1656
  }
1659
1657
  else if (!device.connectionType) {
1660
1658
  this.registeringDevice = false;
1661
- this.debugLog(`Device: ${device.deviceName} Connection Type not Set, will not display in HomeKit`);
1659
+ this.errorLog(`Device: ${device.deviceName} Connection Type not Set, will not display in HomeKit`);
1662
1660
  }
1663
1661
  else if (device.hide_device) {
1664
1662
  this.registeringDevice = false;
1665
- this.debugLog(`Device: ${device.deviceName} Device Set to Hidden, will not display in HomeKit`);
1663
+ this.errorLog(`Device: ${device.deviceName} Device Set to Hidden, will not display in HomeKit`);
1666
1664
  }
1667
1665
  else {
1668
1666
  this.registeringDevice = false;
1669
- this.debugLog(`Device: ${device.deviceName} OpenAPI and BLE Are Not Enabled`);
1667
+ this.errorLog(`Device: ${device.deviceName} OpenAPI or BLE Are Not Enabled`);
1670
1668
  }
1671
1669
  return this.registeringDevice;
1672
1670
  }