@switchbot/homebridge-switchbot 2.0.0-beta.19 → 2.0.0-beta.20

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 +6 -1
  2. package/README.md +1 -2
  3. package/config.schema.json +51 -32
  4. package/dist/device/bot.d.ts +32 -29
  5. package/dist/device/bot.d.ts.map +1 -1
  6. package/dist/device/bot.js +549 -575
  7. package/dist/device/bot.js.map +1 -1
  8. package/dist/device/colorbulb.d.ts +33 -15
  9. package/dist/device/colorbulb.d.ts.map +1 -1
  10. package/dist/device/colorbulb.js +426 -341
  11. package/dist/device/colorbulb.js.map +1 -1
  12. package/dist/device/contact.d.ts +16 -9
  13. package/dist/device/contact.d.ts.map +1 -1
  14. package/dist/device/contact.js +246 -208
  15. package/dist/device/contact.js.map +1 -1
  16. package/dist/device/curtain.d.ts +21 -18
  17. package/dist/device/curtain.d.ts.map +1 -1
  18. package/dist/device/curtain.js +449 -449
  19. package/dist/device/curtain.js.map +1 -1
  20. package/dist/device/humidifier.d.ts +22 -20
  21. package/dist/device/humidifier.d.ts.map +1 -1
  22. package/dist/device/humidifier.js +346 -324
  23. package/dist/device/humidifier.js.map +1 -1
  24. package/dist/device/lock.d.ts +22 -10
  25. package/dist/device/lock.d.ts.map +1 -1
  26. package/dist/device/lock.js +257 -178
  27. package/dist/device/lock.js.map +1 -1
  28. package/dist/device/meter.d.ts +21 -14
  29. package/dist/device/meter.d.ts.map +1 -1
  30. package/dist/device/meter.js +287 -239
  31. package/dist/device/meter.js.map +1 -1
  32. package/dist/device/meterplus.d.ts +23 -10
  33. package/dist/device/meterplus.d.ts.map +1 -1
  34. package/dist/device/meterplus.js +308 -190
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/motion.d.ts +17 -10
  37. package/dist/device/motion.d.ts.map +1 -1
  38. package/dist/device/motion.js +225 -193
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts +24 -17
  41. package/dist/device/plug.d.ts.map +1 -1
  42. package/dist/device/plug.js +270 -267
  43. package/dist/device/plug.js.map +1 -1
  44. package/dist/device/striplight.d.ts +36 -14
  45. package/dist/device/striplight.d.ts.map +1 -1
  46. package/dist/device/striplight.js +447 -299
  47. package/dist/device/striplight.js.map +1 -1
  48. package/dist/irdevice/airconditioner.d.ts +7 -14
  49. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  50. package/dist/irdevice/airconditioner.js +177 -169
  51. package/dist/irdevice/airconditioner.js.map +1 -1
  52. package/dist/irdevice/airpurifier.d.ts +3 -5
  53. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  54. package/dist/irdevice/airpurifier.js +72 -57
  55. package/dist/irdevice/airpurifier.js.map +1 -1
  56. package/dist/irdevice/camera.d.ts +3 -4
  57. package/dist/irdevice/camera.d.ts.map +1 -1
  58. package/dist/irdevice/camera.js +47 -33
  59. package/dist/irdevice/camera.js.map +1 -1
  60. package/dist/irdevice/fan.d.ts +3 -4
  61. package/dist/irdevice/fan.d.ts.map +1 -1
  62. package/dist/irdevice/fan.js +66 -48
  63. package/dist/irdevice/fan.js.map +1 -1
  64. package/dist/irdevice/light.d.ts +3 -4
  65. package/dist/irdevice/light.d.ts.map +1 -1
  66. package/dist/irdevice/light.js +48 -47
  67. package/dist/irdevice/light.js.map +1 -1
  68. package/dist/irdevice/other.d.ts +3 -4
  69. package/dist/irdevice/other.d.ts.map +1 -1
  70. package/dist/irdevice/other.js +47 -33
  71. package/dist/irdevice/other.js.map +1 -1
  72. package/dist/irdevice/tv.d.ts +10 -11
  73. package/dist/irdevice/tv.d.ts.map +1 -1
  74. package/dist/irdevice/tv.js +64 -48
  75. package/dist/irdevice/tv.js.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.d.ts +7 -12
  77. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  78. package/dist/irdevice/vacuumcleaner.js +52 -41
  79. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  80. package/dist/irdevice/waterheater.d.ts +6 -11
  81. package/dist/irdevice/waterheater.d.ts.map +1 -1
  82. package/dist/irdevice/waterheater.js +52 -42
  83. package/dist/irdevice/waterheater.js.map +1 -1
  84. package/dist/platform.d.ts +0 -4
  85. package/dist/platform.d.ts.map +1 -1
  86. package/dist/platform.js +44 -66
  87. package/dist/platform.js.map +1 -1
  88. package/dist/settings.d.ts +3 -3
  89. package/dist/settings.d.ts.map +1 -1
  90. package/package.json +7 -6
  91. package/src/device/bot.ts +551 -589
  92. package/src/device/colorbulb.ts +441 -375
  93. package/src/device/contact.ts +249 -213
  94. package/src/device/curtain.ts +452 -461
  95. package/src/device/humidifier.ts +358 -365
  96. package/src/device/lock.ts +263 -179
  97. package/src/device/meter.ts +302 -253
  98. package/src/device/meterplus.ts +319 -194
  99. package/src/device/motion.ts +230 -199
  100. package/src/device/plug.ts +273 -274
  101. package/src/device/striplight.ts +460 -316
  102. package/src/irdevice/airconditioner.ts +181 -183
  103. package/src/irdevice/airpurifier.ts +70 -60
  104. package/src/irdevice/camera.ts +46 -36
  105. package/src/irdevice/fan.ts +64 -49
  106. package/src/irdevice/light.ts +47 -51
  107. package/src/irdevice/other.ts +46 -36
  108. package/src/irdevice/tv.ts +64 -51
  109. package/src/irdevice/vacuumcleaner.ts +52 -45
  110. package/src/irdevice/waterheater.ts +50 -45
  111. package/src/platform.ts +44 -68
  112. package/src/settings.ts +3 -3
package/dist/platform.js CHANGED
@@ -153,7 +153,7 @@ class SwitchBotPlatform {
153
153
  if (!deviceConfig.deviceId) {
154
154
  throw new Error('The devices config section is missing the *Device ID* in the config. Please check your config.');
155
155
  }
156
- if (!deviceConfig.configDeviceType && deviceConfig.ble) {
156
+ if (!deviceConfig.configDeviceType && deviceConfig.connectionType) {
157
157
  throw new Error('The devices config section is missing the *Device Type* in the config. Please check your config.');
158
158
  }
159
159
  }
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
598
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
599
599
  this.api.updatePlatformAccessories([existingAccessory]);
600
600
  // create the accessory handler for the restored accessory
601
601
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
621
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
650
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
651
651
  this.api.updatePlatformAccessories([existingAccessory]);
652
652
  // create the accessory handler for the restored accessory
653
653
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
674
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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`
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
703
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
704
704
  this.api.updatePlatformAccessories([existingAccessory]);
705
705
  // create the accessory handler for the restored accessory
706
706
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
726
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
754
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
755
755
  this.api.updatePlatformAccessories([existingAccessory]);
756
756
  // create the accessory handler for the restored accessory
757
757
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
777
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
805
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
806
806
  this.api.updatePlatformAccessories([existingAccessory]);
807
807
  // create the accessory handler for the restored accessory
808
808
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
828
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
856
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
857
857
  this.api.updatePlatformAccessories([existingAccessory]);
858
858
  // create the accessory handler for the restored accessory
859
859
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
879
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
907
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewAccessory(device, accessory);
942
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
982
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
983
983
  this.api.updatePlatformAccessories([existingAccessory]);
984
984
  // create the accessory handler for the restored accessory
985
985
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
1005
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1033
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
1034
1034
  this.api.updatePlatformAccessories([existingAccessory]);
1035
1035
  // create the accessory handler for the restored accessory
1036
1036
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
1056
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1084
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
1085
1085
  this.api.updatePlatformAccessories([existingAccessory]);
1086
1086
  // create the accessory handler for the restored accessory
1087
1087
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
1107
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -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
- await this.connectionTypeExistingAccessory(device, existingAccessory);
1135
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
1136
1136
  this.api.updatePlatformAccessories([existingAccessory]);
1137
1137
  // create the accessory handler for the restored accessory
1138
1138
  // this is imported from `platformAccessory.ts`
@@ -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
- await this.connectionTypeNewAccessory(device, accessory);
1158
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1184
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1203
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1235
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1258
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1286
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1309
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1337
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1360
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1388
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1411
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1439
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1462
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1490
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1513
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1541
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1564
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeExistingIRAccessory(existingAccessory);
1592
+ existingAccessory.context.connectionType = device.connectionType || 'OpenAPI';
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
- await this.connectionTypeNewIRAccessory(accessory);
1615
+ accessory.context.connectionType = device.connectionType || 'OpenAPI';
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);
@@ -1626,16 +1626,16 @@ class SwitchBotPlatform {
1626
1626
  }
1627
1627
  }
1628
1628
  registerDevice(device) {
1629
- if (!device.hide_device && device.enableCloudService && device.ble) {
1629
+ if (!device.hide_device && device.enableCloudService && device.connectionType === 'Both') {
1630
1630
  this.registeringDevice = true;
1631
1631
  this.debugLog(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
1632
1632
  }
1633
1633
  else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName
1634
- && !device.enableCloudService) {
1634
+ && !device.enableCloudService && device.connectionType === 'BLE') {
1635
1635
  this.registeringDevice = true;
1636
1636
  this.debugLog(`Device: ${device.deviceName} BLE Connection Enabled`);
1637
1637
  }
1638
- else if (!device.hide_device && device.enableCloudService && !device.ble) {
1638
+ else if (!device.hide_device && device.enableCloudService && device.connectionType === 'OpenAPI') {
1639
1639
  this.registeringDevice = true;
1640
1640
  this.debugLog(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
1641
1641
  }
@@ -1658,28 +1658,6 @@ class SwitchBotPlatform {
1658
1658
  async externalAccessory(accessory) {
1659
1659
  this.api.publishExternalAccessories(settings_1.PLUGIN_NAME, [accessory]);
1660
1660
  }
1661
- async connectionTypeNewAccessory(device, accessory) {
1662
- if (device.ble) {
1663
- accessory.context.connectionType = 'BLE';
1664
- }
1665
- else {
1666
- accessory.context.connectionType = 'OpenAPI';
1667
- }
1668
- }
1669
- async connectionTypeExistingAccessory(device, existingAccessory) {
1670
- if (device.ble) {
1671
- existingAccessory.context.connectionType = 'BLE';
1672
- }
1673
- else {
1674
- existingAccessory.context.connectionType = 'OpenAPI';
1675
- }
1676
- }
1677
- async connectionTypeNewIRAccessory(accessory) {
1678
- accessory.context.connectionType = 'IR wirth OpenAPI';
1679
- }
1680
- async connectionTypeExistingIRAccessory(existingAccessory) {
1681
- existingAccessory.context.connectionType = 'IR with OpenAPI';
1682
- }
1683
1661
  unregisterPlatformAccessories(existingAccessory) {
1684
1662
  // remove platform accessories when no longer present
1685
1663
  this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [existingAccessory]);