@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
@@ -46,6 +46,7 @@ export class StripLight {
46
46
  deviceLogging!: string;
47
47
  deviceRefreshRate!: number;
48
48
  adaptiveLightingShift?: number;
49
+ OpenAPI?: boolean;
49
50
 
50
51
  // Adaptive Lighting
51
52
  AdaptiveLightingController?: ControllerConstructor | Controller<ControllerServiceMap>;
@@ -62,6 +63,7 @@ export class StripLight {
62
63
  constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
63
64
  // default placeholders
64
65
  this.logs(device);
66
+ this.openAPI();
65
67
  this.scan(device);
66
68
  this.refreshRate(device);
67
69
  this.config(device);
@@ -171,9 +173,10 @@ export class StripLight {
171
173
  try {
172
174
  await this.pushChanges();
173
175
  } catch (e: any) {
174
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushChanges`);
176
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges`);
175
177
  if (this.deviceLogging.includes('debug')) {
176
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${superStringify(e.message)}`);
178
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges,`
179
+ + ` Error Message: ${superStringify(e.message)}`);
177
180
  }
178
181
  this.apiError(e);
179
182
  }
@@ -197,7 +200,7 @@ export class StripLight {
197
200
  }
198
201
 
199
202
  async BLEparseStatus(): Promise<void> {
200
- this.debugLog(`Strip Light: ${this.accessory.displayName} BLE parseStatus`);
203
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE parseStatus`);
201
204
  // State
202
205
  switch (this.state) {
203
206
  case 'on':
@@ -206,7 +209,7 @@ export class StripLight {
206
209
  default:
207
210
  this.On = false;
208
211
  }
209
- this.debugLog(`Strip Light: ${this.accessory.displayName} On: ${this.On}`);
212
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
210
213
  }
211
214
 
212
215
  async openAPIparseStatus(): Promise<void> {
@@ -217,30 +220,31 @@ export class StripLight {
217
220
  default:
218
221
  this.On = false;
219
222
  }
220
- this.debugLog(`Strip Light: ${this.accessory.displayName} On: ${this.On}`);
223
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
221
224
 
222
225
  // Brightness
223
226
  this.Brightness = Number(this.brightness);
224
- this.debugLog(`Strip Light: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
227
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
225
228
 
226
229
  // Color, Hue & Brightness
227
230
  if (this.color) {
228
- this.debugLog(`Strip Light: ${this.accessory.displayName} color: ${superStringify(this.color)}`);
231
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} color: ${superStringify(this.color)}`);
229
232
  const [red, green, blue] = this.color!.split(':');
230
- this.debugLog(`Strip Light: ${this.accessory.displayName} red: ${superStringify(red)}`);
231
- this.debugLog(`Strip Light: ${this.accessory.displayName} green: ${superStringify(green)}`);
232
- this.debugLog(`Strip Light: ${this.accessory.displayName} blue: ${superStringify(blue)}`);
233
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} red: ${superStringify(red)}`);
234
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} green: ${superStringify(green)}`);
235
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} blue: ${superStringify(blue)}`);
233
236
 
234
237
  const [hue, saturation] = rgb2hs(Number(red), Number(green), Number(blue));
235
- this.debugLog(`Strip Light: ${this.accessory.displayName} hs: ${superStringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
238
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
239
+ +` hs: ${superStringify(rgb2hs(Number(red), Number(green), Number(blue)))}`);
236
240
 
237
241
  // Hue
238
242
  this.Hue = hue;
239
- this.debugLog(`Strip Light: ${this.accessory.displayName} Hue: ${this.Hue}`);
243
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
240
244
 
241
245
  // Saturation
242
246
  this.Saturation = saturation;
243
- this.debugLog(`Strip Light: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
247
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
244
248
  }
245
249
  }
246
250
 
@@ -253,14 +257,14 @@ export class StripLight {
253
257
  }
254
258
 
255
259
  async BLERefreshStatus(): Promise<void> {
256
- this.debugLog(`Strip Light: ${this.accessory.displayName} BLE refreshStatus`);
260
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE refreshStatus`);
257
261
  const switchbot = await this.platform.connectBLE();
258
262
  // Convert to BLE Address
259
263
  this.device.bleMac = this.device
260
264
  .deviceId!.match(/.{1,2}/g)!
261
265
  .join(':')
262
266
  .toLowerCase();
263
- this.debugLog(`Strip Light: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
267
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
264
268
  this.getCustomBLEAddress(switchbot);
265
269
  // Start to monitor advertisement packets
266
270
  if (switchbot !== false) {
@@ -276,10 +280,10 @@ export class StripLight {
276
280
  if (this.deviceLogging.includes('debug')) {
277
281
  this.infoLog(this.address);
278
282
  this.infoLog(this.device.bleMac);
279
- this.infoLog(`Strip Light: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
280
- this.infoLog(`Strip Light: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
283
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address Found: ${this.address}`);
284
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac}`);
281
285
  }
282
- this.errorLog(`Strip Light: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
286
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
283
287
  this.serviceData = ad.serviceData;
284
288
  //this.state = ad.serviceData.state;
285
289
  //this.delay = ad.serviceData.delay;
@@ -288,19 +292,19 @@ export class StripLight {
288
292
  //this.wifiRssi = ad.serviceData.wifiRssi;
289
293
  //this.overload = ad.serviceData.overload;
290
294
  //this.currentPower = ad.serviceData.currentPower;
291
- this.debugLog(`Strip Light: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
295
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${superStringify(ad.serviceData)}`);
292
296
  /*this.debugLog(
293
- `Strip Light: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
297
+ `${this.device.deviceType}: ${this.accessory.displayName} state: ${ad.serviceData.state}, ` +
294
298
  `delay: ${ad.serviceData.delay}, timer: ${ad.serviceData.timer}, syncUtcTime: ${ad.serviceData.syncUtcTime} ` +
295
299
  `wifiRssi: ${ad.serviceData.wifiRssi}, overload: ${ad.serviceData.overload}, currentPower: ${ad.serviceData.currentPower}`,
296
300
  );*/
297
301
 
298
302
  if (this.serviceData) {
299
303
  this.connected = true;
300
- this.debugLog(`Strip Light: ${this.accessory.displayName} connected: ${this.connected}`);
304
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
301
305
  } else {
302
306
  this.connected = false;
303
- this.debugLog(`Strip Light: ${this.accessory.displayName} connected: ${this.connected}`);
307
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} connected: ${this.connected}`);
304
308
  }
305
309
  };
306
310
  // Wait 2 seconds
@@ -313,23 +317,24 @@ export class StripLight {
313
317
  this.parseStatus();
314
318
  this.updateHomeKitCharacteristics();
315
319
  } else {
316
- this.errorLog(`Strip Light: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
320
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
317
321
  if (this.platform.config.credentials?.token) {
318
- this.warnLog(`Strip Light: ${this.accessory.displayName} Using OpenAPI Connection`);
322
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
319
323
  this.SwitchToOpenAPI = true;
320
324
  await this.openAPIRefreshStatus();
321
325
  }
322
326
  }
323
327
  })
324
328
  .catch(async (e: any) => {
325
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
329
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
326
330
  if (this.deviceLogging.includes('debug')) {
327
331
  this.errorLog(
328
- `Strip Light: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${superStringify(e.message)}`,
332
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
333
+ + ` Error Message: ${superStringify(e.message)}`,
329
334
  );
330
335
  }
331
336
  if (this.platform.config.credentials?.token) {
332
- this.warnLog(`Strip Light: ${this.accessory.displayName} Using OpenAPI Connection`);
337
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
333
338
  this.SwitchToOpenAPI = true;
334
339
  await this.openAPIRefreshStatus();
335
340
  }
@@ -342,7 +347,7 @@ export class StripLight {
342
347
 
343
348
  async getCustomBLEAddress(switchbot: any) {
344
349
  if (this.device.customBLEaddress && this.deviceLogging.includes('debug')) {
345
- this.debugLog(`Strip Light: ${this.accessory.displayName} customBLEaddress: ${this.device.customBLEaddress}`);
350
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} customBLEaddress: ${this.device.customBLEaddress}`);
346
351
  (async () => {
347
352
  // Start to monitor advertisement packets
348
353
  await switchbot.startScan({
@@ -350,7 +355,7 @@ export class StripLight {
350
355
  });
351
356
  // Set an event handler
352
357
  switchbot.onadvertisement = (ad: any) => {
353
- this.warnLog(`Strip Light: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
358
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} ad: ${superStringify(ad, null, ' ')}`);
354
359
  };
355
360
  await switchbot.wait(10000);
356
361
  // Stop to monitor
@@ -360,68 +365,73 @@ export class StripLight {
360
365
  }
361
366
 
362
367
  async BLEconnection(switchbot: any): Promise<void> {
363
- this.errorLog(`Strip Light: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
368
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
364
369
  if (this.platform.config.credentials?.token) {
365
- this.warnLog(`Strip Light: ${this.accessory.displayName} Using OpenAPI Connection`);
370
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI Connection`);
366
371
  this.SwitchToOpenAPI = true;
367
372
  await this.openAPIRefreshStatus();
368
373
  }
369
374
  }
370
375
 
371
376
  async openAPIRefreshStatus(): Promise<void> {
372
- try {
373
- const t = Date.now();
374
- const nonce = 'requestID';
375
- const data = this.platform.config.credentials?.token + t + nonce;
376
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
377
- const sign = signTerm.toString('base64');
378
- this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
379
- const options = {
380
- hostname: HostDomain,
381
- port: 443,
382
- path: `${DevicePath}/${this.device.deviceId}/status`,
383
- method: 'GET',
384
- headers: {
385
- Authorization: this.platform.config.credentials?.token,
386
- sign: sign,
387
- nonce: nonce,
388
- t: t,
389
- 'Content-Type': 'application/json',
390
- },
391
- };
392
- const req = https.request(options, (res) => {
393
- this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
394
- let rawData = '';
395
- res.on('data', (d) => {
396
- rawData += d;
397
- this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
377
+ if (this.OpenAPI) {
378
+ try {
379
+ const t = Date.now();
380
+ const nonce = 'requestID';
381
+ const data = this.platform.config.credentials?.token + t + nonce;
382
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret).update(Buffer.from(data, 'utf-8')).digest();
383
+ const sign = signTerm.toString('base64');
384
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
385
+ const options = {
386
+ hostname: HostDomain,
387
+ port: 443,
388
+ path: `${DevicePath}/${this.device.deviceId}/status`,
389
+ method: 'GET',
390
+ headers: {
391
+ Authorization: this.platform.config.credentials?.token,
392
+ sign: sign,
393
+ nonce: nonce,
394
+ t: t,
395
+ 'Content-Type': 'application/json',
396
+ },
397
+ };
398
+ const req = https.request(options, (res) => {
399
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
400
+ let rawData = '';
401
+ res.on('data', (d) => {
402
+ rawData += d;
403
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
404
+ });
405
+ res.on('end', () => {
406
+ try {
407
+ this.deviceStatus = JSON.parse(rawData);
408
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
409
+ this.power = this.deviceStatus.body.power;
410
+ this.color = this.deviceStatus.body.color;
411
+ this.brightness = this.deviceStatus.body.brightness;
412
+ this.parseStatus();
413
+ this.updateHomeKitCharacteristics();
414
+ } catch (e: any) {
415
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
416
+ }
417
+ });
398
418
  });
399
- res.on('end', () => {
400
- try {
401
- this.deviceStatus = JSON.parse(rawData);
402
- this.debugLog(`Strip Light: ${this.accessory.displayName} refreshStatus: ${superStringify(this.deviceStatus)}`);
403
- this.power = this.deviceStatus.body.power;
404
- this.color = this.deviceStatus.body.color;
405
- this.brightness = this.deviceStatus.body.brightness;
406
- this.parseStatus();
407
- this.updateHomeKitCharacteristics();
408
- } catch (e: any) {
409
- this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
410
- }
419
+ req.on('error', (e: any) => {
420
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
411
421
  });
412
- });
413
- req.on('error', (e: any) => {
414
- this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
415
- });
416
- req.end();
417
- } catch (e: any) {
418
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
419
- if (this.deviceLogging.includes('debug')) {
420
- this.errorLog(
421
- `Strip Light: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
422
- );
422
+ req.end();
423
+ } catch (e: any) {
424
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
425
+ if (this.deviceLogging.includes('debug')) {
426
+ this.errorLog(
427
+ `${this.device.deviceType}: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
428
+ + ` Error Message: ${superStringify(e.message)}`,
429
+ );
430
+ }
431
+ this.apiError(e);
423
432
  }
424
- this.apiError(e);
433
+ } else {
434
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
425
435
  }
426
436
  }
427
437
 
@@ -436,86 +446,91 @@ export class StripLight {
436
446
  *
437
447
  */
438
448
  async pushChanges(): Promise<void> {
439
- try {
440
- if (this.On !== this.accessory.context.On) {
449
+ if (this.OpenAPI) {
450
+ try {
451
+ if (this.On !== this.accessory.context.On) {
441
452
  // Make Push On request to the API
442
- const t = Date.now();
443
- const nonce = 'requestID';
444
- const data = this.platform.config.credentials?.token + t + nonce;
445
- const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
446
- .update(Buffer.from(data, 'utf-8'))
447
- .digest();
448
- const sign = signTerm.toString('base64');
449
- this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
450
-
451
- let command = '';
453
+ const t = Date.now();
454
+ const nonce = 'requestID';
455
+ const data = this.platform.config.credentials?.token + t + nonce;
456
+ const signTerm = crypto.createHmac('sha256', this.platform.config.credentials?.secret)
457
+ .update(Buffer.from(data, 'utf-8'))
458
+ .digest();
459
+ const sign = signTerm.toString('base64');
460
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
461
+
462
+ let command = '';
463
+ if (this.On) {
464
+ command = 'turnOn';
465
+ } else {
466
+ command = 'turnOff';
467
+ }
468
+ const body = superStringify({
469
+ 'command': `${command}`,
470
+ 'parameter': 'default',
471
+ 'commandType': 'command',
472
+ });
473
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
474
+ const options = {
475
+ hostname: HostDomain,
476
+ port: 443,
477
+ path: `${DevicePath}/${this.device.deviceId}/commands`,
478
+ method: 'POST',
479
+ headers: {
480
+ 'Authorization': this.platform.config.credentials?.token,
481
+ 'sign': sign,
482
+ 'nonce': nonce,
483
+ 't': t,
484
+ 'Content-Type': 'application/json',
485
+ 'Content-Length': body.length,
486
+ },
487
+ };
488
+ const req = https.request(options, res => {
489
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
490
+ this.statusCode({ res });
491
+ res.on('data', d => {
492
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
493
+ });
494
+ });
495
+ req.on('error', (e: any) => {
496
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
497
+ });
498
+ req.write(body);
499
+ req.end();
500
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
501
+ }
502
+ // Push Brightness Update
452
503
  if (this.On) {
453
- command = 'turnOn';
454
- } else {
455
- command = 'turnOff';
504
+ await this.pushBrightnessChanges();
456
505
  }
457
- const body = superStringify({
458
- 'command': `${command}`,
459
- 'parameter': 'default',
460
- 'commandType': 'command',
461
- });
462
- this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
463
- const options = {
464
- hostname: HostDomain,
465
- port: 443,
466
- path: `${DevicePath}/${this.device.deviceId}/commands`,
467
- method: 'POST',
468
- headers: {
469
- 'Authorization': this.platform.config.credentials?.token,
470
- 'sign': sign,
471
- 'nonce': nonce,
472
- 't': t,
473
- 'Content-Type': 'application/json',
474
- 'Content-Length': body.length,
475
- },
476
- };
477
- const req = https.request(options, res => {
478
- this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
479
- this.statusCode({ res });
480
- res.on('data', d => {
481
- this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
482
- });
483
- });
484
- req.on('error', (e: any) => {
485
- this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
486
- });
487
- req.write(body);
488
- req.end();
489
- this.debugLog(`Strip Light: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
490
- }
491
- // Push Brightness Update
492
- if (this.On) {
493
- await this.pushBrightnessChanges();
494
- }
495
506
 
496
- // Push Hue & Saturation Update
497
- if (this.On) {
498
- await this.pushHueSaturationChanges();
499
- }
500
- } catch (e: any) {
501
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
502
- if (this.deviceLogging.includes('debug')) {
503
- this.errorLog(
504
- `Strip Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
505
- );
507
+ // Push Hue & Saturation Update
508
+ if (this.On) {
509
+ await this.pushHueSaturationChanges();
510
+ }
511
+ } catch (e: any) {
512
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
513
+ if (this.deviceLogging.includes('debug')) {
514
+ this.errorLog(
515
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
516
+ + ` Error Message: ${superStringify(e.message)}`,
517
+ );
518
+ }
519
+ this.apiError(e);
506
520
  }
507
- this.apiError(e);
521
+ } else {
522
+ this.warnLog(`${this.device.deviceType}: ${this.accessory.displayName} OpenAPI is disabled, commands will not be sent.`);
508
523
  }
509
524
  }
510
525
 
511
526
  async pushHueSaturationChanges(): Promise<void> {
512
527
  try {
513
528
  if (this.Hue !== this.accessory.context.Hue || this.Saturation !== this.accessory.context.Saturation) {
514
- this.debugLog(`Strip Light: ${this.accessory.displayName} Hue: ${superStringify(this.Hue)}`);
515
- this.debugLog(`Strip Light: ${this.accessory.displayName} Saturation: ${superStringify(this.Saturation)}`);
529
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${superStringify(this.Hue)}`);
530
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${superStringify(this.Saturation)}`);
516
531
 
517
532
  const [red, green, blue] = hs2rgb(Number(this.Hue), Number(this.Saturation));
518
- this.debugLog(`Strip Light: ${this.accessory.displayName} rgb: ${superStringify([red, green, blue])}`);
533
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} rgb: ${superStringify([red, green, blue])}`);
519
534
  // Make Push On request to the API
520
535
  const t = Date.now();
521
536
  const nonce = 'requestID';
@@ -524,13 +539,13 @@ export class StripLight {
524
539
  .update(Buffer.from(data, 'utf-8'))
525
540
  .digest();
526
541
  const sign = signTerm.toString('base64');
527
- this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
542
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
528
543
  const body = superStringify({
529
544
  'command': 'setColor',
530
545
  'parameter': `${red}:${green}:${blue}`,
531
546
  'commandType': 'command',
532
547
  });
533
- this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
548
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
534
549
  const options = {
535
550
  hostname: HostDomain,
536
551
  port: 443,
@@ -546,30 +561,30 @@ export class StripLight {
546
561
  },
547
562
  };
548
563
  const req = https.request(options, res => {
549
- this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
564
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
550
565
  this.statusCode({ res });
551
566
  res.on('data', d => {
552
- this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
567
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
553
568
  });
554
569
  });
555
570
  req.on('error', (e: any) => {
556
- this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
571
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
557
572
  });
558
573
  req.write(body);
559
574
  req.end();
560
- this.debugLog(`Strip Light: ${this.accessory.displayName} pushHueSaturationChanges: ${superStringify(req)}`);
575
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushHueSaturationChanges: ${superStringify(req)}`);
561
576
  } else {
562
577
  this.debugLog(
563
- `Strip Light: ${this.accessory.displayName} No Changes.` +
578
+ `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` +
564
579
  `Hue: ${this.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.Saturation}, `
565
580
  +`SaturationCached: ${this.accessory.context.Saturation}`,
566
581
  );
567
582
  }
568
583
  } catch (e: any) {
569
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection`);
584
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection`);
570
585
  if (this.deviceLogging.includes('debug')) {
571
586
  this.errorLog(
572
- `Strip Light: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection,`
587
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushHueSaturationChanges with OpenAPI Connection,`
573
588
  + ` Error Message: ${superStringify(e.message)}`,
574
589
  );
575
590
  }
@@ -588,13 +603,13 @@ export class StripLight {
588
603
  .update(Buffer.from(data, 'utf-8'))
589
604
  .digest();
590
605
  const sign = signTerm.toString('base64');
591
- this.debugLog(`Strip Light: ${this.accessory.displayName} sign: ${sign}`);
606
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} sign: ${sign}`);
592
607
  const body = superStringify({
593
608
  'command': 'setBrightness',
594
609
  'parameter': `${this.Brightness}`,
595
610
  'commandType': 'command',
596
611
  });
597
- this.infoLog(`Strip Light: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
612
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
598
613
  const options = {
599
614
  hostname: HostDomain,
600
615
  port: 443,
@@ -610,29 +625,29 @@ export class StripLight {
610
625
  },
611
626
  };
612
627
  const req = https.request(options, res => {
613
- this.debugLog(`Strip Light: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
628
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
614
629
  this.statusCode({ res });
615
630
  res.on('data', d => {
616
- this.debugLog(`Strip Light: ${this.accessory.displayName} d: ${d}`);
631
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} d: ${d}`);
617
632
  });
618
633
  });
619
634
  req.on('error', (e: any) => {
620
- this.errorLog(`Strip Light: ${this.accessory.displayName} error message: ${e.message}`);
635
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} error message: ${e.message}`);
621
636
  });
622
637
  req.write(body);
623
638
  req.end();
624
- this.debugLog(`Strip Light: ${this.accessory.displayName} pushBrightnessChanges: ${superStringify(req)}`);
639
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} pushBrightnessChanges: ${superStringify(req)}`);
625
640
  } else {
626
641
  this.debugLog(
627
- `Strip Light: ${this.accessory.displayName} No Changes.` + `Brightness: ${this.Brightness}, `
642
+ `${this.device.deviceType}: ${this.accessory.displayName} No Changes.` + `Brightness: ${this.Brightness}, `
628
643
  +`BrightnessCached: ${this.accessory.context.Brightness}`,
629
644
  );
630
645
  }
631
646
  } catch (e: any) {
632
- this.errorLog(`Strip Light: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection`);
647
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection`);
633
648
  if (this.deviceLogging.includes('debug')) {
634
649
  this.errorLog(
635
- `Strip Light: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection,`
650
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushBrightnessChanges with OpenAPI Connection,`
636
651
  + ` Error Message: ${superStringify(e.message)}`,
637
652
  );
638
653
  }
@@ -642,32 +657,32 @@ export class StripLight {
642
657
 
643
658
  async updateHomeKitCharacteristics(): Promise<void> {
644
659
  if (this.On === undefined) {
645
- this.debugLog(`Strip Light: ${this.accessory.displayName} On: ${this.On}`);
660
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${this.On}`);
646
661
  } else {
647
662
  this.accessory.context.On = this.On;
648
663
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, this.On);
649
- this.debugLog(`Strip Light: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
664
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
650
665
  }
651
666
  if (this.Brightness === undefined) {
652
- this.debugLog(`Strip Light: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
667
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${this.Brightness}`);
653
668
  } else {
654
669
  this.accessory.context.Brightness = this.Brightness;
655
670
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Brightness, this.Brightness);
656
- this.debugLog(`Strip Light: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
671
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Brightness: ${this.Brightness}`);
657
672
  }
658
673
  if (this.Hue === undefined) {
659
- this.debugLog(`Strip Light: ${this.accessory.displayName} Hue: ${this.Hue}`);
674
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${this.Hue}`);
660
675
  } else {
661
676
  this.accessory.context.Hue = this.Hue;
662
677
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Hue, this.Hue);
663
- this.debugLog(`Strip Light: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
678
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Hue: ${this.Hue}`);
664
679
  }
665
680
  if (this.Saturation === undefined) {
666
- this.debugLog(`Strip Light: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
681
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${this.Saturation}`);
667
682
  } else {
668
683
  this.accessory.context.Saturation = this.Saturation;
669
684
  this.lightBulbService.updateCharacteristic(this.platform.Characteristic.Saturation, this.Saturation);
670
- this.debugLog(`Strip Light: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
685
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} updateCharacteristic Saturation: ${this.Saturation}`);
671
686
  }
672
687
  }
673
688
 
@@ -682,36 +697,36 @@ export class StripLight {
682
697
  async statusCode({ res }: { res: IncomingMessage }): Promise<void> {
683
698
  switch (res.statusCode) {
684
699
  case 151:
685
- this.errorLog(`Strip Light: ${this.accessory.displayName} Command not supported by this device type.`);
700
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command not supported by this device type.`);
686
701
  break;
687
702
  case 152:
688
- this.errorLog(`Strip Light: ${this.accessory.displayName} Device not found.`);
703
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device not found.`);
689
704
  break;
690
705
  case 160:
691
- this.errorLog(`Strip Light: ${this.accessory.displayName} Command is not supported.`);
706
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Command is not supported.`);
692
707
  break;
693
708
  case 161:
694
- this.errorLog(`Strip Light: ${this.accessory.displayName} Device is offline.`);
709
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Device is offline.`);
695
710
  this.offlineOff();
696
711
  break;
697
712
  case 171:
698
- this.errorLog(`Strip Light: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
713
+ this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} is offline. Hub: ${this.device.hubDeviceId}`);
699
714
  this.offlineOff();
700
715
  break;
701
716
  case 190:
702
717
  this.errorLog(
703
- `Strip Light: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
718
+ `${this.device.deviceType}: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
704
719
  ` Or command: ${superStringify(res)} format is invalid`,
705
720
  );
706
721
  break;
707
722
  case 100:
708
723
  if (this.platform.debugMode) {
709
- this.debugLog(`Strip Light: ${this.accessory.displayName} Command successfully sent.`);
724
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Command successfully sent.`);
710
725
  }
711
726
  break;
712
727
  default:
713
728
  if (this.platform.debugMode) {
714
- this.debugLog(`Strip Light: ${this.accessory.displayName} Unknown statusCode.`);
729
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode.`);
715
730
  }
716
731
  }
717
732
  }
@@ -727,7 +742,7 @@ export class StripLight {
727
742
  * Handle requests to set the value of the "On" characteristic
728
743
  */
729
744
  async OnSet(value: CharacteristicValue): Promise<void> {
730
- this.debugLog(`Strip Light: ${this.accessory.displayName} On: ${value}`);
745
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} On: ${value}`);
731
746
 
732
747
  this.On = value;
733
748
  this.doStripLightUpdate.next();
@@ -737,7 +752,7 @@ export class StripLight {
737
752
  * Handle requests to set the value of the "Brightness" characteristic
738
753
  */
739
754
  async BrightnessSet(value: CharacteristicValue): Promise<void> {
740
- this.debugLog(`Strip Light: ${this.accessory.displayName} Brightness: ${value}`);
755
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Brightness: ${value}`);
741
756
 
742
757
  this.Brightness = value;
743
758
  this.doStripLightUpdate.next();
@@ -747,7 +762,7 @@ export class StripLight {
747
762
  * Handle requests to set the value of the "Hue" characteristic
748
763
  */
749
764
  async HueSet(value: CharacteristicValue): Promise<void> {
750
- this.debugLog(`Strip Light: ${this.accessory.displayName} Hue: ${value}`);
765
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Hue: ${value}`);
751
766
 
752
767
  this.Hue = value;
753
768
  this.doStripLightUpdate.next();
@@ -757,7 +772,7 @@ export class StripLight {
757
772
  * Handle requests to set the value of the "Saturation" characteristic
758
773
  */
759
774
  async SaturationSet(value: CharacteristicValue): Promise<void> {
760
- this.debugLog(`Strip Light: ${this.accessory.displayName} Saturation: ${value}`);
775
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Saturation: ${value}`);
761
776
 
762
777
  this.Saturation = value;
763
778
  this.doStripLightUpdate.next();
@@ -771,6 +786,9 @@ export class StripLight {
771
786
  if (device.ble) {
772
787
  config['ble'] = device.ble;
773
788
  }
789
+ if (device.openAPI !== undefined) {
790
+ config['openAPI'] = device.openAPI;
791
+ }
774
792
  if (device.logging !== undefined) {
775
793
  config['logging'] = device.logging;
776
794
  }
@@ -784,30 +802,39 @@ export class StripLight {
784
802
  config['offline'] = device.offline;
785
803
  }
786
804
  if (Object.entries(config).length !== 0) {
787
- this.infoLog(`Strip Light: ${this.accessory.displayName} Config: ${superStringify(config)}`);
805
+ this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
788
806
  }
789
807
  }
790
808
 
791
809
  async refreshRate(device: device & devicesConfig): Promise<void> {
792
810
  if (device.refreshRate) {
793
811
  this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
794
- this.debugLog(`Strip Light: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
812
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
795
813
  } else if (this.platform.config.options!.refreshRate) {
796
814
  this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
797
- this.debugLog(`Strip Light: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
815
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
816
+ }
817
+ }
818
+
819
+ async openAPI() {
820
+ if (!this.device.openAPI) {
821
+ this.OpenAPI = true;
822
+ } else {
823
+ this.OpenAPI = this.device.openAPI;
798
824
  }
825
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
799
826
  }
800
827
 
801
828
  async scan(device: device & devicesConfig): Promise<void> {
802
829
  if (device.scanDuration) {
803
830
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
804
831
  if (device.ble) {
805
- this.debugLog(`Bot: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
832
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config scanDuration: ${this.scanDuration}`);
806
833
  }
807
834
  } else {
808
835
  this.scanDuration = this.accessory.context.scanDuration = 1;
809
836
  if (this.device.ble) {
810
- this.debugLog(`Bot: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
837
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Default scanDuration: ${this.scanDuration}`);
811
838
  }
812
839
  }
813
840
  }
@@ -815,24 +842,25 @@ export class StripLight {
815
842
  async logs(device: device & devicesConfig): Promise<void> {
816
843
  if (this.platform.debugMode) {
817
844
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
818
- this.debugLog(`Strip Light: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
845
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
819
846
  } else if (device.logging) {
820
847
  this.deviceLogging = this.accessory.context.logging = device.logging;
821
- this.debugLog(`Strip Light: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
848
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
822
849
  } else if (this.platform.config.options?.logging) {
823
850
  this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
824
- this.debugLog(`Strip Light: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
851
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
825
852
  } else {
826
853
  this.deviceLogging = this.accessory.context.logging = 'standard';
827
- this.debugLog(`Strip Light: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
854
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
828
855
  }
829
856
  }
830
857
 
831
858
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
832
859
  let FirmwareRevision: string;
833
- this.debugLog(`Strip Light: ${this.accessory.displayName} accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
834
- this.debugLog(`Strip Light: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
835
- this.debugLog(`Strip Light: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
860
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} `
861
+ +`accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
862
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
863
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
836
864
  if (accessory.context.FirmwareRevision) {
837
865
  FirmwareRevision = accessory.context.FirmwareRevision;
838
866
  } else if (device.firmware) {