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

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 (84) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +19 -18
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/colorbulb.js +25 -25
  5. package/dist/device/colorbulb.js.map +1 -1
  6. package/dist/device/contact.d.ts.map +1 -1
  7. package/dist/device/contact.js +7 -6
  8. package/dist/device/contact.js.map +1 -1
  9. package/dist/device/curtain.d.ts.map +1 -1
  10. package/dist/device/curtain.js +14 -13
  11. package/dist/device/curtain.js.map +1 -1
  12. package/dist/device/humidifier.d.ts.map +1 -1
  13. package/dist/device/humidifier.js +18 -17
  14. package/dist/device/humidifier.js.map +1 -1
  15. package/dist/device/lock.d.ts.map +1 -1
  16. package/dist/device/lock.js +8 -7
  17. package/dist/device/lock.js.map +1 -1
  18. package/dist/device/meter.d.ts.map +1 -1
  19. package/dist/device/meter.js +9 -8
  20. package/dist/device/meter.js.map +1 -1
  21. package/dist/device/meterplus.d.ts.map +1 -1
  22. package/dist/device/meterplus.js +8 -7
  23. package/dist/device/meterplus.js.map +1 -1
  24. package/dist/device/motion.d.ts.map +1 -1
  25. package/dist/device/motion.js +7 -6
  26. package/dist/device/motion.js.map +1 -1
  27. package/dist/device/plug.d.ts.map +1 -1
  28. package/dist/device/plug.js +13 -12
  29. package/dist/device/plug.js.map +1 -1
  30. package/dist/device/striplight.d.ts.map +1 -1
  31. package/dist/device/striplight.js +27 -26
  32. package/dist/device/striplight.js.map +1 -1
  33. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  34. package/dist/irdevice/airconditioner.js +10 -9
  35. package/dist/irdevice/airconditioner.js.map +1 -1
  36. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  37. package/dist/irdevice/airpurifier.js +8 -7
  38. package/dist/irdevice/airpurifier.js.map +1 -1
  39. package/dist/irdevice/camera.d.ts.map +1 -1
  40. package/dist/irdevice/camera.js +7 -6
  41. package/dist/irdevice/camera.js.map +1 -1
  42. package/dist/irdevice/fan.d.ts.map +1 -1
  43. package/dist/irdevice/fan.js +10 -9
  44. package/dist/irdevice/fan.js.map +1 -1
  45. package/dist/irdevice/light.d.ts.map +1 -1
  46. package/dist/irdevice/light.js +9 -8
  47. package/dist/irdevice/light.js.map +1 -1
  48. package/dist/irdevice/other.d.ts.map +1 -1
  49. package/dist/irdevice/other.js +7 -6
  50. package/dist/irdevice/other.js.map +1 -1
  51. package/dist/irdevice/tv.d.ts.map +1 -1
  52. package/dist/irdevice/tv.js +16 -15
  53. package/dist/irdevice/tv.js.map +1 -1
  54. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  55. package/dist/irdevice/vacuumcleaner.js +7 -6
  56. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  57. package/dist/irdevice/waterheater.d.ts.map +1 -1
  58. package/dist/irdevice/waterheater.js +7 -6
  59. package/dist/irdevice/waterheater.js.map +1 -1
  60. package/dist/platform.d.ts.map +1 -1
  61. package/dist/platform.js +44 -43
  62. package/dist/platform.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/device/bot.ts +19 -18
  65. package/src/device/colorbulb.ts +25 -25
  66. package/src/device/contact.ts +7 -6
  67. package/src/device/curtain.ts +14 -13
  68. package/src/device/humidifier.ts +18 -17
  69. package/src/device/lock.ts +8 -7
  70. package/src/device/meter.ts +9 -8
  71. package/src/device/meterplus.ts +8 -7
  72. package/src/device/motion.ts +7 -6
  73. package/src/device/plug.ts +13 -12
  74. package/src/device/striplight.ts +27 -26
  75. package/src/irdevice/airconditioner.ts +10 -9
  76. package/src/irdevice/airpurifier.ts +8 -7
  77. package/src/irdevice/camera.ts +7 -6
  78. package/src/irdevice/fan.ts +10 -9
  79. package/src/irdevice/light.ts +9 -8
  80. package/src/irdevice/other.ts +7 -6
  81. package/src/irdevice/tv.ts +16 -15
  82. package/src/irdevice/vacuumcleaner.ts +7 -6
  83. package/src/irdevice/waterheater.ts +7 -6
  84. package/src/platform.ts +44 -43
package/src/platform.ts CHANGED
@@ -22,6 +22,7 @@ import https from 'https';
22
22
  import crypto from 'crypto';
23
23
  import { Buffer } from 'buffer';
24
24
  import fakegato from 'fakegato-history';
25
+ import superStringify from 'super-stringify';
25
26
  import { readFileSync, writeFileSync } from 'fs';
26
27
  import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
27
28
  import { PLATFORM_NAME, PLUGIN_NAME, irdevice, device, SwitchBotPlatformConfig, devicesConfig, DevicePath, HostDomain } from './settings';
@@ -65,9 +66,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
65
66
  this.verifyConfig();
66
67
  this.debugLog('Config OK');
67
68
  } catch (e: any) {
68
- this.errorLog(JSON.stringify(e.message));
69
+ this.errorLog(superStringify(e.message));
69
70
  if (this.platformLogging?.includes('debug')) {
70
- this.errorLog(JSON.stringify(e));
71
+ this.errorLog(superStringify(e));
71
72
  }
72
73
  return;
73
74
  }
@@ -89,9 +90,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
89
90
  this.discoverDevices();
90
91
  }
91
92
  } catch (e: any) {
92
- this.errorLog('Failed to Discover Devices.', JSON.stringify(e.message));
93
+ this.errorLog('Failed to Discover Devices.', superStringify(e.message));
93
94
  if (this.platformLogging?.includes('debug')) {
94
- this.errorLog(JSON.stringify(e));
95
+ this.errorLog(superStringify(e));
95
96
  }
96
97
  }
97
98
  });
@@ -145,7 +146,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
145
146
  platformConfig['pushRate'] = this.config.options.pushRate;
146
147
  }
147
148
  if (Object.entries(platformConfig).length !== 0) {
148
- this.infoLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
149
+ this.infoLog(`Platform Config: ${superStringify(platformConfig)}`);
149
150
  }
150
151
 
151
152
  if (this.config.options) {
@@ -263,7 +264,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
263
264
  this.warnLog(`Token: ${pluginConfig.credentials.token}`);
264
265
  }
265
266
  // save the config, ensuring we maintain pretty json
266
- writeFileSync(this.api.user.configPath(), JSON.stringify(currentConfig, null, 4));
267
+ writeFileSync(this.api.user.configPath(), superStringify(currentConfig, null, 4));
267
268
  this.verifyConfig();
268
269
  } catch (e: any) {
269
270
  this.errorLog(e);
@@ -297,7 +298,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
297
298
  };
298
299
  const req = https.request(options, (res) => {
299
300
  this.debugLog(`statusCode: ${res.statusCode}`);
300
- this.debugLog(`headers: ${JSON.stringify(res.headers)}`);
301
+ this.debugLog(`headers: ${superStringify(res.headers)}`);
301
302
  let rawData = '';
302
303
  res.on('data', (d) => {
303
304
  rawData += d;
@@ -306,7 +307,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
306
307
  res.on('end', () => {
307
308
  try {
308
309
  const devicesAPI = JSON.parse(rawData);
309
- this.debugLog(`devicesAPI: ${JSON.stringify(devicesAPI.body)}`);
310
+ this.debugLog(`devicesAPI: ${superStringify(devicesAPI.body)}`);
310
311
 
311
312
  // SwitchBot Devices
312
313
  if (devicesAPI.body.deviceList.length !== 0) {
@@ -316,7 +317,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
316
317
  }
317
318
  const deviceLists = devicesAPI.body.deviceList;
318
319
  if (!this.config.options?.devices) {
319
- this.debugLog(`SwitchBot Device Config Not Set: ${JSON.stringify(this.config.options?.devices)}`);
320
+ this.debugLog(`SwitchBot Device Config Not Set: ${superStringify(this.config.options?.devices)}`);
320
321
  const devices = deviceLists.map((v: any) => v);
321
322
  for (const device of devices) {
322
323
  if (device.deviceType) {
@@ -327,7 +328,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
327
328
  }
328
329
  }
329
330
  } else if (this.config.credentials?.token && this.config.options.devices) {
330
- this.debugLog(`SwitchBot Device Config Set: ${JSON.stringify(this.config.options?.devices)}`);
331
+ this.debugLog(`SwitchBot Device Config Set: ${superStringify(this.config.options?.devices)}`);
331
332
  const deviceConfigs = this.config.options?.devices;
332
333
 
333
334
  const mergeBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
@@ -340,7 +341,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
340
341
  }));
341
342
 
342
343
  const devices = mergeBydeviceId(deviceLists, deviceConfigs);
343
- this.debugLog(`SwitchBot Devices: ${JSON.stringify(devices)}`);
344
+ this.debugLog(`SwitchBot Devices: ${superStringify(devices)}`);
344
345
  for (const device of devices) {
345
346
  if (device.deviceType) {
346
347
  if (device.configDeviceName) {
@@ -361,7 +362,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
361
362
  }
362
363
  const irDeviceLists = devicesAPI.body.infraredRemoteList;
363
364
  if (!this.config.options?.irdevices) {
364
- this.debugLog(`IR Device Config Not Set: ${JSON.stringify(this.config.options?.irdevices)}`);
365
+ this.debugLog(`IR Device Config Not Set: ${superStringify(this.config.options?.irdevices)}`);
365
366
  const devices = irDeviceLists.map((v: any) => v);
366
367
  for (const device of devices) {
367
368
  if (device.remoteType) {
@@ -369,7 +370,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
369
370
  }
370
371
  }
371
372
  } else {
372
- this.debugLog(`IR Device Config Set: ${JSON.stringify(this.config.options?.irdevices)}`);
373
+ this.debugLog(`IR Device Config Set: ${superStringify(this.config.options?.irdevices)}`);
373
374
  const irDeviceConfig = this.config.options?.irdevices;
374
375
 
375
376
  const mergeIRBydeviceId = (a1: { deviceId: string }[], a2: any[]) =>
@@ -382,7 +383,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
382
383
  }));
383
384
 
384
385
  const devices = mergeIRBydeviceId(irDeviceLists, irDeviceConfig);
385
- this.debugLog(`IR Devices: ${JSON.stringify(devices)}`);
386
+ this.debugLog(`IR Devices: ${superStringify(devices)}`);
386
387
  for (const device of devices) {
387
388
  if (device.remoteType) {
388
389
  this.createIRDevice(device);
@@ -399,7 +400,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
399
400
  });
400
401
  req.end();
401
402
  } else if (!this.config.credentials?.token && this.config.options?.devices) {
402
- this.debugLog(`SwitchBot Device Manual Config Set: ${JSON.stringify(this.config.options?.devices)}`);
403
+ this.debugLog(`SwitchBot Device Manual Config Set: ${superStringify(this.config.options?.devices)}`);
403
404
  const deviceConfigs = this.config.options?.devices;
404
405
  const devices = deviceConfigs.map((v: any) => v);
405
406
  for (const device of devices) {
@@ -452,10 +453,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
452
453
  this.errorLog('Failed to Discover Devices');
453
454
  }
454
455
  if (this.platformLogging === 'debug') {
455
- this.errorLog(`Failed to Discover Devices, Error Message: ${JSON.stringify(e.message)}`);
456
+ this.errorLog(`Failed to Discover Devices, Error Message: ${superStringify(e.message)}`);
456
457
  }
457
458
  if (this.platformLogging === 'debugMode') {
458
- this.errorLog(`Failed to Discover Devices, Error: ${JSON.stringify(e)}`);
459
+ this.errorLog(`Failed to Discover Devices, Error: ${superStringify(e)}`);
459
460
  }
460
461
  }
461
462
 
@@ -607,7 +608,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
607
608
  //existingAccessory.context.firmwareRevision = firmware;
608
609
  existingAccessory.context.model = device.deviceType;
609
610
  existingAccessory.context.deviceID = device.deviceId;
610
- existingAccessory.displayName = device.deviceName;
611
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
611
612
  existingAccessory.context.firmwareRevision = device.firmware;
612
613
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
613
614
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -659,12 +660,12 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
659
660
  if (this.registerDevice(device)) {
660
661
  this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
661
662
 
662
- this.debugLog(JSON.stringify(device.bot?.mode));
663
+ this.debugLog(superStringify(device.bot?.mode));
663
664
 
664
665
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
665
666
  existingAccessory.context.model = device.deviceType;
666
667
  existingAccessory.context.deviceID = device.deviceId;
667
- existingAccessory.displayName = device.deviceName;
668
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
668
669
  existingAccessory.context.firmwareRevision = device.firmware;
669
670
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
670
671
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -680,7 +681,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
680
681
  // the accessory does not yet exist, so we need to create it
681
682
  this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
682
683
 
683
- this.debugLog(JSON.stringify(device.bot?.mode));
684
+ this.debugLog(superStringify(device.bot?.mode));
684
685
 
685
686
  // create a new accessory
686
687
  const accessory = new this.api.platformAccessory(device.deviceName, uuid);
@@ -722,7 +723,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
722
723
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
723
724
  existingAccessory.context.model = device.deviceType;
724
725
  existingAccessory.context.deviceID = device.deviceId;
725
- existingAccessory.displayName = device.deviceName;
726
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
726
727
  existingAccessory.context.firmwareRevision = device.firmware;
727
728
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
728
729
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -777,7 +778,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
777
778
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
778
779
  existingAccessory.context.model = device.deviceType;
779
780
  existingAccessory.context.deviceID = device.deviceId;
780
- existingAccessory.displayName = device.deviceName;
781
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
781
782
  existingAccessory.context.firmwareRevision = device.firmware;
782
783
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
783
784
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -832,7 +833,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
832
833
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
833
834
  existingAccessory.context.model = device.deviceType;
834
835
  existingAccessory.context.deviceID = device.deviceId;
835
- existingAccessory.displayName = device.deviceName;
836
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
836
837
  existingAccessory.context.firmwareRevision = device.firmware;
837
838
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
838
839
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -887,7 +888,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
887
888
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
888
889
  existingAccessory.context.model = device.deviceType;
889
890
  existingAccessory.context.deviceID = device.deviceId;
890
- existingAccessory.displayName = device.deviceName;
891
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
891
892
  existingAccessory.context.firmwareRevision = device.firmware;
892
893
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
893
894
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -942,7 +943,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
942
943
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
943
944
  existingAccessory.context.model = device.deviceType;
944
945
  existingAccessory.context.deviceID = device.deviceId;
945
- existingAccessory.displayName = device.deviceName;
946
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
946
947
  existingAccessory.context.firmwareRevision = device.firmware;
947
948
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
948
949
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -1023,7 +1024,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1023
1024
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1024
1025
  existingAccessory.context.model = device.deviceType;
1025
1026
  existingAccessory.context.deviceID = device.deviceId;
1026
- existingAccessory.displayName = device.deviceName;
1027
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1027
1028
  existingAccessory.context.firmwareRevision = device.firmware;
1028
1029
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1029
1030
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -1078,7 +1079,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1078
1079
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1079
1080
  existingAccessory.context.model = device.deviceType;
1080
1081
  existingAccessory.context.deviceID = device.deviceId;
1081
- existingAccessory.displayName = device.deviceName;
1082
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1082
1083
  existingAccessory.context.firmwareRevision = device.firmware;
1083
1084
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1084
1085
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -1133,7 +1134,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1133
1134
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1134
1135
  existingAccessory.context.model = device.deviceType;
1135
1136
  existingAccessory.context.deviceID = device.deviceId;
1136
- existingAccessory.displayName = device.deviceName;
1137
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1137
1138
  existingAccessory.context.firmwareRevision = device.firmware;
1138
1139
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1139
1140
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -1188,7 +1189,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1188
1189
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1189
1190
  existingAccessory.context.model = device.deviceType;
1190
1191
  existingAccessory.context.deviceID = device.deviceId;
1191
- existingAccessory.displayName = device.deviceName;
1192
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1192
1193
  existingAccessory.context.firmwareRevision = device.firmware;
1193
1194
  existingAccessory.context.deviceType = `SwitchBot: ${device.deviceType}`;
1194
1195
  await this.connectionTypeExistingAccessory(device, existingAccessory);
@@ -1241,7 +1242,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1241
1242
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1242
1243
  existingAccessory.context.model = device.remoteType;
1243
1244
  existingAccessory.context.deviceID = device.deviceId;
1244
- existingAccessory.displayName = device.deviceName;
1245
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1245
1246
  existingAccessory.context.firmwareRevision = device.firmware;
1246
1247
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1247
1248
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1298,7 +1299,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1298
1299
 
1299
1300
  existingAccessory.context.model = device.remoteType;
1300
1301
  existingAccessory.context.deviceID = device.deviceId;
1301
- existingAccessory.displayName = device.deviceName;
1302
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1302
1303
  existingAccessory.context.firmwareRevision = device.firmware;
1303
1304
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1304
1305
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1353,7 +1354,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1353
1354
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1354
1355
  existingAccessory.context.model = device.remoteType;
1355
1356
  existingAccessory.context.deviceID = device.deviceId;
1356
- existingAccessory.displayName = device.deviceName;
1357
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1357
1358
  existingAccessory.context.firmwareRevision = device.firmware;
1358
1359
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1359
1360
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1408,7 +1409,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1408
1409
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1409
1410
  existingAccessory.context.model = device.remoteType;
1410
1411
  existingAccessory.context.deviceID = device.deviceId;
1411
- existingAccessory.displayName = device.deviceName;
1412
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1412
1413
  existingAccessory.context.firmwareRevision = device.firmware;
1413
1414
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1414
1415
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1463,7 +1464,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1463
1464
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1464
1465
  existingAccessory.context.model = device.remoteType;
1465
1466
  existingAccessory.context.deviceID = device.deviceId;
1466
- existingAccessory.displayName = device.deviceName;
1467
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1467
1468
  existingAccessory.context.firmwareRevision = device.firmware;
1468
1469
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1469
1470
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1518,7 +1519,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1518
1519
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1519
1520
  existingAccessory.context.model = device.remoteType;
1520
1521
  existingAccessory.context.deviceID = device.deviceId;
1521
- existingAccessory.displayName = device.deviceName;
1522
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1522
1523
  existingAccessory.context.firmwareRevision = device.firmware;
1523
1524
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1524
1525
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1573,7 +1574,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1573
1574
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1574
1575
  existingAccessory.context.model = device.remoteType;
1575
1576
  existingAccessory.context.deviceID = device.deviceId;
1576
- existingAccessory.displayName = device.deviceName;
1577
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1577
1578
  existingAccessory.context.firmwareRevision = device.firmware;
1578
1579
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1579
1580
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1628,7 +1629,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1628
1629
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1629
1630
  existingAccessory.context.model = device.remoteType;
1630
1631
  existingAccessory.context.deviceID = device.deviceId;
1631
- existingAccessory.displayName = device.deviceName;
1632
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1632
1633
  existingAccessory.context.firmwareRevision = device.firmware;
1633
1634
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1634
1635
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1683,7 +1684,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1683
1684
  // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
1684
1685
  existingAccessory.context.model = device.remoteType;
1685
1686
  existingAccessory.context.deviceID = device.deviceId;
1686
- existingAccessory.displayName = device.deviceName;
1687
+ existingAccessory.displayName = device.configDeviceName || device.deviceName;
1687
1688
  existingAccessory.context.firmwareRevision = device.firmware;
1688
1689
  existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
1689
1690
  await this.connectionTypeExistingIRAccessory(existingAccessory);
@@ -1787,13 +1788,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1787
1788
 
1788
1789
  public deviceListInfo(devices) {
1789
1790
  if (this.platformLogging?.includes('debug')) {
1790
- this.warnLog(`deviceListInfoStatus: ${JSON.stringify(devices)}`);
1791
+ this.warnLog(`deviceListInfoStatus: ${superStringify(devices)}`);
1791
1792
  }
1792
1793
  }
1793
1794
 
1794
1795
  public async deviceInfo(device: (irdevice & devicesConfig) | (device & devicesConfig)) {
1795
1796
  if (this.platformLogging?.includes('debug')) {
1796
- this.warnLog(JSON.stringify(device));
1797
+ this.warnLog(superStringify(device));
1797
1798
 
1798
1799
  const t = Date.now();
1799
1800
  const nonce = 'requestID';
@@ -1827,9 +1828,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
1827
1828
 
1828
1829
  this.deviceStatus = req;
1829
1830
  if (this.deviceStatus.message === 'success') {
1830
- this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus)}`);
1831
+ this.warnLog(`${device.deviceName} deviceInfoStatus: ${superStringify(this.deviceStatus)}`);
1831
1832
  } else {
1832
- this.warnLog(`${device.deviceName} deviceInfoStatus: ${JSON.stringify(this.deviceStatus.message)}`);
1833
+ this.warnLog(`${device.deviceName} deviceInfoStatus: ${superStringify(this.deviceStatus.message)}`);
1833
1834
  this.warnLog('Unable to retreive deviceInfoStatus.');
1834
1835
  }
1835
1836
  }