@switchbot/homebridge-switchbot 4.1.1-beta.2 → 4.1.1-beta.3

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 (96) hide show
  1. package/dist/device/blindtilt.js +102 -102
  2. package/dist/device/blindtilt.js.map +1 -1
  3. package/dist/device/bot.js +85 -85
  4. package/dist/device/bot.js.map +1 -1
  5. package/dist/device/ceilinglight.js +98 -98
  6. package/dist/device/ceilinglight.js.map +1 -1
  7. package/dist/device/colorbulb.js +140 -140
  8. package/dist/device/colorbulb.js.map +1 -1
  9. package/dist/device/contact.js +44 -44
  10. package/dist/device/contact.js.map +1 -1
  11. package/dist/device/curtain.js +82 -82
  12. package/dist/device/curtain.js.map +1 -1
  13. package/dist/device/device.d.ts +11 -11
  14. package/dist/device/device.d.ts.map +1 -1
  15. package/dist/device/device.js +41 -41
  16. package/dist/device/device.js.map +1 -1
  17. package/dist/device/fan.js +96 -96
  18. package/dist/device/fan.js.map +1 -1
  19. package/dist/device/hub.js +43 -43
  20. package/dist/device/hub.js.map +1 -1
  21. package/dist/device/humidifier.js +84 -84
  22. package/dist/device/humidifier.js.map +1 -1
  23. package/dist/device/iosensor.js +44 -44
  24. package/dist/device/iosensor.js.map +1 -1
  25. package/dist/device/lightstrip.js +119 -119
  26. package/dist/device/lightstrip.js.map +1 -1
  27. package/dist/device/lock.js +75 -75
  28. package/dist/device/lock.js.map +1 -1
  29. package/dist/device/meter.js +44 -44
  30. package/dist/device/meter.js.map +1 -1
  31. package/dist/device/meterplus.js +42 -42
  32. package/dist/device/meterplus.js.map +1 -1
  33. package/dist/device/meterpro.js +42 -42
  34. package/dist/device/meterpro.js.map +1 -1
  35. package/dist/device/motion.js +42 -42
  36. package/dist/device/motion.js.map +1 -1
  37. package/dist/device/plug.js +60 -60
  38. package/dist/device/plug.js.map +1 -1
  39. package/dist/device/robotvacuumcleaner.js +74 -74
  40. package/dist/device/robotvacuumcleaner.js.map +1 -1
  41. package/dist/device/waterdetector.js +44 -44
  42. package/dist/device/waterdetector.js.map +1 -1
  43. package/dist/irdevice/airconditioner.js +31 -31
  44. package/dist/irdevice/airconditioner.js.map +1 -1
  45. package/dist/irdevice/airpurifier.js +10 -10
  46. package/dist/irdevice/airpurifier.js.map +1 -1
  47. package/dist/irdevice/camera.js +9 -9
  48. package/dist/irdevice/camera.js.map +1 -1
  49. package/dist/irdevice/fan.js +11 -11
  50. package/dist/irdevice/fan.js.map +1 -1
  51. package/dist/irdevice/irdevice.js +11 -11
  52. package/dist/irdevice/irdevice.js.map +1 -1
  53. package/dist/irdevice/light.js +9 -9
  54. package/dist/irdevice/light.js.map +1 -1
  55. package/dist/irdevice/other.js +55 -55
  56. package/dist/irdevice/other.js.map +1 -1
  57. package/dist/irdevice/tv.js +33 -33
  58. package/dist/irdevice/tv.js.map +1 -1
  59. package/dist/irdevice/vacuumcleaner.js +9 -9
  60. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  61. package/dist/irdevice/waterheater.js +9 -9
  62. package/dist/irdevice/waterheater.js.map +1 -1
  63. package/dist/platform.js +228 -228
  64. package/dist/platform.js.map +1 -1
  65. package/package.json +1 -1
  66. package/src/device/blindtilt.ts +102 -102
  67. package/src/device/bot.ts +85 -85
  68. package/src/device/ceilinglight.ts +98 -98
  69. package/src/device/colorbulb.ts +140 -140
  70. package/src/device/contact.ts +44 -44
  71. package/src/device/curtain.ts +82 -82
  72. package/src/device/device.ts +41 -41
  73. package/src/device/fan.ts +96 -96
  74. package/src/device/hub.ts +43 -43
  75. package/src/device/humidifier.ts +84 -84
  76. package/src/device/iosensor.ts +44 -44
  77. package/src/device/lightstrip.ts +119 -119
  78. package/src/device/lock.ts +75 -75
  79. package/src/device/meter.ts +44 -44
  80. package/src/device/meterplus.ts +42 -42
  81. package/src/device/meterpro.ts +42 -42
  82. package/src/device/motion.ts +42 -42
  83. package/src/device/plug.ts +60 -60
  84. package/src/device/robotvacuumcleaner.ts +74 -74
  85. package/src/device/waterdetector.ts +44 -44
  86. package/src/irdevice/airconditioner.ts +31 -31
  87. package/src/irdevice/airpurifier.ts +10 -10
  88. package/src/irdevice/camera.ts +9 -9
  89. package/src/irdevice/fan.ts +11 -11
  90. package/src/irdevice/irdevice.ts +11 -11
  91. package/src/irdevice/light.ts +9 -9
  92. package/src/irdevice/other.ts +55 -55
  93. package/src/irdevice/tv.ts +33 -33
  94. package/src/irdevice/vacuumcleaner.ts +9 -9
  95. package/src/irdevice/waterheater.ts +9 -9
  96. package/src/platform.ts +228 -228
@@ -148,24 +148,24 @@ export class StripLight extends deviceBase {
148
148
  }
149
149
  catch (e) {
150
150
  await this.apiError(e);
151
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
151
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
152
152
  }
153
153
  this.stripLightUpdateInProgress = false;
154
154
  });
155
155
  }
156
156
  async BLEparseStatus() {
157
- await this.debugLog('BLEparseStatus');
158
- await this.debugLog(`(power, brightness, color) = BLE:(${this.serviceData.power}, ${this.serviceData.brightness}, ${this.serviceData.red}:${this.serviceData.green}:${this.serviceData.blue}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
157
+ this.debugLog('BLEparseStatus');
158
+ this.debugLog(`(power, brightness, color) = BLE:(${this.serviceData.power}, ${this.serviceData.brightness}, ${this.serviceData.red}:${this.serviceData.green}:${this.serviceData.blue}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
159
159
  // On
160
160
  this.LightBulb.On = this.serviceData.power;
161
- await this.debugLog(`On: ${this.LightBulb.On}`);
161
+ this.debugLog(`On: ${this.LightBulb.On}`);
162
162
  // Brightness
163
163
  this.LightBulb.Brightness = this.serviceData.brightness;
164
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
164
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
165
165
  // Color, Hue & Brightness
166
- await this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`);
166
+ this.debugLog(`red: ${this.serviceData.red}, green: ${this.serviceData.green}, blue: ${this.serviceData.blue}`);
167
167
  const [hue, saturation] = rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue);
168
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`);
168
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(this.serviceData.red, this.serviceData.green, this.serviceData.blue))}`);
169
169
  // Hue
170
170
  this.LightBulb.Hue = hue;
171
171
  this.debugLog(`Hue: ${this.LightBulb.Hue}`);
@@ -174,30 +174,30 @@ export class StripLight extends deviceBase {
174
174
  this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
175
175
  }
176
176
  async openAPIparseStatus() {
177
- await this.debugLog('openAPIparseStatus');
178
- await this.debugLog(`(power, brightness, color) = API:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
177
+ this.debugLog('openAPIparseStatus');
178
+ this.debugLog(`(power, brightness, color) = API:(${this.deviceStatus.power}, ${this.deviceStatus.brightness}, ${this.deviceStatus.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
179
179
  // On
180
180
  this.LightBulb.On = this.deviceStatus.power === 'on';
181
- await this.debugLog(`On: ${this.LightBulb.On}`);
181
+ this.debugLog(`On: ${this.LightBulb.On}`);
182
182
  // Brightness
183
183
  this.LightBulb.Brightness = this.deviceStatus.brightness;
184
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
184
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
185
185
  // Color, Hue & Brightness
186
- await this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`);
186
+ this.debugLog(`color: ${JSON.stringify(this.deviceStatus.color)}`);
187
187
  const [red, green, blue] = this.deviceStatus.color.split(':');
188
- await this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`);
188
+ this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`);
189
189
  const [hue, saturation] = rgb2hs(red, green, blue);
190
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`);
190
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`);
191
191
  // Hue
192
192
  this.LightBulb.Hue = hue;
193
- await this.debugLog(`Hue: ${this.LightBulb.Hue}`);
193
+ this.debugLog(`Hue: ${this.LightBulb.Hue}`);
194
194
  // Saturation
195
195
  this.LightBulb.Saturation = saturation;
196
- await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
196
+ this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
197
197
  // Firmware Version
198
198
  if (this.deviceStatus.version) {
199
199
  const version = this.deviceStatus.version.toString();
200
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
200
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
201
201
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
202
202
  this.accessory
203
203
  .getService(this.hap.Service.AccessoryInformation)
@@ -206,37 +206,37 @@ export class StripLight extends deviceBase {
206
206
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
207
207
  .updateValue(deviceVersion);
208
208
  this.accessory.context.version = deviceVersion;
209
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
209
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`);
210
210
  }
211
211
  }
212
212
  async parseStatusWebhook() {
213
- await this.debugLog('parseStatusWebhook');
214
- await this.debugLog(`(powerState, brightness, color) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
213
+ this.debugLog('parseStatusWebhook');
214
+ this.debugLog(`(powerState, brightness, color) = Webhook:(${this.webhookContext.powerState}, ${this.webhookContext.brightness}, ${this.webhookContext.color}), current:(${this.LightBulb.On}, ${this.LightBulb.Brightness}, ${this.LightBulb.Hue}, ${this.LightBulb.Saturation})`);
215
215
  // On
216
216
  this.LightBulb.On = this.webhookContext.powerState === 'ON';
217
- await this.debugLog(`On: ${this.LightBulb.On}`);
217
+ this.debugLog(`On: ${this.LightBulb.On}`);
218
218
  // Brightness
219
219
  this.LightBulb.Brightness = this.webhookContext.brightness;
220
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
220
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
221
221
  // Color, Hue & Brightness
222
- await this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`);
222
+ this.debugLog(`color: ${JSON.stringify(this.webhookContext.color)}`);
223
223
  const [red, green, blue] = this.webhookContext.color.split(':');
224
- await this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`);
224
+ this.debugLog(`red: ${JSON.stringify(red)}, green: ${JSON.stringify(green)}, blue: ${JSON.stringify(blue)}`);
225
225
  const [hue, saturation] = rgb2hs(red, green, blue);
226
- await this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`);
226
+ this.debugLog(`hs: ${JSON.stringify(rgb2hs(red, green, blue))}`);
227
227
  // Hue
228
228
  this.LightBulb.Hue = hue;
229
- await this.debugLog(`Hue: ${this.LightBulb.Hue}`);
229
+ this.debugLog(`Hue: ${this.LightBulb.Hue}`);
230
230
  // Saturation
231
231
  this.LightBulb.Saturation = saturation;
232
- await this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
232
+ this.debugLog(`Saturation: ${this.LightBulb.Saturation}`);
233
233
  }
234
234
  /**
235
235
  * Asks the SwitchBot API for the latest device information
236
236
  */
237
237
  async refreshStatus() {
238
238
  if (!this.device.enableCloudService && this.OpenAPI) {
239
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
239
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
240
240
  }
241
241
  else if (this.BLE) {
242
242
  await this.BLERefreshStatus();
@@ -246,11 +246,11 @@ export class StripLight extends deviceBase {
246
246
  }
247
247
  else {
248
248
  await this.offlineOff();
249
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
249
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
250
250
  }
251
251
  }
252
252
  async BLERefreshStatus() {
253
- await this.debugLog('BLERefreshStatus');
253
+ this.debugLog('BLERefreshStatus');
254
254
  const switchBotBLE = await this.switchbotBLE();
255
255
  if (switchBotBLE === undefined) {
256
256
  await this.BLERefreshConnection(switchBotBLE);
@@ -267,79 +267,79 @@ export class StripLight extends deviceBase {
267
267
  await this.updateHomeKitCharacteristics();
268
268
  }
269
269
  else {
270
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
270
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
271
271
  await this.BLERefreshConnection(switchBotBLE);
272
272
  }
273
273
  })();
274
274
  }
275
275
  }
276
276
  async registerPlatformBLE() {
277
- await this.debugLog('registerPlatformBLE');
277
+ this.debugLog('registerPlatformBLE');
278
278
  if (this.config.options?.BLE) {
279
- await this.debugLog('is listening to Platform BLE.');
279
+ this.debugLog('is listening to Platform BLE.');
280
280
  try {
281
281
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
282
282
  this.device.bleMac = formattedDeviceId;
283
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
283
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
284
284
  this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
285
285
  try {
286
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
286
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`);
287
287
  this.serviceData = context;
288
288
  await this.BLEparseStatus();
289
289
  await this.updateHomeKitCharacteristics();
290
290
  }
291
291
  catch (e) {
292
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
292
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
293
293
  }
294
294
  };
295
295
  }
296
296
  catch (error) {
297
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
297
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
298
298
  }
299
299
  }
300
300
  else {
301
- await this.debugLog('is not listening to Platform BLE');
301
+ this.debugLog('is not listening to Platform BLE');
302
302
  }
303
303
  }
304
304
  async openAPIRefreshStatus() {
305
- await this.debugLog('openAPIRefreshStatus');
305
+ this.debugLog('openAPIRefreshStatus');
306
306
  try {
307
- const { body } = await this.deviceRefreshStatus();
308
- const deviceStatus = await body;
309
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
307
+ const response = await this.deviceRefreshStatus();
308
+ const deviceStatus = response.body;
309
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
310
310
  if (await this.successfulStatusCodes(deviceStatus)) {
311
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
311
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
312
312
  this.deviceStatus = deviceStatus.body;
313
313
  await this.openAPIparseStatus();
314
314
  await this.updateHomeKitCharacteristics();
315
315
  }
316
316
  else {
317
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
318
- await this.debugWarnLog(deviceStatus);
317
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
318
+ this.debugWarnLog(deviceStatus);
319
319
  }
320
320
  }
321
321
  catch (e) {
322
322
  await this.apiError(e);
323
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
323
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
324
324
  }
325
325
  }
326
326
  async registerWebhook() {
327
327
  if (this.device.webhook) {
328
- await this.debugLog('is listening webhook.');
328
+ this.debugLog('is listening webhook.');
329
329
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
330
330
  try {
331
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
331
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
332
332
  this.webhookContext = context;
333
333
  await this.parseStatusWebhook();
334
334
  await this.updateHomeKitCharacteristics();
335
335
  }
336
336
  catch (e) {
337
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
337
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
338
338
  }
339
339
  };
340
340
  }
341
341
  else {
342
- await this.debugLog('is not listening webhook.');
342
+ this.debugLog('is not listening webhook.');
343
343
  }
344
344
  }
345
345
  /**
@@ -360,10 +360,10 @@ export class StripLight extends deviceBase {
360
360
  await this.BLEpushChanges();
361
361
  if (this.LightBulb.On) {
362
362
  // Push Brightness Update
363
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
363
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
364
364
  await this.BLEpushBrightnessChanges();
365
365
  // Push Hue & Saturation Update
366
- await this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`);
366
+ this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`);
367
367
  await this.BLEpushRGBChanges();
368
368
  // Set ColorTemperature
369
369
  if (this.LightBulb.ColorTemperature !== this.accessory.context.ColorTemperature) {
@@ -371,30 +371,30 @@ export class StripLight extends deviceBase {
371
371
  this.accessory.context.kelvin = kelvin;
372
372
  }
373
373
  else {
374
- await this.debugLog(`No pushColorTemperatureChanges, ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`);
374
+ this.debugLog(`No pushColorTemperatureChanges, ColorTemperature: ${this.LightBulb.ColorTemperature}, ColorTemperatureCached: ${this.accessory.context.ColorTemperature}`);
375
375
  }
376
376
  }
377
377
  else {
378
- await this.debugLog('BLE (Brightness), (Hue), & (Saturation) changes will not happen, as the device is OFF.');
378
+ this.debugLog('BLE (Brightness), (Hue), & (Saturation) changes will not happen, as the device is OFF.');
379
379
  }
380
380
  }
381
381
  else if (this.OpenAPI && this.platform.config.credentials?.token) {
382
382
  await this.openAPIpushChanges();
383
383
  if (this.LightBulb.On) {
384
384
  // Push Brightness Update
385
- await this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
385
+ this.debugLog(`Brightness: ${this.LightBulb.Brightness}`);
386
386
  await this.pushBrightnessChanges();
387
387
  // Push Hue & Saturation Update
388
- await this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`);
388
+ this.debugLog(`Hue: ${this.LightBulb.Hue}, Saturation: ${this.LightBulb.Saturation}`);
389
389
  await this.pushHueSaturationChanges();
390
390
  }
391
391
  else {
392
- await this.debugLog('openAPI (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.');
392
+ this.debugLog('openAPI (Brightness), (ColorTemperature), (Hue), & (Saturation) changes will not happen, as the device is OFF.');
393
393
  }
394
394
  }
395
395
  else {
396
396
  await this.offlineOff();
397
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
397
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
398
398
  }
399
399
  // Refresh the status from the API
400
400
  interval(15000)
@@ -405,22 +405,22 @@ export class StripLight extends deviceBase {
405
405
  });
406
406
  }
407
407
  async BLEpushChanges() {
408
- await this.debugLog('BLEpushChanges');
408
+ this.debugLog('BLEpushChanges');
409
409
  if (this.LightBulb.On !== this.accessory.context.On) {
410
- await this.debugLog(`BLEpushChanges On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
410
+ this.debugLog(`BLEpushChanges On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
411
411
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
412
412
  try {
413
413
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
414
414
  this.device.bleMac = formattedDeviceId;
415
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
415
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
416
416
  if (switchBotBLE !== false) {
417
417
  switchBotBLE
418
418
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
419
419
  .then(async (device_list) => {
420
420
  const deviceList = device_list;
421
- await this.infoLog(`On: ${this.LightBulb.On}`);
421
+ this.infoLog(`On: ${this.LightBulb.On}`);
422
422
  return await this.retryBLE({
423
- max: await this.maxRetryBLE(),
423
+ max: this.maxRetryBLE(),
424
424
  fn: async () => {
425
425
  if (this.LightBulb.On) {
426
426
  return await deviceList[0].turnOn();
@@ -432,109 +432,109 @@ export class StripLight extends deviceBase {
432
432
  });
433
433
  })
434
434
  .then(async () => {
435
- await this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`);
435
+ this.successLog(`On: ${this.LightBulb.On} sent over SwitchBot BLE, sent successfully`);
436
436
  await this.updateHomeKitCharacteristics();
437
437
  })
438
438
  .catch(async (e) => {
439
439
  await this.apiError(e);
440
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
440
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
441
441
  await this.BLEPushConnection();
442
442
  });
443
443
  }
444
444
  else {
445
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
445
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
446
446
  await this.BLEPushConnection();
447
447
  }
448
448
  }
449
449
  catch (error) {
450
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
450
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
451
451
  }
452
452
  }
453
453
  else {
454
- await this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
454
+ this.debugLog(`No changes (BLEpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
455
455
  }
456
456
  }
457
457
  async BLEpushBrightnessChanges() {
458
- await this.debugLog('BLEpushBrightnessChanges');
458
+ this.debugLog('BLEpushBrightnessChanges');
459
459
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
460
460
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
461
461
  try {
462
462
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
463
463
  this.device.bleMac = formattedDeviceId;
464
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
464
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
465
465
  if (switchBotBLE !== false) {
466
466
  switchBotBLE
467
467
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
468
468
  .then(async (device_list) => {
469
- await this.infoLog(`Brightness: ${this.LightBulb.Brightness}`);
469
+ this.infoLog(`Brightness: ${this.LightBulb.Brightness}`);
470
470
  return await device_list[0].setBrightness(this.LightBulb.Brightness);
471
471
  })
472
472
  .then(async () => {
473
- await this.successLog(`Brightness: ${this.LightBulb.Brightness} sent over SwitchBot BLE, sent successfully`);
473
+ this.successLog(`Brightness: ${this.LightBulb.Brightness} sent over SwitchBot BLE, sent successfully`);
474
474
  await this.updateHomeKitCharacteristics();
475
475
  })
476
476
  .catch(async (e) => {
477
477
  await this.apiError(e);
478
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
478
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
479
479
  await this.BLEPushConnection();
480
480
  });
481
481
  }
482
482
  else {
483
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
483
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
484
484
  await this.BLEPushConnection();
485
485
  }
486
486
  }
487
487
  catch (error) {
488
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
488
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
489
489
  }
490
490
  }
491
491
  else {
492
- await this.debugLog(`No changes (BLEpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`);
492
+ this.debugLog(`No changes (BLEpushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`);
493
493
  }
494
494
  }
495
495
  async BLEpushRGBChanges() {
496
- await this.debugLog('BLEpushRGBChanges');
496
+ this.debugLog('BLEpushRGBChanges');
497
497
  if ((this.LightBulb.Hue !== this.accessory.context.Hue) || (this.LightBulb.Saturation !== this.accessory.context.Saturation)) {
498
- await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`);
498
+ this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`);
499
499
  const [red, green, blue] = hs2rgb(this.LightBulb.Hue, this.LightBulb.Saturation);
500
- await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`);
500
+ this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`);
501
501
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
502
502
  try {
503
503
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
504
504
  this.device.bleMac = formattedDeviceId;
505
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
505
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
506
506
  if (switchBotBLE !== false) {
507
507
  switchBotBLE
508
508
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
509
509
  .then(async (device_list) => {
510
- await this.infoLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)}`);
510
+ this.infoLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)}`);
511
511
  return await device_list[0].setRGB(this.LightBulb.Brightness, red, green, blue);
512
512
  })
513
513
  .then(async () => {
514
- await this.successLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)} sent over SwitchBot BLE, sent successfully`);
514
+ this.successLog(`RGB: ${(this.LightBulb.Brightness, red, green, blue)} sent over SwitchBot BLE, sent successfully`);
515
515
  await this.updateHomeKitCharacteristics();
516
516
  })
517
517
  .catch(async (e) => {
518
518
  await this.apiError(e);
519
- await this.errorLog(`failed BLEpushRGBChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
519
+ this.errorLog(`failed BLEpushRGBChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
520
520
  await this.BLEPushConnection();
521
521
  });
522
522
  }
523
523
  else {
524
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
524
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
525
525
  await this.BLEPushConnection();
526
526
  }
527
527
  }
528
528
  catch (error) {
529
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
529
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
530
530
  }
531
531
  }
532
532
  else {
533
- await this.debugLog(`No changes (BLEpushRGBChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
533
+ this.debugLog(`No changes (BLEpushRGBChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
534
534
  }
535
535
  }
536
536
  async openAPIpushChanges() {
537
- await this.debugLog('openAPIpushChanges');
537
+ this.debugLog('openAPIpushChanges');
538
538
  if (this.LightBulb.On !== this.accessory.context.On) {
539
539
  const command = this.LightBulb.On ? 'turnOn' : 'turnOff';
540
540
  const bodyChange = {
@@ -542,13 +542,13 @@ export class StripLight extends deviceBase {
542
542
  parameter: 'default',
543
543
  commandType: 'command',
544
544
  };
545
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
545
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
546
546
  try {
547
- const { body } = await this.pushChangeRequest(bodyChange);
548
- const deviceStatus = await body;
549
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
547
+ const response = await this.pushChangeRequest(bodyChange);
548
+ const deviceStatus = response.body;
549
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
550
550
  if (await this.successfulStatusCodes(deviceStatus)) {
551
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
551
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
552
552
  await this.updateHomeKitCharacteristics();
553
553
  }
554
554
  else {
@@ -557,31 +557,31 @@ export class StripLight extends deviceBase {
557
557
  }
558
558
  catch (e) {
559
559
  await this.apiError(e);
560
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
560
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
561
561
  }
562
562
  }
563
563
  else {
564
- await this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
564
+ this.debugLog(`No changes (openAPIpushChanges), On: ${this.LightBulb.On}, OnCached: ${this.accessory.context.On}`);
565
565
  }
566
566
  }
567
567
  async pushHueSaturationChanges() {
568
- await this.debugLog('pushHueSaturationChanges');
568
+ this.debugLog('pushHueSaturationChanges');
569
569
  if ((this.LightBulb.Hue !== this.accessory.context.Hue) || (this.LightBulb.Saturation !== this.accessory.context.Saturation)) {
570
- await this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`);
570
+ this.debugLog(`Hue: ${JSON.stringify(this.LightBulb.Hue)}, Saturation: ${JSON.stringify(this.LightBulb.Saturation)}`);
571
571
  const [red, green, blue] = hs2rgb(this.LightBulb.Hue, this.LightBulb.Saturation);
572
- await this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`);
572
+ this.debugLog(`rgb: ${JSON.stringify([red, green, blue])}`);
573
573
  const bodyChange = {
574
574
  command: 'setColor',
575
575
  parameter: `${red}:${green}:${blue}`,
576
576
  commandType: 'command',
577
577
  };
578
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
578
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
579
579
  try {
580
- const { body } = await this.pushChangeRequest(bodyChange);
581
- const deviceStatus = await body;
582
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
580
+ const response = await this.pushChangeRequest(bodyChange);
581
+ const deviceStatus = response.body;
582
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
583
583
  if (await this.successfulStatusCodes(deviceStatus)) {
584
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
584
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
585
585
  await this.updateHomeKitCharacteristics();
586
586
  }
587
587
  else {
@@ -590,28 +590,28 @@ export class StripLight extends deviceBase {
590
590
  }
591
591
  catch (e) {
592
592
  await this.apiError(e);
593
- await this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
593
+ this.errorLog(`failed pushHueSaturationChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
594
594
  }
595
595
  }
596
596
  else {
597
- await this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
597
+ this.debugLog(`No changes (pushHueSaturationChanges), Hue: ${this.LightBulb.Hue}, HueCached: ${this.accessory.context.Hue}, Saturation: ${this.LightBulb.Saturation}, SaturationCached: ${this.accessory.context.Saturation}`);
598
598
  }
599
599
  }
600
600
  async pushBrightnessChanges() {
601
- await this.debugLog('pushBrightnessChanges');
601
+ this.debugLog('pushBrightnessChanges');
602
602
  if (this.LightBulb.Brightness !== this.accessory.context.Brightness) {
603
603
  const bodyChange = {
604
604
  command: 'setBrightness',
605
605
  parameter: `${this.LightBulb.Brightness}`,
606
606
  commandType: 'command',
607
607
  };
608
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
608
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
609
609
  try {
610
- const { body } = await this.pushChangeRequest(bodyChange);
611
- const deviceStatus = await body;
612
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
610
+ const response = await this.pushChangeRequest(bodyChange);
611
+ const deviceStatus = response.body;
612
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
613
613
  if (await this.successfulStatusCodes(deviceStatus)) {
614
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
614
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
615
615
  await this.updateHomeKitCharacteristics();
616
616
  }
617
617
  else {
@@ -620,11 +620,11 @@ export class StripLight extends deviceBase {
620
620
  }
621
621
  catch (e) {
622
622
  await this.apiError(e);
623
- await this.errorLog(`failed pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
623
+ this.errorLog(`failed pushBrightnessChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
624
624
  }
625
625
  }
626
626
  else {
627
- await this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`);
627
+ this.debugLog(`No changes (pushBrightnessChanges), Brightness: ${this.LightBulb.Brightness}, BrightnessCached: ${this.accessory.context.Brightness}`);
628
628
  }
629
629
  }
630
630
  /**
@@ -632,10 +632,10 @@ export class StripLight extends deviceBase {
632
632
  */
633
633
  async OnSet(value) {
634
634
  if (this.LightBulb.On !== this.accessory.context.On) {
635
- await this.infoLog(`Set On: ${value}`);
635
+ this.infoLog(`Set On: ${value}`);
636
636
  }
637
637
  else {
638
- await this.debugLog(`No Changes, On: ${value}`);
638
+ this.debugLog(`No Changes, On: ${value}`);
639
639
  }
640
640
  this.LightBulb.On = value;
641
641
  this.doStripLightUpdate.next();
@@ -645,7 +645,7 @@ export class StripLight extends deviceBase {
645
645
  */
646
646
  async BrightnessSet(value) {
647
647
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
648
- await this.infoLog(`Set Brightness: ${value}`);
648
+ this.infoLog(`Set Brightness: ${value}`);
649
649
  }
650
650
  else {
651
651
  if (this.LightBulb.On) {
@@ -742,21 +742,21 @@ export class StripLight extends deviceBase {
742
742
  async getAdaptiveLightingSettings(accessory, device) {
743
743
  // Adaptive Lighting
744
744
  this.adaptiveLighting = accessory.context.adaptiveLighting ?? true;
745
- await this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`);
745
+ this.debugLog(`adaptiveLighting: ${this.adaptiveLighting}`);
746
746
  // Adaptive Lighting Shift
747
747
  this.adaptiveLightingShift = device.adaptiveLightingShift ?? 0;
748
748
  this.debugLog(`adaptiveLightingShift: ${this.adaptiveLightingShift}`);
749
749
  }
750
750
  async BLEPushConnection() {
751
751
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
752
- await this.warnLog('Using OpenAPI Connection to Push Changes');
752
+ this.warnLog('Using OpenAPI Connection to Push Changes');
753
753
  await this.openAPIpushChanges();
754
754
  }
755
755
  }
756
756
  async BLERefreshConnection(switchbot) {
757
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
757
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
758
758
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
759
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
759
+ this.warnLog('Using OpenAPI Connection to Refresh Status');
760
760
  await this.openAPIRefreshStatus();
761
761
  }
762
762
  }