@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/dist/platform.js CHANGED
@@ -81,6 +81,10 @@ class SwitchBotPlatform {
81
81
  if (this.config.credentials?.openToken && !this.config.credentials.token) {
82
82
  await this.updateToken();
83
83
  }
84
+ else if (!this.config.credentials?.secret) {
85
+ // eslint-disable-next-line no-useless-escape
86
+ this.errorLog('\"secret\" config is not populated, you must populate then please restart Homebridge.');
87
+ }
84
88
  else {
85
89
  this.discoverDevices();
86
90
  }
@@ -132,10 +136,10 @@ class SwitchBotPlatform {
132
136
  if (this.config.options.logging) {
133
137
  platformConfig['logging'] = this.config.options.logging;
134
138
  }
135
- if (this.config.options.logging) {
139
+ if (this.config.options.logging && this.config.options.refreshRate) {
136
140
  platformConfig['refreshRate'] = this.config.options.refreshRate;
137
141
  }
138
- if (this.config.options.logging) {
142
+ if (this.config.options.logging && this.config.options.pushRate) {
139
143
  platformConfig['pushRate'] = this.config.options.pushRate;
140
144
  }
141
145
  if (Object.entries(platformConfig).length !== 0) {
@@ -203,7 +207,6 @@ class SwitchBotPlatform {
203
207
  this.errorLog('Missing secret');
204
208
  this.warnLog('Cloud Enabled SwitchBot Devices & IR Devices will not work');
205
209
  }
206
- throw Error('Missing secret');
207
210
  }
208
211
  }
209
212
  }
@@ -234,8 +237,16 @@ class SwitchBotPlatform {
234
237
  throw new Error('pluginConfig.credentials is not an object');
235
238
  }
236
239
  // Move openToken to token
237
- this.warnLog('This plugin has been updated to use OpenAPI v1.1, config is set with openToken.');
238
- this.warnLog('`openToken` config has been moved to the `token` config, Please restart Homebridge.');
240
+ if (!this.config.credentials.secret) {
241
+ // eslint-disable-next-line no-useless-escape, max-len
242
+ 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');
243
+ // eslint-disable-next-line no-useless-escape
244
+ this.errorLog('\"secret\" config is not populated, you must populate then please restart Homebridge.');
245
+ }
246
+ else {
247
+ // eslint-disable-next-line no-useless-escape, max-len
248
+ 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.');
249
+ }
239
250
  // set the refresh token
240
251
  pluginConfig.credentials.token = this.config.credentials?.openToken;
241
252
  pluginConfig.credentials.openToken = 'Delete';
@@ -243,7 +254,7 @@ class SwitchBotPlatform {
243
254
  this.warnLog(`Token: ${pluginConfig.credentials.token}`);
244
255
  }
245
256
  // save the config, ensuring we maintain pretty json
246
- (0, fs_1.writeFileSync)(this.api.user.configPath(), (0, super_stringify_1.default)(currentConfig, null, 4));
257
+ (0, fs_1.writeFileSync)(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
247
258
  this.verifyConfig();
248
259
  }
249
260
  catch (e) {
@@ -577,14 +588,13 @@ class SwitchBotPlatform {
577
588
  if (existingAccessory) {
578
589
  // the accessory already exists
579
590
  if (this.registerDevice(device)) {
580
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
581
591
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
582
- //existingAccessory.context.firmwareRevision = firmware;
583
592
  existingAccessory.context.model = device.deviceType;
584
593
  existingAccessory.context.deviceID = device.deviceId;
585
594
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
586
595
  existingAccessory.context.firmwareRevision = device.firmware;
587
596
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
597
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
588
598
  await this.connectionTypeExistingAccessory(device, existingAccessory);
589
599
  this.api.updatePlatformAccessories([existingAccessory]);
590
600
  // create the accessory handler for the restored accessory
@@ -629,7 +639,6 @@ class SwitchBotPlatform {
629
639
  if (existingAccessory) {
630
640
  // the accessory already exists
631
641
  if (this.registerDevice(device)) {
632
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
633
642
  this.debugLog((0, super_stringify_1.default)(device.bot?.mode));
634
643
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
635
644
  existingAccessory.context.model = device.deviceType;
@@ -637,6 +646,7 @@ class SwitchBotPlatform {
637
646
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
638
647
  existingAccessory.context.firmwareRevision = device.firmware;
639
648
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
649
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
640
650
  await this.connectionTypeExistingAccessory(device, existingAccessory);
641
651
  this.api.updatePlatformAccessories([existingAccessory]);
642
652
  // create the accessory handler for the restored accessory
@@ -683,13 +693,13 @@ class SwitchBotPlatform {
683
693
  if (existingAccessory) {
684
694
  // the accessory already exists
685
695
  if (this.registerDevice(device)) {
686
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
687
696
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
688
697
  existingAccessory.context.model = device.deviceType;
689
698
  existingAccessory.context.deviceID = device.deviceId;
690
699
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
691
700
  existingAccessory.context.firmwareRevision = device.firmware;
692
701
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
702
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
693
703
  await this.connectionTypeExistingAccessory(device, existingAccessory);
694
704
  this.api.updatePlatformAccessories([existingAccessory]);
695
705
  // create the accessory handler for the restored accessory
@@ -734,13 +744,13 @@ class SwitchBotPlatform {
734
744
  if (existingAccessory) {
735
745
  // the accessory already exists
736
746
  if (this.registerDevice(device)) {
737
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
738
747
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
739
748
  existingAccessory.context.model = device.deviceType;
740
749
  existingAccessory.context.deviceID = device.deviceId;
741
750
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
742
751
  existingAccessory.context.firmwareRevision = device.firmware;
743
752
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
753
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
744
754
  await this.connectionTypeExistingAccessory(device, existingAccessory);
745
755
  this.api.updatePlatformAccessories([existingAccessory]);
746
756
  // create the accessory handler for the restored accessory
@@ -785,13 +795,13 @@ class SwitchBotPlatform {
785
795
  if (existingAccessory) {
786
796
  // the accessory already exists
787
797
  if (this.registerDevice(device)) {
788
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
789
798
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
790
799
  existingAccessory.context.model = device.deviceType;
791
800
  existingAccessory.context.deviceID = device.deviceId;
792
801
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
793
802
  existingAccessory.context.firmwareRevision = device.firmware;
794
803
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
804
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
795
805
  await this.connectionTypeExistingAccessory(device, existingAccessory);
796
806
  this.api.updatePlatformAccessories([existingAccessory]);
797
807
  // create the accessory handler for the restored accessory
@@ -836,13 +846,13 @@ class SwitchBotPlatform {
836
846
  if (existingAccessory) {
837
847
  // the accessory already exists
838
848
  if (this.registerDevice(device)) {
839
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
840
849
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
841
850
  existingAccessory.context.model = device.deviceType;
842
851
  existingAccessory.context.deviceID = device.deviceId;
843
852
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
844
853
  existingAccessory.context.firmwareRevision = device.firmware;
845
854
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
855
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
846
856
  await this.connectionTypeExistingAccessory(device, existingAccessory);
847
857
  this.api.updatePlatformAccessories([existingAccessory]);
848
858
  // create the accessory handler for the restored accessory
@@ -887,13 +897,13 @@ class SwitchBotPlatform {
887
897
  if (existingAccessory) {
888
898
  // the accessory already exists
889
899
  if (this.isCurtainGrouped(device)) {
890
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
891
900
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
892
901
  existingAccessory.context.model = device.deviceType;
893
902
  existingAccessory.context.deviceID = device.deviceId;
894
903
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
895
904
  existingAccessory.context.firmwareRevision = device.firmware;
896
905
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
906
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
897
907
  await this.connectionTypeExistingAccessory(device, existingAccessory);
898
908
  this.api.updatePlatformAccessories([existingAccessory]);
899
909
  // create the accessory handler for the restored accessory
@@ -962,13 +972,13 @@ class SwitchBotPlatform {
962
972
  if (existingAccessory) {
963
973
  // the accessory already exists
964
974
  if (this.registerDevice(device)) {
965
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
966
975
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
967
976
  existingAccessory.context.model = device.deviceType;
968
977
  existingAccessory.context.deviceID = device.deviceId;
969
978
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
970
979
  existingAccessory.context.firmwareRevision = device.firmware;
971
980
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
981
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
972
982
  await this.connectionTypeExistingAccessory(device, existingAccessory);
973
983
  this.api.updatePlatformAccessories([existingAccessory]);
974
984
  // create the accessory handler for the restored accessory
@@ -1013,13 +1023,13 @@ class SwitchBotPlatform {
1013
1023
  if (existingAccessory) {
1014
1024
  // the accessory already exists
1015
1025
  if (this.registerDevice(device)) {
1016
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1017
1026
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1018
1027
  existingAccessory.context.model = device.deviceType;
1019
1028
  existingAccessory.context.deviceID = device.deviceId;
1020
1029
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1021
1030
  existingAccessory.context.firmwareRevision = device.firmware;
1022
1031
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1032
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1023
1033
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1024
1034
  this.api.updatePlatformAccessories([existingAccessory]);
1025
1035
  // create the accessory handler for the restored accessory
@@ -1064,13 +1074,13 @@ class SwitchBotPlatform {
1064
1074
  if (existingAccessory) {
1065
1075
  // the accessory already exists
1066
1076
  if (this.registerDevice(device)) {
1067
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1068
1077
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1069
1078
  existingAccessory.context.model = device.deviceType;
1070
1079
  existingAccessory.context.deviceID = device.deviceId;
1071
1080
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1072
1081
  existingAccessory.context.firmwareRevision = device.firmware;
1073
1082
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1083
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1074
1084
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1075
1085
  this.api.updatePlatformAccessories([existingAccessory]);
1076
1086
  // create the accessory handler for the restored accessory
@@ -1115,13 +1125,13 @@ class SwitchBotPlatform {
1115
1125
  if (existingAccessory) {
1116
1126
  // the accessory already exists
1117
1127
  if (this.registerDevice(device)) {
1118
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1119
1128
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1120
1129
  existingAccessory.context.model = device.deviceType;
1121
1130
  existingAccessory.context.deviceID = device.deviceId;
1122
1131
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1123
1132
  existingAccessory.context.firmwareRevision = device.firmware;
1124
1133
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1134
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1125
1135
  await this.connectionTypeExistingAccessory(device, existingAccessory);
1126
1136
  this.api.updatePlatformAccessories([existingAccessory]);
1127
1137
  // create the accessory handler for the restored accessory
@@ -1164,13 +1174,13 @@ class SwitchBotPlatform {
1164
1174
  // the cached devices we stored in the `configureAccessory` method above
1165
1175
  const existingAccessory = this.accessories.find((accessory) => accessory.UUID === uuid);
1166
1176
  if (!device.hide_device && existingAccessory) {
1167
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1168
1177
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1169
1178
  existingAccessory.context.model = device.remoteType;
1170
1179
  existingAccessory.context.deviceID = device.deviceId;
1171
1180
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1172
1181
  existingAccessory.context.firmwareRevision = device.firmware;
1173
1182
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1183
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1174
1184
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1175
1185
  this.api.updatePlatformAccessories([existingAccessory]);
1176
1186
  // create the accessory handler for the restored accessory
@@ -1215,13 +1225,13 @@ class SwitchBotPlatform {
1215
1225
  if (existingAccessory) {
1216
1226
  // the accessory already exists
1217
1227
  if (!device.hide_device && device.hubDeviceId) {
1218
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1219
1228
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1220
1229
  existingAccessory.context.model = device.remoteType;
1221
1230
  existingAccessory.context.deviceID = device.deviceId;
1222
1231
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1223
1232
  existingAccessory.context.firmwareRevision = device.firmware;
1224
1233
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1234
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1225
1235
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1226
1236
  this.api.updatePlatformAccessories([existingAccessory]);
1227
1237
  // create the accessory handler for the restored accessory
@@ -1266,13 +1276,13 @@ class SwitchBotPlatform {
1266
1276
  if (existingAccessory) {
1267
1277
  // the accessory already exists
1268
1278
  if (!device.hide_device && device.hubDeviceId) {
1269
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1270
1279
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1271
1280
  existingAccessory.context.model = device.remoteType;
1272
1281
  existingAccessory.context.deviceID = device.deviceId;
1273
1282
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1274
1283
  existingAccessory.context.firmwareRevision = device.firmware;
1275
1284
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1285
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1276
1286
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1277
1287
  this.api.updatePlatformAccessories([existingAccessory]);
1278
1288
  // create the accessory handler for the restored accessory
@@ -1317,13 +1327,13 @@ class SwitchBotPlatform {
1317
1327
  if (existingAccessory) {
1318
1328
  // the accessory already exists
1319
1329
  if (!device.hide_device && device.hubDeviceId) {
1320
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1321
1330
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1322
1331
  existingAccessory.context.model = device.remoteType;
1323
1332
  existingAccessory.context.deviceID = device.deviceId;
1324
1333
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1325
1334
  existingAccessory.context.firmwareRevision = device.firmware;
1326
1335
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1336
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1327
1337
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1328
1338
  this.api.updatePlatformAccessories([existingAccessory]);
1329
1339
  // create the accessory handler for the restored accessory
@@ -1368,13 +1378,13 @@ class SwitchBotPlatform {
1368
1378
  if (existingAccessory) {
1369
1379
  // the accessory already exists
1370
1380
  if (!device.hide_device && device.hubDeviceId) {
1371
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1372
1381
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1373
1382
  existingAccessory.context.model = device.remoteType;
1374
1383
  existingAccessory.context.deviceID = device.deviceId;
1375
1384
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1376
1385
  existingAccessory.context.firmwareRevision = device.firmware;
1377
1386
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1387
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1378
1388
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1379
1389
  this.api.updatePlatformAccessories([existingAccessory]);
1380
1390
  // create the accessory handler for the restored accessory
@@ -1419,13 +1429,13 @@ class SwitchBotPlatform {
1419
1429
  if (existingAccessory) {
1420
1430
  // the accessory already exists
1421
1431
  if (!device.hide_device && device.hubDeviceId) {
1422
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1423
1432
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1424
1433
  existingAccessory.context.model = device.remoteType;
1425
1434
  existingAccessory.context.deviceID = device.deviceId;
1426
1435
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1427
1436
  existingAccessory.context.firmwareRevision = device.firmware;
1428
1437
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1438
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1429
1439
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1430
1440
  this.api.updatePlatformAccessories([existingAccessory]);
1431
1441
  // create the accessory handler for the restored accessory
@@ -1470,13 +1480,13 @@ class SwitchBotPlatform {
1470
1480
  if (existingAccessory) {
1471
1481
  // the accessory already exists
1472
1482
  if (!device.hide_device && device.hubDeviceId) {
1473
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1474
1483
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1475
1484
  existingAccessory.context.model = device.remoteType;
1476
1485
  existingAccessory.context.deviceID = device.deviceId;
1477
1486
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1478
1487
  existingAccessory.context.firmwareRevision = device.firmware;
1479
1488
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1489
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1480
1490
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1481
1491
  this.api.updatePlatformAccessories([existingAccessory]);
1482
1492
  // create the accessory handler for the restored accessory
@@ -1521,13 +1531,13 @@ class SwitchBotPlatform {
1521
1531
  if (existingAccessory) {
1522
1532
  // the accessory already exists
1523
1533
  if (!device.hide_device && device.hubDeviceId) {
1524
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1525
1534
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1526
1535
  existingAccessory.context.model = device.remoteType;
1527
1536
  existingAccessory.context.deviceID = device.deviceId;
1528
1537
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1529
1538
  existingAccessory.context.firmwareRevision = device.firmware;
1530
1539
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1540
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1531
1541
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1532
1542
  this.api.updatePlatformAccessories([existingAccessory]);
1533
1543
  // create the accessory handler for the restored accessory
@@ -1572,13 +1582,13 @@ class SwitchBotPlatform {
1572
1582
  if (existingAccessory) {
1573
1583
  // the accessory already exists
1574
1584
  if (!device.hide_device && device.hubDeviceId) {
1575
- this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1576
1585
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1577
1586
  existingAccessory.context.model = device.remoteType;
1578
1587
  existingAccessory.context.deviceID = device.deviceId;
1579
1588
  existingAccessory.displayName = device.configDeviceName || device.deviceName;
1580
1589
  existingAccessory.context.firmwareRevision = device.firmware;
1581
1590
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1591
+ this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
1582
1592
  await this.connectionTypeExistingIRAccessory(existingAccessory);
1583
1593
  this.api.updatePlatformAccessories([existingAccessory]);
1584
1594
  // create the accessory handler for the restored accessory