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

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 (106) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/config.schema.json +11 -2
  3. package/dist/device/bot.d.ts +2 -0
  4. package/dist/device/bot.d.ts.map +1 -1
  5. package/dist/device/bot.js +201 -163
  6. package/dist/device/bot.js.map +1 -1
  7. package/dist/device/colorbulb.d.ts +2 -0
  8. package/dist/device/colorbulb.d.ts.map +1 -1
  9. package/dist/device/colorbulb.js +250 -218
  10. package/dist/device/colorbulb.js.map +1 -1
  11. package/dist/device/contact.d.ts +2 -0
  12. package/dist/device/contact.d.ts.map +1 -1
  13. package/dist/device/contact.js +85 -66
  14. package/dist/device/contact.js.map +1 -1
  15. package/dist/device/curtain.d.ts +2 -0
  16. package/dist/device/curtain.d.ts.map +1 -1
  17. package/dist/device/curtain.js +166 -136
  18. package/dist/device/curtain.js.map +1 -1
  19. package/dist/device/humidifier.d.ts.map +1 -1
  20. package/dist/device/humidifier.js +126 -115
  21. package/dist/device/humidifier.js.map +1 -1
  22. package/dist/device/lock.d.ts +2 -0
  23. package/dist/device/lock.d.ts.map +1 -1
  24. package/dist/device/lock.js +156 -130
  25. package/dist/device/lock.js.map +1 -1
  26. package/dist/device/meter.d.ts +2 -0
  27. package/dist/device/meter.d.ts.map +1 -1
  28. package/dist/device/meter.js +85 -64
  29. package/dist/device/meter.js.map +1 -1
  30. package/dist/device/meterplus.d.ts +2 -0
  31. package/dist/device/meterplus.d.ts.map +1 -1
  32. package/dist/device/meterplus.js +78 -59
  33. package/dist/device/meterplus.js.map +1 -1
  34. package/dist/device/motion.d.ts +2 -0
  35. package/dist/device/motion.d.ts.map +1 -1
  36. package/dist/device/motion.js +76 -57
  37. package/dist/device/motion.js.map +1 -1
  38. package/dist/device/plug.d.ts +2 -0
  39. package/dist/device/plug.d.ts.map +1 -1
  40. package/dist/device/plug.js +133 -107
  41. package/dist/device/plug.js.map +1 -1
  42. package/dist/device/striplight.d.ts +2 -0
  43. package/dist/device/striplight.d.ts.map +1 -1
  44. package/dist/device/striplight.js +224 -195
  45. package/dist/device/striplight.js.map +1 -1
  46. package/dist/irdevice/airconditioner.d.ts +2 -0
  47. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  48. package/dist/irdevice/airconditioner.js +127 -105
  49. package/dist/irdevice/airconditioner.js.map +1 -1
  50. package/dist/irdevice/airpurifier.d.ts +2 -0
  51. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  52. package/dist/irdevice/airpurifier.js +83 -66
  53. package/dist/irdevice/airpurifier.js.map +1 -1
  54. package/dist/irdevice/camera.d.ts +8 -6
  55. package/dist/irdevice/camera.d.ts.map +1 -1
  56. package/dist/irdevice/camera.js +83 -68
  57. package/dist/irdevice/camera.js.map +1 -1
  58. package/dist/irdevice/fan.d.ts +7 -5
  59. package/dist/irdevice/fan.d.ts.map +1 -1
  60. package/dist/irdevice/fan.js +90 -75
  61. package/dist/irdevice/fan.js.map +1 -1
  62. package/dist/irdevice/light.d.ts +8 -6
  63. package/dist/irdevice/light.d.ts.map +1 -1
  64. package/dist/irdevice/light.js +83 -68
  65. package/dist/irdevice/light.js.map +1 -1
  66. package/dist/irdevice/other.d.ts +8 -6
  67. package/dist/irdevice/other.d.ts.map +1 -1
  68. package/dist/irdevice/other.js +93 -78
  69. package/dist/irdevice/other.js.map +1 -1
  70. package/dist/irdevice/tv.d.ts +8 -6
  71. package/dist/irdevice/tv.d.ts.map +1 -1
  72. package/dist/irdevice/tv.js +68 -52
  73. package/dist/irdevice/tv.js.map +1 -1
  74. package/dist/irdevice/vacuumcleaner.d.ts +8 -6
  75. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  76. package/dist/irdevice/vacuumcleaner.js +83 -69
  77. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  78. package/dist/irdevice/waterheater.d.ts +2 -0
  79. package/dist/irdevice/waterheater.d.ts.map +1 -1
  80. package/dist/irdevice/waterheater.js +75 -60
  81. package/dist/irdevice/waterheater.js.map +1 -1
  82. package/dist/settings.d.ts +12 -11
  83. package/dist/settings.d.ts.map +1 -1
  84. package/dist/settings.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/device/bot.ts +200 -163
  87. package/src/device/colorbulb.ts +252 -221
  88. package/src/device/contact.ts +85 -66
  89. package/src/device/curtain.ts +165 -136
  90. package/src/device/humidifier.ts +126 -115
  91. package/src/device/lock.ts +156 -131
  92. package/src/device/meter.ts +85 -64
  93. package/src/device/meterplus.ts +78 -59
  94. package/src/device/motion.ts +76 -57
  95. package/src/device/plug.ts +132 -107
  96. package/src/device/striplight.ts +226 -198
  97. package/src/irdevice/airconditioner.ts +126 -103
  98. package/src/irdevice/airpurifier.ts +84 -66
  99. package/src/irdevice/camera.ts +84 -68
  100. package/src/irdevice/fan.ts +91 -75
  101. package/src/irdevice/light.ts +84 -68
  102. package/src/irdevice/other.ts +94 -78
  103. package/src/irdevice/tv.ts +69 -53
  104. package/src/irdevice/vacuumcleaner.ts +83 -68
  105. package/src/irdevice/waterheater.ts +76 -60
  106. package/src/settings.ts +12 -11
package/src/device/bot.ts CHANGED
@@ -53,6 +53,7 @@ export class Bot {
53
53
  scanDuration!: number;
54
54
  deviceLogging!: string;
55
55
  deviceRefreshRate!: number;
56
+ OpenAPI?: boolean;
56
57
 
57
58
  // Others
58
59
  doublePress!: number;
@@ -64,6 +65,7 @@ export class Bot {
64
65
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
65
66
  // default placeholders
66
67
  this.logs(device);
68
+ this.openAPI();
67
69
  this.scan(device);
68
70
  this.refreshRate(device);
69
71
  this.PressOrSwitch(device);
@@ -117,7 +119,7 @@ export class Bot {
117
119
  // Add switchService
118
120
  (this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
119
121
  `${accessory.displayName} Switch`;
120
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Switch`);
122
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Switch`);
121
123
 
122
124
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
123
125
  this.switchService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
@@ -136,7 +138,7 @@ export class Bot {
136
138
  (this.garageDoorService =
137
139
  accessory.getService(this.platform.Service.GarageDoorOpener) || accessory.addService(this.platform.Service.GarageDoorOpener)),
138
140
  `${accessory.displayName} Garage Door Opener`;
139
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Garage Door Opener`);
141
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Garage Door Opener`);
140
142
 
141
143
  this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
142
144
  this.garageDoorService.getCharacteristic(this.platform.Characteristic.TargetDoorState).onSet(this.handleOnSet.bind(this));
@@ -155,7 +157,7 @@ export class Bot {
155
157
  // Add switchService
156
158
  (this.doorService = accessory.getService(this.platform.Service.Door) || accessory.addService(this.platform.Service.Door)),
157
159
  `${accessory.displayName} Door`;
158
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Door`);
160
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Door`);
159
161
 
160
162
  this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
161
163
  this.doorService
@@ -182,7 +184,7 @@ export class Bot {
182
184
  // Add switchService
183
185
  (this.windowService = accessory.getService(this.platform.Service.Window) || accessory.addService(this.platform.Service.Window)),
184
186
  `${accessory.displayName} Window`;
185
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Window`);
187
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window`);
186
188
 
187
189
  this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
188
190
  this.windowService
@@ -210,7 +212,7 @@ export class Bot {
210
212
  (this.windowCoveringService =
211
213
  accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
212
214
  `${accessory.displayName} Window Covering`;
213
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Window Covering`);
215
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Window Covering`);
214
216
 
215
217
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
216
218
  this.windowCoveringService
@@ -237,7 +239,7 @@ export class Bot {
237
239
  // Add switchService
238
240
  (this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
239
241
  `${accessory.displayName} Lock`;
240
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Lock`);
242
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Lock`);
241
243
 
242
244
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
243
245
  this.lockService.getCharacteristic(this.platform.Characteristic.LockTargetState).onSet(this.handleOnSet.bind(this));
@@ -255,7 +257,7 @@ export class Bot {
255
257
  // Add switchService
256
258
  (this.faucetService = accessory.getService(this.platform.Service.Faucet) || accessory.addService(this.platform.Service.Faucet)),
257
259
  `${accessory.displayName} Faucet`;
258
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Faucet`);
260
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Faucet`);
259
261
 
260
262
  this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
261
263
  this.faucetService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.handleOnSet.bind(this));
@@ -273,7 +275,7 @@ export class Bot {
273
275
  // Add switchService
274
276
  (this.fanService = accessory.getService(this.platform.Service.Fan) || accessory.addService(this.platform.Service.Fan)),
275
277
  `${accessory.displayName} Fan`;
276
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Fan`);
278
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Fan`);
277
279
 
278
280
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
279
281
  this.fanService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
@@ -293,7 +295,7 @@ export class Bot {
293
295
  accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
294
296
  accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
295
297
  `${accessory.displayName} Stateful Programmable Switch`;
296
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
298
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
297
299
 
298
300
  this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
299
301
  this.statefulProgrammableSwitchService
@@ -313,7 +315,7 @@ export class Bot {
313
315
  // Add outletService
314
316
  (this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
315
317
  `${accessory.displayName} Outlet`;
316
- this.infoLog(`Bot: ${accessory.displayName} Displaying as Outlet`);
318
+ this.infoLog(`${this.device.deviceType}: ${accessory.displayName} Displaying as Outlet`);
317
319
 
318
320
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
319
321
  this.outletService.getCharacteristic(this.platform.Characteristic.On).onSet(this.handleOnSet.bind(this));
@@ -321,17 +323,17 @@ export class Bot {
321
323
 
322
324
  // Battery Service
323
325
  if (!device.ble) {
324
- this.debugLog(`Bot: ${accessory.displayName} Removing Battery Service`);
326
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Removing Battery Service`);
325
327
  this.batteryService = this.accessory.getService(this.platform.Service.Battery);
326
328
  accessory.removeService(this.batteryService!);
327
329
  } else if (device.ble && !this.batteryService) {
328
- this.debugLog(`Bot: ${accessory.displayName} Add Battery Service`);
330
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Add Battery Service`);
329
331
  (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
330
332
  `${accessory.displayName} Battery`;
331
333
 
332
334
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
333
335
  } else {
334
- this.debugLog(`Bot: ${accessory.displayName} Battery Service Not Added`);
336
+ this.debugLog(`${this.device.deviceType}: ${accessory.displayName} Battery Service Not Added`);
335
337
  }
336
338
 
337
339
  // Retrieve initial values and updateHomekit
@@ -361,12 +363,13 @@ export class Bot {
361
363
  await this.pushChanges();
362
364
  });
363
365
  } catch (e: any) {
364
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges`);
366
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
365
367
  if (this.deviceLogging.includes('debug')) {
366
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${superStringify(e.message)}`);
368
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,`
369
+ + ` Error Message: ${superStringify(e.message)}`);
367
370
  }
368
371
  if (this.platform.debugMode) {
369
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${superStringify(e)}`);
372
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${superStringify(e)}`);
370
373
  }
371
374
  }
372
375
  this.botUpdateInProgress = false;
@@ -385,18 +388,18 @@ export class Bot {
385
388
  }
386
389
 
387
390
  async BLEparseStatus(): Promise<void> {
388
- this.debugLog(`Bot: ${this.accessory.displayName} BLE parseStatus`);
391
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
389
392
  // BLEmode (true if Switch Mode) | (false if Press Mode)
390
393
  if (this.mode) {
391
394
  this.accessory.context.On = this.On;
392
395
  if (this.On === undefined) {
393
396
  this.On = Boolean(this.state);
394
397
  }
395
- this.debugLog(`Bot: ${this.accessory.displayName} Switch Mode, mode: ${this.mode}, On: ${this.On}`);
398
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, mode: ${this.mode}, On: ${this.On}`);
396
399
  } else {
397
400
  this.On = false;
398
401
  this.accessory.context.On = this.On;
399
- this.debugLog(`Bot: ${this.accessory.displayName} Press Mode, mode: ${this.mode}, On: ${this.On}`);
402
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode, mode: ${this.mode}, On: ${this.On}`);
400
403
  }
401
404
 
402
405
  this.BatteryLevel = Number(this.battery);
@@ -408,7 +411,7 @@ export class Bot {
408
411
  if (Number.isNaN(this.BatteryLevel)) {
409
412
  this.BatteryLevel = 100;
410
413
  }
411
- this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
414
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
412
415
  }
413
416
 
414
417
  async openAPIparseStatus(): Promise<void> {
@@ -416,7 +419,7 @@ export class Bot {
416
419
  this.SwitchToOpenAPI = false;
417
420
  }
418
421
  if (this.platform.config.credentials?.token) {
419
- this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
422
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI parseStatus`);
420
423
  if (this.botMode === 'press') {
421
424
  this.On = false;
422
425
  this.accessory.context.On = this.On;
@@ -426,7 +429,7 @@ export class Bot {
426
429
  this.On = false;
427
430
  }
428
431
  }
429
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
432
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
430
433
  }
431
434
  }
432
435
 
@@ -442,18 +445,18 @@ export class Bot {
442
445
  }
443
446
 
444
447
  async BLERefreshStatus(): Promise<void> {
445
- this.debugLog(`Bot: ${this.accessory.displayName} BLE refreshStatus`);
448
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE refreshStatus`);
446
449
  const switchbot = await this.platform.connectBLE();
447
450
  // Convert to BLE Address
448
451
  this.device.bleMac = this.device
449
452
  .deviceId!.match(/.{1,2}/g)!
450
453
  .join(':')
451
454
  .toLowerCase();
452
- this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
455
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
453
456
  this.getCustomBLEAddress(switchbot);
454
457
  // Start to monitor advertisement packets
455
458
  if (switchbot === false) {
456
- this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
459
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
457
460
  }
458
461
  switchbot
459
462
  .startScan({
@@ -467,25 +470,25 @@ export class Bot {
467
470
  if (this.deviceLogging.includes('debug')) {
468
471
  this.infoLog(this.address);
469
472
  this.infoLog(this.device.bleMac);
470
- this.infoLog(`Bot: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
471
- this.infoLog(`Bot: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
473
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
474
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
472
475
  }
473
476
  this.serviceData = ad.serviceData;
474
477
  this.mode = ad.serviceData.mode;
475
478
  this.state = ad.serviceData.state;
476
479
  this.battery = ad.serviceData.battery;
477
- this.debugLog(`Bot: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
480
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
478
481
  this.debugLog(
479
- `Bot: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
482
+ `${this.device.deviceType}: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
480
483
  ` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`,
481
484
  );
482
485
 
483
486
  if (this.serviceData) {
484
487
  this.connected = true;
485
- this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
488
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
486
489
  } else {
487
490
  this.connected = false;
488
- this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
491
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
489
492
  }
490
493
  };
491
494
  // Wait 2 seconds
@@ -498,23 +501,24 @@ export class Bot {
498
501
  this.parseStatus();
499
502
  this.updateHomeKitCharacteristics();
500
503
  } else {
501
- this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
504
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
502
505
  if (this.platform.config.credentials?.token) {
503
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
506
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
504
507
  this.SwitchToOpenAPI = true;
505
508
  await this.openAPIRefreshStatus();
506
509
  }
507
510
  }
508
511
  })
509
512
  .catch(async (e: any) => {
510
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
513
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
511
514
  if (this.deviceLogging.includes('debug')) {
512
515
  this.errorLog(
513
- `Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${superStringify(e.message)}`,
516
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
517
+ + ` Error Message: ${superStringify(e.message)}`,
514
518
  );
515
519
  }
516
520
  if (this.platform.config.credentials?.token) {
517
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
521
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
518
522
  this.SwitchToOpenAPI = true;
519
523
  await this.openAPIRefreshStatus();
520
524
  }
@@ -531,7 +535,7 @@ export class Bot {
531
535
  });
532
536
  // Set an event handler
533
537
  switchbot.onadvertisement = (ad: any) => {
534
- this.warnLog(`Bot: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
538
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
535
539
  };
536
540
  await switchbot.wait(10000);
537
541
  // Stop to monitor
@@ -541,15 +545,15 @@ export class Bot {
541
545
  }
542
546
 
543
547
  async openAPIRefreshStatus(): Promise<void> {
544
- if (this.platform.config.credentials?.token) {
545
- this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI refreshStatus`);
548
+ if (this.platform.config.credentials?.token && this.OpenAPI) {
549
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI refreshStatus`);
546
550
  try {
547
551
  const t = Date.now();
548
552
  const nonce = 'requestID';
549
553
  const data = this.platform.config.credentials?.token + t + nonce;
550
554
  const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
551
555
  const sign = signTerm.toString('base64');
552
- this.debugLog(`Bot: ${this.accessory.displayName} sign: ${sign}`);
556
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
553
557
  const options = {
554
558
  hostname: HostDomain,
555
559
  port: 443,
@@ -564,7 +568,7 @@ export class Bot {
564
568
  },
565
569
  };
566
570
  const req = https.request(options, (res) => {
567
- this.debugLog(`Bot: ${this.accessory.displayName} Refresh statusCode: ${res.statusCode}`);
571
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Refresh statusCode: ${res.statusCode}`);
568
572
  let rawData = '';
569
573
  res.on('data', (d) => {
570
574
  rawData += d;
@@ -573,31 +577,35 @@ export class Bot {
573
577
  res.on('end', () => {
574
578
  try {
575
579
  this.deviceStatus = JSON.parse(rawData);
576
- this.debugLog(`Bot: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
580
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
577
581
  this.power = this.deviceStatus.body.power;
578
582
  this.parseStatus();
579
583
  this.updateHomeKitCharacteristics();
580
584
  } catch (e: any) {
581
- this.errorLog(`Bot: ${this.accessory.displayName} error message: ${e.message}`);
585
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
582
586
  }
583
587
  });
584
588
  });
585
589
  req.on('error', (e: any) => {
586
- this.errorLog(`Bot: ${this.accessory.displayName} error message: ${e.message}`);
590
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
587
591
  });
588
592
  req.end();
589
593
  } catch (e: any) {
590
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
594
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
591
595
  if (this.deviceLogging.includes('debug')) {
592
596
  this.errorLog(
593
- `Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
597
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
598
+ + ` Error Message: ${superStringify(e.message)}`,
594
599
  );
595
600
  }
596
601
  if (this.platform.debugMode) {
597
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${superStringify(e)}`);
602
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
603
+ + ` Error: ${superStringify(e)}`);
598
604
  }
599
605
  this.apiError(e);
600
606
  }
607
+ } else {
608
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
601
609
  }
602
610
  }
603
611
 
@@ -622,27 +630,27 @@ export class Bot {
622
630
  }
623
631
 
624
632
  async BLEpushChanges(): Promise<void> {
625
- this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
633
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.accessory.context.On}`);
626
634
  if (this.On !== this.accessory.context.On || this.allowPush) {
627
- this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
635
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE pushChanges`);
628
636
  const switchbot = await this.platform.connectBLE();
629
637
  // Convert to BLE Address
630
638
  this.device.bleMac = this.device
631
639
  .deviceId!.match(/.{1,2}/g)!
632
640
  .join(':')
633
641
  .toLowerCase();
634
- this.debugLog(`Bot: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
642
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
635
643
  //if (switchbot !== false) {
636
644
  if (this.botMode === 'press') {
637
- this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
645
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
638
646
  switchbot
639
647
  .discover({ model: 'H', quick: true, id: this.device.bleMac })
640
648
  .then((device_list: { press: (arg0: { id: string | undefined }) => any }[]) => {
641
- this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
649
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
642
650
  return device_list[0].press({ id: this.device.bleMac });
643
651
  })
644
652
  .then(() => {
645
- this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
653
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
646
654
  this.accessory.context.On = this.On;
647
655
  setTimeout(() => {
648
656
  if (this.device.bot?.deviceType === 'switch') {
@@ -650,55 +658,59 @@ export class Bot {
650
658
  } else {
651
659
  this.outletService?.getCharacteristic(this.platform.Characteristic.On).updateValue(this.On);
652
660
  }
653
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
661
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
654
662
  }, 500);
655
663
  })
656
664
  .catch(async (e: any) => {
657
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
665
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
658
666
  if (this.deviceLogging.includes('debug')) {
659
667
  this.errorLog(
660
- `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${superStringify(e.message)}`,
668
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
669
+ + ` Error Message: ${superStringify(e.message)}`,
661
670
  );
662
671
  }
663
672
  if (this.platform.debugMode) {
664
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${superStringify(e)}`);
673
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
674
+ + ` Error: ${superStringify(e)}`);
665
675
  }
666
676
  if (this.platform.config.credentials?.token) {
667
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
677
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
668
678
  await this.openAPIpushChanges();
669
679
  }
670
680
  this.apiError(e);
671
681
  });
672
682
  } else if (this.botMode === 'switch') {
673
- this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
683
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
674
684
  switchbot
675
685
  .discover({ model: 'H', quick: true, id: this.device.bleMac })
676
686
  .then((device_list: any) => {
677
- this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
687
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
678
688
  return this.turnOnOff(device_list);
679
689
  })
680
690
  .then(() => {
681
- this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
691
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Done.`);
682
692
  this.accessory.context.On = this.On;
683
693
  })
684
694
  .catch(async (e: any) => {
685
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
695
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
686
696
  if (this.deviceLogging.includes('debug')) {
687
697
  this.errorLog(
688
- `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${superStringify(e.message)}`,
698
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
699
+ + ` Error Message: ${superStringify(e.message)}`,
689
700
  );
690
701
  }
691
702
  if (this.platform.debugMode) {
692
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${superStringify(e)}`);
703
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
704
+ + ` Error: ${superStringify(e)}`);
693
705
  }
694
706
  if (this.platform.config.credentials?.token) {
695
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
707
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
696
708
  await this.openAPIpushChanges();
697
709
  }
698
710
  this.apiError(e);
699
711
  });
700
712
  } else {
701
- throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
713
+ throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
702
714
  }
703
715
  }
704
716
  this.accessory.context.On = this.On;
@@ -718,10 +730,10 @@ export class Bot {
718
730
  }
719
731
 
720
732
  async openAPIpushChanges(): Promise<void> {
721
- if (this.platform.config.credentials?.token) {
733
+ if (this.platform.config.credentials?.token && this.OpenAPI) {
722
734
  try {
723
735
  if (this.On !== this.accessory.context.On || this.allowPush) {
724
- this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI pushChanges`);
736
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI pushChanges`);
725
737
  // Make Push On request to the API
726
738
  const t = Date.now();
727
739
  const nonce = 'requestID';
@@ -730,29 +742,29 @@ export class Bot {
730
742
  .update(Buffer.from(data, 'utf-8'))
731
743
  .digest();
732
744
  const sign = signTerm.toString('base64');
733
- this.debugLog(`Bot: ${this.accessory.displayName} sign: ${sign}`);
745
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
734
746
  let command = '';
735
747
  if (this.botMode === 'switch' && this.On) {
736
748
  command = 'turnOn';
737
749
  this.On = true;
738
- this.debugLog(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
750
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
739
751
  } else if (this.botMode === 'switch' && !this.On) {
740
752
  command = 'turnOff';
741
753
  this.On = false;
742
- this.debugLog(`Bot: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
754
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Switch Mode, Turning ${this.On}`);
743
755
  } else if (this.botMode === 'press') {
744
756
  command = 'press';
745
- this.debugLog(`Bot: ${this.accessory.displayName} Press Mode`);
757
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Press Mode`);
746
758
  this.On = false;
747
759
  } else {
748
- throw new Error(`Bot: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
760
+ throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
749
761
  }
750
762
  const body = superStringify({
751
763
  'command': `${command}`,
752
764
  'parameter': 'default',
753
765
  'commandType': 'command',
754
766
  });
755
- this.infoLog(`Bot: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
767
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
756
768
  const options = {
757
769
  hostname: HostDomain,
758
770
  port: 443,
@@ -768,32 +780,38 @@ export class Bot {
768
780
  },
769
781
  };
770
782
  const req = https.request(options, res => {
771
- this.debugLog(`Bot: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
783
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
772
784
  this.statusCode({ res });
773
785
  res.on('data', d => {
774
- this.debugLog(`Bot: ${this.accessory.displayName} d: ${d}`);
786
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
775
787
  });
776
788
  });
777
789
  req.on('error', (e: any) => {
778
- this.errorLog(`Bot: ${this.accessory.displayName} error message: ${e.message}`);
790
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
779
791
  });
780
792
  req.write(body);
781
793
  req.end();
782
- this.debugLog(`Bot: ${this.accessory.displayName} openAPIpushChanges: ${superStringify(req)}`);
794
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges: ${superStringify(req)}`);
783
795
  this.accessory.context.On = this.On;
784
796
  }
785
797
  } catch (e: any) {
786
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
798
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
787
799
  if (this.deviceLogging.includes('debug')) {
788
800
  this.errorLog(
789
- `Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
801
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
802
+ + ` Error Message: ${superStringify(e.message)}`,
790
803
  );
791
804
  }
792
805
  if (this.platform.debugMode) {
793
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${superStringify(e)}`);
806
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
807
+ + ` Error: ${superStringify(e)}`);
794
808
  }
795
809
  this.apiError(e);
796
810
  }
811
+ } else {
812
+ if (this.deviceLogging.includes('debug')) {
813
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, device status will not be sent.`);
814
+ }
797
815
  }
798
816
  }
799
817
 
@@ -803,7 +821,7 @@ export class Bot {
803
821
  async updateHomeKitCharacteristics(): Promise<void> {
804
822
  if (this.device.bot?.deviceType === 'garagedoor') {
805
823
  if (this.On === undefined) {
806
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
824
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
807
825
  } else {
808
826
  if (this.On) {
809
827
  this.garageDoorService?.updateCharacteristic(
@@ -814,7 +832,8 @@ export class Bot {
814
832
  this.platform.Characteristic.CurrentDoorState,
815
833
  this.platform.Characteristic.CurrentDoorState.OPEN,
816
834
  );
817
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
835
+ this.debugLog(`${this.device.deviceType}: `
836
+ + `${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
818
837
  } else {
819
838
  this.garageDoorService?.updateCharacteristic(
820
839
  this.platform.Characteristic.TargetDoorState,
@@ -824,47 +843,48 @@ export class Bot {
824
843
  this.platform.Characteristic.CurrentDoorState,
825
844
  this.platform.Characteristic.CurrentDoorState.CLOSED,
826
845
  );
827
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
846
+ this.debugLog(`${this.device.deviceType}: `
847
+ +`${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
828
848
  }
829
849
  }
830
- this.debugLog(`Bot: ${this.accessory.displayName} Garage Door On: ${this.On}`);
850
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Garage Door On: ${this.On}`);
831
851
  } else if (this.device.bot?.deviceType === 'door') {
832
852
  if (this.On === undefined) {
833
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
853
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
834
854
  } else {
835
855
  if (this.On) {
836
856
  this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
837
857
  this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
838
858
  this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
839
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
859
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
840
860
  } else {
841
861
  this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
842
862
  this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
843
863
  this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
844
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
864
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
845
865
  }
846
866
  }
847
- this.debugLog(`Bot: ${this.accessory.displayName} Door On: ${this.On}`);
867
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Door On: ${this.On}`);
848
868
  } else if (this.device.bot?.deviceType === 'window') {
849
869
  if (this.On === undefined) {
850
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
870
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
851
871
  } else {
852
872
  if (this.On) {
853
873
  this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
854
874
  this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
855
875
  this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
856
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
876
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
857
877
  } else {
858
878
  this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
859
879
  this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
860
880
  this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
861
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
881
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
862
882
  }
863
883
  }
864
- this.debugLog(`Bot: ${this.accessory.displayName} Window On: ${this.On}`);
884
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window On: ${this.On}`);
865
885
  } else if (this.device.bot?.deviceType === 'windowcovering') {
866
886
  if (this.On === undefined) {
867
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
887
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
868
888
  } else {
869
889
  if (this.On) {
870
890
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
@@ -873,7 +893,7 @@ export class Bot {
873
893
  this.platform.Characteristic.PositionState,
874
894
  this.platform.Characteristic.PositionState.STOPPED,
875
895
  );
876
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
896
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
877
897
  } else {
878
898
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
879
899
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
@@ -881,13 +901,13 @@ export class Bot {
881
901
  this.platform.Characteristic.PositionState,
882
902
  this.platform.Characteristic.PositionState.STOPPED,
883
903
  );
884
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
904
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
885
905
  }
886
906
  }
887
- this.debugLog(`Bot: ${this.accessory.displayName} Window Covering On: ${this.On}`);
907
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Window Covering On: ${this.On}`);
888
908
  } else if (this.device.bot?.deviceType === 'lock') {
889
909
  if (this.On === undefined) {
890
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
910
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
891
911
  } else {
892
912
  if (this.On) {
893
913
  this.lockService?.updateCharacteristic(
@@ -898,46 +918,48 @@ export class Bot {
898
918
  this.platform.Characteristic.LockCurrentState,
899
919
  this.platform.Characteristic.LockCurrentState.UNSECURED,
900
920
  );
901
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
921
+ this.debugLog(`${this.device.deviceType}: `
922
+ + `${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
902
923
  } else {
903
924
  this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
904
925
  this.lockService?.updateCharacteristic(
905
926
  this.platform.Characteristic.LockCurrentState,
906
927
  this.platform.Characteristic.LockCurrentState.SECURED,
907
928
  );
908
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
929
+ this.debugLog(`${this.device.deviceType}: `
930
+ + `${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
909
931
  }
910
932
  }
911
- this.debugLog(`Bot: ${this.accessory.displayName} Lock On: ${this.On}`);
933
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Lock On: ${this.On}`);
912
934
  } else if (this.device.bot?.deviceType === 'faucet') {
913
935
  if (this.On === undefined) {
914
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
936
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
915
937
  } else {
916
938
  if (this.On) {
917
939
  this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
918
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
940
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
919
941
  } else {
920
942
  this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
921
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
943
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
922
944
  }
923
945
  }
924
- this.debugLog(`Bot: ${this.accessory.displayName} Faucet On: ${this.On}`);
946
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Faucet On: ${this.On}`);
925
947
  } else if (this.device.bot?.deviceType === 'fan') {
926
948
  if (this.On === undefined) {
927
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
949
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
928
950
  } else {
929
951
  if (this.On) {
930
952
  this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
931
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
953
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
932
954
  } else {
933
955
  this.fanService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
934
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
956
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
935
957
  }
936
958
  }
937
- this.debugLog(`Bot: ${this.accessory.displayName} Fan On: ${this.On}`);
959
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Fan On: ${this.On}`);
938
960
  } else if (this.device.bot?.deviceType === 'stateful') {
939
961
  if (this.On === undefined) {
940
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
962
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
941
963
  } else {
942
964
  if (this.On) {
943
965
  this.statefulProgrammableSwitchService?.updateCharacteristic(
@@ -945,47 +967,49 @@ export class Bot {
945
967
  this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
946
968
  );
947
969
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
948
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
970
+ this.debugLog(`${this.device.deviceType}: `
971
+ + `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
949
972
  } else {
950
973
  this.statefulProgrammableSwitchService?.updateCharacteristic(
951
974
  this.platform.Characteristic.ProgrammableSwitchEvent,
952
975
  this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
953
976
  );
954
977
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
955
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
978
+ this.debugLog(`${this.device.deviceType}: `
979
+ + `${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
956
980
  }
957
981
  }
958
- this.debugLog(`Bot: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
982
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatefulProgrammableSwitch On: ${this.On}`);
959
983
  } else if (this.device.bot?.deviceType === 'switch') {
960
984
  if (this.On === undefined) {
961
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
985
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
962
986
  } else {
963
987
  this.switchService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
964
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
988
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
965
989
  }
966
990
  } else {
967
991
  if (this.On === undefined) {
968
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
992
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
969
993
  } else {
970
994
  this.outletService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
971
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
995
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
972
996
  }
973
997
  }
974
998
  this.accessory.context.On = this.On;
975
999
  if (this.device.ble) {
976
1000
  if (this.BatteryLevel === undefined) {
977
- this.debugLog(`Bot: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
1001
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel}`);
978
1002
  } else {
979
1003
  this.accessory.context.BatteryLevel = this.BatteryLevel;
980
1004
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.BatteryLevel, this.BatteryLevel);
981
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
1005
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic BatteryLevel: ${this.BatteryLevel}`);
982
1006
  }
983
1007
  if (this.StatusLowBattery === undefined) {
984
- this.debugLog(`Bot: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
1008
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} StatusLowBattery: ${this.StatusLowBattery}`);
985
1009
  } else {
986
1010
  this.accessory.context.StatusLowBattery = this.StatusLowBattery;
987
1011
  this.batteryService?.updateCharacteristic(this.platform.Characteristic.StatusLowBattery, this.StatusLowBattery);
988
- this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
1012
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic StatusLowBattery: ${this.StatusLowBattery}`);
989
1013
  }
990
1014
  }
991
1015
  }
@@ -1032,33 +1056,33 @@ export class Bot {
1032
1056
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
1033
1057
  switch (res.statusCode) {
1034
1058
  case 151:
1035
- this.errorLog(`Bot: ${this.accessory.displayName} Command not supported by this device type.`);
1059
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
1036
1060
  break;
1037
1061
  case 152:
1038
- this.errorLog(`Bot: ${this.accessory.displayName} Device not found.`);
1062
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
1039
1063
  break;
1040
1064
  case 160:
1041
- this.errorLog(`Bot: ${this.accessory.displayName} Command is not supported.`);
1065
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
1042
1066
  break;
1043
1067
  case 161:
1044
- this.errorLog(`Bot: ${this.accessory.displayName} Device is offline.`);
1068
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
1045
1069
  this.offlineOff();
1046
1070
  break;
1047
1071
  case 171:
1048
- this.errorLog(`Bot: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
1072
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
1049
1073
  this.offlineOff();
1050
1074
  break;
1051
1075
  case 190:
1052
1076
  this.errorLog(
1053
- `Bot: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
1077
+ `${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
1054
1078
  ` Or command: ${superStringify(res)} format is invalid`,
1055
1079
  );
1056
1080
  break;
1057
1081
  case 100:
1058
- this.debugLog(`Bot: ${this.accessory.displayName} Command successfully sent.`);
1082
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
1059
1083
  break;
1060
1084
  default:
1061
- this.debugLog(`Bot: ${this.accessory.displayName} Unknown statusCode.`);
1085
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
1062
1086
  }
1063
1087
  }
1064
1088
 
@@ -1078,7 +1102,7 @@ export class Bot {
1078
1102
  */
1079
1103
  async handleOnSet(value: CharacteristicValue): Promise<void> {
1080
1104
  if (this.device.bot?.deviceType === 'garagedoor') {
1081
- this.debugLog(`Bot: ${this.accessory.displayName} TargetDoorState: ${value}`);
1105
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetDoorState: ${value}`);
1082
1106
  if (value === this.platform.Characteristic.TargetDoorState.CLOSED) {
1083
1107
  this.On = false;
1084
1108
  } else {
@@ -1089,35 +1113,35 @@ export class Bot {
1089
1113
  this.device.bot?.deviceType === 'window' ||
1090
1114
  this.device.bot?.deviceType === 'windowcovering'
1091
1115
  ) {
1092
- this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
1116
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} TargetPosition: ${value}`);
1093
1117
  if (value === 0) {
1094
1118
  this.On = false;
1095
1119
  } else {
1096
1120
  this.On = true;
1097
1121
  }
1098
1122
  } else if (this.device.bot?.deviceType === 'lock') {
1099
- this.debugLog(`Bot: ${this.accessory.displayName} LockTargetState: ${value}`);
1123
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} LockTargetState: ${value}`);
1100
1124
  if (value === this.platform.Characteristic.LockTargetState.SECURED) {
1101
1125
  this.On = false;
1102
1126
  } else {
1103
1127
  this.On = true;
1104
1128
  }
1105
1129
  } else if (this.device.bot?.deviceType === 'faucet') {
1106
- this.debugLog(`Bot: ${this.accessory.displayName} Active: ${value}`);
1130
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Active: ${value}`);
1107
1131
  if (value === this.platform.Characteristic.Active.INACTIVE) {
1108
1132
  this.On = false;
1109
1133
  } else {
1110
1134
  this.On = true;
1111
1135
  }
1112
1136
  } else if (this.device.bot?.deviceType === 'stateful') {
1113
- this.debugLog(`Bot: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
1137
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} ProgrammableSwitchOutputState: ${value}`);
1114
1138
  if (value === 0) {
1115
1139
  this.On = false;
1116
1140
  } else {
1117
1141
  this.On = true;
1118
1142
  }
1119
1143
  } else {
1120
- this.debugLog(`Bot: ${this.accessory.displayName} On: ${value}`);
1144
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${value}`);
1121
1145
  this.On = value;
1122
1146
  }
1123
1147
  this.doBotUpdate.next();
@@ -1153,6 +1177,9 @@ export class Bot {
1153
1177
  if (device.ble) {
1154
1178
  config['ble'] = device.ble;
1155
1179
  }
1180
+ if (device.openAPI !== undefined) {
1181
+ config['openAPI'] = device.openAPI;
1182
+ }
1156
1183
  if (device.logging !== undefined) {
1157
1184
  config['logging'] = device.logging;
1158
1185
  }
@@ -1166,30 +1193,39 @@ export class Bot {
1166
1193
  config['offline'] = device.offline;
1167
1194
  }
1168
1195
  if (Object.entries(config).length !== 0) {
1169
- this.infoLog(`Bot: ${this.accessory.displayName} Config: ${superStringify(config)}`);
1196
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
1170
1197
  }
1171
1198
  }
1172
1199
 
1173
1200
  async refreshRate(device: device & devicesConfig): Promise<void> {
1174
1201
  if (device.refreshRate) {
1175
1202
  this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
1176
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
1203
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
1177
1204
  } else if (this.platform.config.options!.refreshRate) {
1178
1205
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
1179
- this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
1206
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
1207
+ }
1208
+ }
1209
+
1210
+ async openAPI() {
1211
+ if (!this.device.openAPI) {
1212
+ this.OpenAPI = true;
1213
+ } else {
1214
+ this.OpenAPI = this.device.openAPI;
1180
1215
  }
1216
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
1181
1217
  }
1182
1218
 
1183
1219
  async scan(device: device & devicesConfig): Promise<void> {
1184
1220
  if (device.scanDuration) {
1185
1221
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
1186
1222
  if (device.ble) {
1187
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
1223
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
1188
1224
  }
1189
1225
  } else {
1190
1226
  this.scanDuration = this.accessory.context.scanDuration = 1;
1191
1227
  if (this.device.ble) {
1192
- this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
1228
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
1193
1229
  }
1194
1230
  }
1195
1231
  }
@@ -1197,24 +1233,25 @@ export class Bot {
1197
1233
  async logs(device: device & devicesConfig): Promise<void> {
1198
1234
  if (this.platform.debugMode) {
1199
1235
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
1200
- this.debugLog(`Bot: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
1236
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
1201
1237
  } else if (device.logging) {
1202
1238
  this.deviceLogging = this.accessory.context.logging = device.logging;
1203
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
1239
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
1204
1240
  } else if (this.platform.config.options?.logging) {
1205
1241
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
1206
- this.debugLog(`Bot: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
1242
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
1207
1243
  } else {
1208
1244
  this.deviceLogging = this.accessory.context.logging = 'standard';
1209
- this.debugLog(`Bot: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
1245
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
1210
1246
  }
1211
1247
  }
1212
1248
 
1213
1249
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
1214
1250
  let FirmwareRevision: string;
1215
- this.debugLog(`Bot: ${this.accessory.displayName} accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
1216
- this.debugLog(`Bot: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
1217
- this.debugLog(`Bot: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
1251
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
1252
+ + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
1253
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
1254
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
1218
1255
  if (accessory.context.FirmwareRevision) {
1219
1256
  FirmwareRevision = accessory.context.FirmwareRevision;
1220
1257
  } else if (device.firmware) {
@@ -1228,16 +1265,16 @@ export class Bot {
1228
1265
  async PressOrSwitch(device: device & devicesConfig): Promise<void> {
1229
1266
  if (!device.bot?.mode) {
1230
1267
  this.botMode = 'switch';
1231
- this.warnLog(`Bot: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
1232
- this.warnLog(`Bot: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
1268
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} does not have bot mode set in the Plugin's SwitchBot Device Settings,`);
1269
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} is defaulting to "${this.botMode}" mode, you may experience issues.`);
1233
1270
  } else if (device.bot?.mode === 'switch') {
1234
1271
  this.botMode = 'switch';
1235
- this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1272
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1236
1273
  } else if (device.bot?.mode === 'press') {
1237
1274
  this.botMode = 'press';
1238
- this.debugLog(`Bot: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1275
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Bot Mode: ${this.botMode}`);
1239
1276
  } else {
1240
- throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
1277
+ throw new Error(`${this.device.deviceType}: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
1241
1278
  }
1242
1279
  }
1243
1280
 
@@ -1247,14 +1284,14 @@ export class Bot {
1247
1284
  } else {
1248
1285
  this.allowPush = false;
1249
1286
  }
1250
- this.debugLog(`Bot: ${this.accessory.displayName} Allowing Push Changes: ${this.allowPush}`);
1287
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Allowing Push Changes: ${this.allowPush}`);
1251
1288
  }
1252
1289
 
1253
1290
  async removeOutletService(accessory: PlatformAccessory): Promise<void> {
1254
1291
  // If outletService still pressent, then remove first
1255
1292
  this.outletService = this.accessory.getService(this.platform.Service.Outlet);
1256
1293
  if (this.outletService) {
1257
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Outlet Service`);
1294
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Outlet Service`);
1258
1295
  }
1259
1296
  accessory.removeService(this.outletService!);
1260
1297
  }
@@ -1263,7 +1300,7 @@ export class Bot {
1263
1300
  // If garageDoorService still pressent, then remove first
1264
1301
  this.garageDoorService = this.accessory.getService(this.platform.Service.GarageDoorOpener);
1265
1302
  if (this.garageDoorService) {
1266
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Garage Door Service`);
1303
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Garage Door Service`);
1267
1304
  }
1268
1305
  accessory.removeService(this.garageDoorService!);
1269
1306
  }
@@ -1272,7 +1309,7 @@ export class Bot {
1272
1309
  // If doorService still pressent, then remove first
1273
1310
  this.doorService = this.accessory.getService(this.platform.Service.Door);
1274
1311
  if (this.doorService) {
1275
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Door Service`);
1312
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Door Service`);
1276
1313
  }
1277
1314
  accessory.removeService(this.doorService!);
1278
1315
  }
@@ -1281,7 +1318,7 @@ export class Bot {
1281
1318
  // If lockService still pressent, then remove first
1282
1319
  this.lockService = this.accessory.getService(this.platform.Service.LockMechanism);
1283
1320
  if (this.lockService) {
1284
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Lock Service`);
1321
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Lock Service`);
1285
1322
  }
1286
1323
  accessory.removeService(this.lockService!);
1287
1324
  }
@@ -1290,7 +1327,7 @@ export class Bot {
1290
1327
  // If faucetService still pressent, then remove first
1291
1328
  this.faucetService = this.accessory.getService(this.platform.Service.Faucet);
1292
1329
  if (this.faucetService) {
1293
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Faucet Service`);
1330
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Faucet Service`);
1294
1331
  }
1295
1332
  accessory.removeService(this.faucetService!);
1296
1333
  }
@@ -1299,7 +1336,7 @@ export class Bot {
1299
1336
  // If fanService still pressent, then remove first
1300
1337
  this.fanService = this.accessory.getService(this.platform.Service.Fan);
1301
1338
  if (this.fanService) {
1302
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Fan Service`);
1339
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Fan Service`);
1303
1340
  }
1304
1341
  accessory.removeService(this.fanService!);
1305
1342
  }
@@ -1308,7 +1345,7 @@ export class Bot {
1308
1345
  // If windowService still pressent, then remove first
1309
1346
  this.windowService = this.accessory.getService(this.platform.Service.Window);
1310
1347
  if (this.windowService) {
1311
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Service`);
1348
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Service`);
1312
1349
  }
1313
1350
  accessory.removeService(this.windowService!);
1314
1351
  }
@@ -1317,7 +1354,7 @@ export class Bot {
1317
1354
  // If windowCoveringService still pressent, then remove first
1318
1355
  this.windowCoveringService = this.accessory.getService(this.platform.Service.WindowCovering);
1319
1356
  if (this.windowCoveringService) {
1320
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Window Covering Service`);
1357
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Window Covering Service`);
1321
1358
  }
1322
1359
  accessory.removeService(this.windowCoveringService!);
1323
1360
  }
@@ -1326,7 +1363,7 @@ export class Bot {
1326
1363
  // If statefulProgrammableSwitchService still pressent, then remove first
1327
1364
  this.statefulProgrammableSwitchService = this.accessory.getService(this.platform.Service.StatefulProgrammableSwitch);
1328
1365
  if (this.statefulProgrammableSwitchService) {
1329
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
1366
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Stateful Programmable Switch Service`);
1330
1367
  }
1331
1368
  accessory.removeService(this.statefulProgrammableSwitchService!);
1332
1369
  }
@@ -1335,7 +1372,7 @@ export class Bot {
1335
1372
  // If switchService still pressent, then remove first
1336
1373
  this.switchService = this.accessory.getService(this.platform.Service.Switch);
1337
1374
  if (this.switchService) {
1338
- this.warnLog(`Bot: ${accessory.displayName} Removing Leftover Switch Service`);
1375
+ this.warnLog(`${this.device.deviceType}: ${accessory.displayName} Removing Leftover Switch Service`);
1339
1376
  }
1340
1377
  accessory.removeService(this.switchService!);
1341
1378
  }