@switchbot/homebridge-switchbot 2.0.0-beta.15 → 2.0.0-beta.17

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/src/platform.ts CHANGED
@@ -86,6 +86,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
86
86
  try {
87
87
  if (this.config.credentials?.openToken && !this.config.credentials.token) {
88
88
  await this.updateToken();
89
+ } else if (!this.config.credentials?.secret) {
90
+ // eslint-disable-next-line no-useless-escape
91
+ this.errorLog('\"secret\" config is not populated, you must populate then please restart Homebridge.');
89
92
  } else {
90
93
  this.discoverDevices();
91
94
  }
@@ -139,10 +142,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
139
142
  if (this.config.options.logging) {
140
143
  platformConfig['logging'] = this.config.options.logging;
141
144
  }
142
- if (this.config.options.logging) {
145
+ if (this.config.options.logging && this.config.options.refreshRate) {
143
146
  platformConfig['refreshRate'] = this.config.options.refreshRate;
144
147
  }
145
- if (this.config.options.logging) {
148
+ if (this.config.options.logging && this.config.options.pushRate) {
146
149
  platformConfig['pushRate'] = this.config.options.pushRate;
147
150
  }
148
151
  if (Object.entries(platformConfig).length !== 0) {
@@ -216,7 +219,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
216
219
  this.errorLog('Missing secret');
217
220
  this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
218
221
  }
219
- throw Error('Missing secret');
220
222
  }
221
223
  }
222
224
  }
@@ -253,8 +255,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
253
255
  throw new Error('pluginConfig.credentials is not an object');
254
256
  }
255
257
  // Move openToken to token
256
- this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken.');
257
- this.warnLog('`openToken` config has been moved to the `token` config, Please restart Homebridge.');
258
+ if (!this.config.credentials.secret){
259
+ // eslint-disable-next-line no-useless-escape, max-len
260
+ this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, \"openToken\" cconfig has been moved to the \"token\" config' );
261
+ // eslint-disable-next-line no-useless-escape
262
+ this.errorLog('\"secret\" config is not populated, you must populate then please restart Homebridge.');
263
+ } else {
264
+ // eslint-disable-next-line no-useless-escape, max-len
265
+ this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken, \"openToken\" config has been moved to the \"token\" config, please restart Homebridge.');
266
+ }
258
267
 
259
268
  // set the refresh token
260
269
  pluginConfig.credentials.token = this.config.credentials?.openToken;
@@ -264,7 +273,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
264
273
  this.warnLog(`Token: ${pluginConfig.credentials.token}`);
265
274
  }
266
275
  // save the config, ensuring we maintain pretty json
267
- writeFileSync(this.api.user.configPath(), superStringify(currentConfig, null, 4));
276
+ writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
268
277
  this.verifyConfig();
269
278
  } catch (e: any) {
270
279
  this.errorLog(e);
@@ -602,15 +611,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
602
611
  if (existingAccessory) {
603
612
  // the accessory already exists
604
613
  if (this.registerDevice(device)) {
605
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
606
-
607
614
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
608
- //existingAccessory.context.firmwareRevision = firmware;
609
615
  existingAccessory.context.model = device.deviceType;
610
616
  existingAccessory.context.deviceID = device.deviceId;
611
617
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
612
618
  existingAccessory.context.firmwareRevision = device.firmware;
613
619
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
620
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
614
621
  await this.connectionTypeExistingAccessory(device, existingAccessory);
615
622
  this.api.updatePlatformAccessories([existingAccessory]);
616
623
  // create the accessory handler for the restored accessory
@@ -658,16 +665,15 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
658
665
  if (existingAccessory) {
659
666
  // the accessory already exists
660
667
  if (this.registerDevice(device)) {
661
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
662
668
 
663
669
  this.debugLog(superStringify(device.bot?.mode));
664
-
665
670
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
666
671
  existingAccessory.context.model = device.deviceType;
667
672
  existingAccessory.context.deviceID = device.deviceId;
668
673
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
669
674
  existingAccessory.context.firmwareRevision = device.firmware;
670
675
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
676
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
671
677
  await this.connectionTypeExistingAccessory(device, existingAccessory);
672
678
  this.api.updatePlatformAccessories([existingAccessory]);
673
679
  // create the accessory handler for the restored accessory
@@ -718,14 +724,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
718
724
  if (existingAccessory) {
719
725
  // the accessory already exists
720
726
  if (this.registerDevice(device)) {
721
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
722
-
723
727
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
724
728
  existingAccessory.context.model = device.deviceType;
725
729
  existingAccessory.context.deviceID = device.deviceId;
726
730
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
727
731
  existingAccessory.context.firmwareRevision = device.firmware;
728
732
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
733
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
729
734
  await this.connectionTypeExistingAccessory(device, existingAccessory);
730
735
  this.api.updatePlatformAccessories([existingAccessory]);
731
736
  // create the accessory handler for the restored accessory
@@ -773,14 +778,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
773
778
  if (existingAccessory) {
774
779
  // the accessory already exists
775
780
  if (this.registerDevice(device)) {
776
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
777
-
778
781
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
779
782
  existingAccessory.context.model = device.deviceType;
780
783
  existingAccessory.context.deviceID = device.deviceId;
781
784
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
782
785
  existingAccessory.context.firmwareRevision = device.firmware;
783
786
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
787
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
784
788
  await this.connectionTypeExistingAccessory(device, existingAccessory);
785
789
  this.api.updatePlatformAccessories([existingAccessory]);
786
790
  // create the accessory handler for the restored accessory
@@ -828,14 +832,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
828
832
  if (existingAccessory) {
829
833
  // the accessory already exists
830
834
  if (this.registerDevice(device)) {
831
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
832
-
833
835
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
834
836
  existingAccessory.context.model = device.deviceType;
835
837
  existingAccessory.context.deviceID = device.deviceId;
836
838
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
837
839
  existingAccessory.context.firmwareRevision = device.firmware;
838
840
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
841
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
839
842
  await this.connectionTypeExistingAccessory(device, existingAccessory);
840
843
  this.api.updatePlatformAccessories([existingAccessory]);
841
844
  // create the accessory handler for the restored accessory
@@ -883,14 +886,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
883
886
  if (existingAccessory) {
884
887
  // the accessory already exists
885
888
  if (this.registerDevice(device)) {
886
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
887
-
888
889
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
889
890
  existingAccessory.context.model = device.deviceType;
890
891
  existingAccessory.context.deviceID = device.deviceId;
891
892
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
892
893
  existingAccessory.context.firmwareRevision = device.firmware;
893
894
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
895
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
894
896
  await this.connectionTypeExistingAccessory(device, existingAccessory);
895
897
  this.api.updatePlatformAccessories([existingAccessory]);
896
898
  // create the accessory handler for the restored accessory
@@ -938,14 +940,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
938
940
  if (existingAccessory) {
939
941
  // the accessory already exists
940
942
  if (this.isCurtainGrouped(device)) {
941
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
942
-
943
943
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
944
944
  existingAccessory.context.model = device.deviceType;
945
945
  existingAccessory.context.deviceID = device.deviceId;
946
946
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
947
947
  existingAccessory.context.firmwareRevision = device.firmware;
948
948
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
949
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
949
950
  await this.connectionTypeExistingAccessory(device, existingAccessory);
950
951
  this.api.updatePlatformAccessories([existingAccessory]);
951
952
  // create the accessory handler for the restored accessory
@@ -1019,14 +1020,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1019
1020
  if (existingAccessory) {
1020
1021
  // the accessory already exists
1021
1022
  if (this.registerDevice(device)) {
1022
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1023
-
1024
1023
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1025
1024
  existingAccessory.context.model = device.deviceType;
1026
1025
  existingAccessory.context.deviceID = device.deviceId;
1027
1026
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1028
1027
  existingAccessory.context.firmwareRevision = device.firmware;
1029
1028
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1029
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1030
1030
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1031
1031
  this.api.updatePlatformAccessories([existingAccessory]);
1032
1032
  // create the accessory handler for the restored accessory
@@ -1074,14 +1074,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1074
1074
  if (existingAccessory) {
1075
1075
  // the accessory already exists
1076
1076
  if (this.registerDevice(device)) {
1077
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1078
-
1079
1077
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1080
1078
  existingAccessory.context.model = device.deviceType;
1081
1079
  existingAccessory.context.deviceID = device.deviceId;
1082
1080
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1083
1081
  existingAccessory.context.firmwareRevision = device.firmware;
1084
1082
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1083
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1085
1084
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1086
1085
  this.api.updatePlatformAccessories([existingAccessory]);
1087
1086
  // create the accessory handler for the restored accessory
@@ -1129,14 +1128,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1129
1128
  if (existingAccessory) {
1130
1129
  // the accessory already exists
1131
1130
  if (this.registerDevice(device)) {
1132
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1133
-
1134
1131
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1135
1132
  existingAccessory.context.model = device.deviceType;
1136
1133
  existingAccessory.context.deviceID = device.deviceId;
1137
1134
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1138
1135
  existingAccessory.context.firmwareRevision = device.firmware;
1139
1136
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1137
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1140
1138
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1141
1139
  this.api.updatePlatformAccessories([existingAccessory]);
1142
1140
  // create the accessory handler for the restored accessory
@@ -1184,14 +1182,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1184
1182
  if (existingAccessory) {
1185
1183
  // the accessory already exists
1186
1184
  if (this.registerDevice(device)) {
1187
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1188
-
1189
1185
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1190
1186
  existingAccessory.context.model = device.deviceType;
1191
1187
  existingAccessory.context.deviceID = device.deviceId;
1192
1188
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1193
1189
  existingAccessory.context.firmwareRevision = device.firmware;
1194
1190
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1191
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1195
1192
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1196
1193
  this.api.updatePlatformAccessories([existingAccessory]);
1197
1194
  // create the accessory handler for the restored accessory
@@ -1237,14 +1234,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1237
1234
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1238
1235
 
1239
1236
  if (!device.hide_device && existingAccessory) {
1240
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1241
-
1242
1237
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1243
1238
  existingAccessory.context.model = device.remoteType;
1244
1239
  existingAccessory.context.deviceID = device.deviceId;
1245
1240
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1246
1241
  existingAccessory.context.firmwareRevision = device.firmware;
1247
1242
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1243
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1248
1244
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1249
1245
  this.api.updatePlatformAccessories([existingAccessory]);
1250
1246
  // create the accessory handler for the restored accessory
@@ -1293,15 +1289,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1293
1289
  if (existingAccessory) {
1294
1290
  // the accessory already exists
1295
1291
  if (!device.hide_device && device.hubDeviceId) {
1296
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1297
-
1298
1292
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1299
-
1300
1293
  existingAccessory.context.model = device.remoteType;
1301
1294
  existingAccessory.context.deviceID = device.deviceId;
1302
1295
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1303
1296
  existingAccessory.context.firmwareRevision = device.firmware;
1304
1297
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1298
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1305
1299
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1306
1300
  this.api.updatePlatformAccessories([existingAccessory]);
1307
1301
  // create the accessory handler for the restored accessory
@@ -1349,14 +1343,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1349
1343
  if (existingAccessory) {
1350
1344
  // the accessory already exists
1351
1345
  if (!device.hide_device && device.hubDeviceId) {
1352
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1353
-
1354
1346
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1355
1347
  existingAccessory.context.model = device.remoteType;
1356
1348
  existingAccessory.context.deviceID = device.deviceId;
1357
1349
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1358
1350
  existingAccessory.context.firmwareRevision = device.firmware;
1359
1351
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1352
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1360
1353
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1361
1354
  this.api.updatePlatformAccessories([existingAccessory]);
1362
1355
  // create the accessory handler for the restored accessory
@@ -1404,14 +1397,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1404
1397
  if (existingAccessory) {
1405
1398
  // the accessory already exists
1406
1399
  if (!device.hide_device && device.hubDeviceId) {
1407
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1408
-
1409
1400
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1410
1401
  existingAccessory.context.model = device.remoteType;
1411
1402
  existingAccessory.context.deviceID = device.deviceId;
1412
1403
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1413
1404
  existingAccessory.context.firmwareRevision = device.firmware;
1414
1405
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1406
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1415
1407
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1416
1408
  this.api.updatePlatformAccessories([existingAccessory]);
1417
1409
  // create the accessory handler for the restored accessory
@@ -1459,14 +1451,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1459
1451
  if (existingAccessory) {
1460
1452
  // the accessory already exists
1461
1453
  if (!device.hide_device && device.hubDeviceId) {
1462
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1463
-
1464
1454
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1465
1455
  existingAccessory.context.model = device.remoteType;
1466
1456
  existingAccessory.context.deviceID = device.deviceId;
1467
1457
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1468
1458
  existingAccessory.context.firmwareRevision = device.firmware;
1469
1459
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1460
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1470
1461
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1471
1462
  this.api.updatePlatformAccessories([existingAccessory]);
1472
1463
  // create the accessory handler for the restored accessory
@@ -1514,14 +1505,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1514
1505
  if (existingAccessory) {
1515
1506
  // the accessory already exists
1516
1507
  if (!device.hide_device && device.hubDeviceId) {
1517
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1518
-
1519
1508
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1520
1509
  existingAccessory.context.model = device.remoteType;
1521
1510
  existingAccessory.context.deviceID = device.deviceId;
1522
1511
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1523
1512
  existingAccessory.context.firmwareRevision = device.firmware;
1524
1513
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1514
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1525
1515
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1526
1516
  this.api.updatePlatformAccessories([existingAccessory]);
1527
1517
  // create the accessory handler for the restored accessory
@@ -1569,14 +1559,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1569
1559
  if (existingAccessory) {
1570
1560
  // the accessory already exists
1571
1561
  if (!device.hide_device && device.hubDeviceId) {
1572
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1573
-
1574
1562
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1575
1563
  existingAccessory.context.model = device.remoteType;
1576
1564
  existingAccessory.context.deviceID = device.deviceId;
1577
1565
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1578
1566
  existingAccessory.context.firmwareRevision = device.firmware;
1579
1567
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1568
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1580
1569
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1581
1570
  this.api.updatePlatformAccessories([existingAccessory]);
1582
1571
  // create the accessory handler for the restored accessory
@@ -1624,14 +1613,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1624
1613
  if (existingAccessory) {
1625
1614
  // the accessory already exists
1626
1615
  if (!device.hide_device && device.hubDeviceId) {
1627
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1628
-
1629
1616
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1630
1617
  existingAccessory.context.model = device.remoteType;
1631
1618
  existingAccessory.context.deviceID = device.deviceId;
1632
1619
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1633
1620
  existingAccessory.context.firmwareRevision = device.firmware;
1634
1621
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1622
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1635
1623
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1636
1624
  this.api.updatePlatformAccessories([existingAccessory]);
1637
1625
  // create the accessory handler for the restored accessory
@@ -1679,14 +1667,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1679
1667
  if (existingAccessory) {
1680
1668
  // the accessory already exists
1681
1669
  if (!device.hide_device && device.hubDeviceId) {
1682
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1683
-
1684
1670
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1685
1671
  existingAccessory.context.model = device.remoteType;
1686
1672
  existingAccessory.context.deviceID = device.deviceId;
1687
1673
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1688
1674
  existingAccessory.context.firmwareRevision = device.firmware;
1689
1675
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1676
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1690
1677
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1691
1678
  this.api.updatePlatformAccessories([existingAccessory]);
1692
1679
  // create the accessory handler for the restored accessory
package/src/settings.ts CHANGED
@@ -58,6 +58,7 @@ export interface devicesConfig extends device {
58
58
  plug?: Record<any, any>;
59
59
  lock?: lock;
60
60
  ble?: boolean;
61
+ openAPI?: boolean;
61
62
  customBLEaddress?: string;
62
63
  scanDuration?: number;
63
64
  hide_device?: boolean;