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

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 (100) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/device/blindtilt.js +103 -103
  3. package/dist/device/blindtilt.js.map +1 -1
  4. package/dist/device/bot.js +84 -84
  5. package/dist/device/bot.js.map +1 -1
  6. package/dist/device/ceilinglight.js +97 -97
  7. package/dist/device/ceilinglight.js.map +1 -1
  8. package/dist/device/colorbulb.js +139 -139
  9. package/dist/device/colorbulb.js.map +1 -1
  10. package/dist/device/contact.js +47 -47
  11. package/dist/device/contact.js.map +1 -1
  12. package/dist/device/curtain.d.ts +1 -1
  13. package/dist/device/curtain.d.ts.map +1 -1
  14. package/dist/device/curtain.js +91 -89
  15. package/dist/device/curtain.js.map +1 -1
  16. package/dist/device/device.d.ts +12 -12
  17. package/dist/device/device.d.ts.map +1 -1
  18. package/dist/device/device.js +42 -42
  19. package/dist/device/device.js.map +1 -1
  20. package/dist/device/fan.js +95 -95
  21. package/dist/device/fan.js.map +1 -1
  22. package/dist/device/hub.js +46 -46
  23. package/dist/device/hub.js.map +1 -1
  24. package/dist/device/humidifier.js +84 -84
  25. package/dist/device/humidifier.js.map +1 -1
  26. package/dist/device/iosensor.js +44 -44
  27. package/dist/device/iosensor.js.map +1 -1
  28. package/dist/device/lightstrip.js +118 -118
  29. package/dist/device/lightstrip.js.map +1 -1
  30. package/dist/device/lock.js +74 -74
  31. package/dist/device/lock.js.map +1 -1
  32. package/dist/device/meter.js +44 -44
  33. package/dist/device/meter.js.map +1 -1
  34. package/dist/device/meterplus.js +42 -42
  35. package/dist/device/meterplus.js.map +1 -1
  36. package/dist/device/meterpro.js +42 -42
  37. package/dist/device/meterpro.js.map +1 -1
  38. package/dist/device/motion.js +44 -44
  39. package/dist/device/motion.js.map +1 -1
  40. package/dist/device/plug.d.ts.map +1 -1
  41. package/dist/device/plug.js +59 -59
  42. package/dist/device/plug.js.map +1 -1
  43. package/dist/device/robotvacuumcleaner.js +73 -73
  44. package/dist/device/robotvacuumcleaner.js.map +1 -1
  45. package/dist/device/waterdetector.js +44 -44
  46. package/dist/device/waterdetector.js.map +1 -1
  47. package/dist/irdevice/airconditioner.js +31 -31
  48. package/dist/irdevice/airconditioner.js.map +1 -1
  49. package/dist/irdevice/airpurifier.js +10 -10
  50. package/dist/irdevice/airpurifier.js.map +1 -1
  51. package/dist/irdevice/camera.js +9 -9
  52. package/dist/irdevice/camera.js.map +1 -1
  53. package/dist/irdevice/fan.js +11 -11
  54. package/dist/irdevice/fan.js.map +1 -1
  55. package/dist/irdevice/irdevice.js +11 -11
  56. package/dist/irdevice/irdevice.js.map +1 -1
  57. package/dist/irdevice/light.js +9 -9
  58. package/dist/irdevice/light.js.map +1 -1
  59. package/dist/irdevice/other.js +55 -55
  60. package/dist/irdevice/other.js.map +1 -1
  61. package/dist/irdevice/tv.js +33 -33
  62. package/dist/irdevice/tv.js.map +1 -1
  63. package/dist/irdevice/vacuumcleaner.js +9 -9
  64. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  65. package/dist/irdevice/waterheater.js +9 -9
  66. package/dist/irdevice/waterheater.js.map +1 -1
  67. package/dist/platform.js +228 -228
  68. package/dist/platform.js.map +1 -1
  69. package/package.json +9 -9
  70. package/src/device/blindtilt.ts +103 -103
  71. package/src/device/bot.ts +84 -84
  72. package/src/device/ceilinglight.ts +97 -97
  73. package/src/device/colorbulb.ts +139 -139
  74. package/src/device/contact.ts +47 -47
  75. package/src/device/curtain.ts +91 -89
  76. package/src/device/device.ts +42 -42
  77. package/src/device/fan.ts +95 -95
  78. package/src/device/hub.ts +46 -46
  79. package/src/device/humidifier.ts +84 -84
  80. package/src/device/iosensor.ts +44 -44
  81. package/src/device/lightstrip.ts +118 -118
  82. package/src/device/lock.ts +74 -74
  83. package/src/device/meter.ts +44 -44
  84. package/src/device/meterplus.ts +42 -42
  85. package/src/device/meterpro.ts +42 -42
  86. package/src/device/motion.ts +44 -44
  87. package/src/device/plug.ts +61 -61
  88. package/src/device/robotvacuumcleaner.ts +73 -73
  89. package/src/device/waterdetector.ts +44 -44
  90. package/src/irdevice/airconditioner.ts +31 -31
  91. package/src/irdevice/airpurifier.ts +10 -10
  92. package/src/irdevice/camera.ts +9 -9
  93. package/src/irdevice/fan.ts +11 -11
  94. package/src/irdevice/irdevice.ts +11 -11
  95. package/src/irdevice/light.ts +9 -9
  96. package/src/irdevice/other.ts +55 -55
  97. package/src/irdevice/tv.ts +33 -33
  98. package/src/irdevice/vacuumcleaner.ts +9 -9
  99. package/src/irdevice/waterheater.ts +9 -9
  100. package/src/platform.ts +228 -228
@@ -132,24 +132,24 @@ export class Fan extends deviceBase {
132
132
  }
133
133
  catch (e) {
134
134
  await this.apiError(e);
135
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
135
+ this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
136
136
  }
137
137
  this.fanUpdateInProgress = false;
138
138
  });
139
139
  }
140
140
  async BLEparseStatus() {
141
- await this.debugLog('BLEparseStatus');
142
- await this.debugLog(`(powerState, fanSpeed) = BLE:(${this.serviceData.state}, ${this.serviceData.fanSpeed}), current:(${this.Fan.Active}, ${this.Fan.RotationSpeed})`);
141
+ this.debugLog('BLEparseStatus');
142
+ this.debugLog(`(powerState, fanSpeed) = BLE:(${this.serviceData.state}, ${this.serviceData.fanSpeed}), current:(${this.Fan.Active}, ${this.Fan.RotationSpeed})`);
143
143
  // Active
144
144
  this.Fan.Active = this.serviceData.state === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
145
- await this.debugLog(`Active: ${this.Fan.Active}`);
145
+ this.debugLog(`Active: ${this.Fan.Active}`);
146
146
  // RotationSpeed
147
147
  this.Fan.RotationSpeed = this.serviceData.fanSpeed; // ?? 0
148
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
148
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
149
149
  }
150
150
  async openAPIparseStatus() {
151
- await this.debugLog('openAPIparseStatus');
152
- await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = OpenAPI:(${this.deviceStatus.version}, ${this.deviceStatus.battery}, ${this.deviceStatus.power}, ${this.deviceStatus.oscillation}, ${this.deviceStatus.chargingStatus}, ${this.deviceStatus.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
151
+ this.debugLog('openAPIparseStatus');
152
+ this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = OpenAPI:(${this.deviceStatus.version}, ${this.deviceStatus.battery}, ${this.deviceStatus.power}, ${this.deviceStatus.oscillation}, ${this.deviceStatus.chargingStatus}, ${this.deviceStatus.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
153
153
  // Active
154
154
  this.Fan.Active = this.deviceStatus.power === 'on' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
155
155
  this.debugLog(`Active: ${this.Fan.Active}`);
@@ -157,26 +157,26 @@ export class Fan extends deviceBase {
157
157
  this.Fan.SwingMode = this.deviceStatus.oscillation === 'on'
158
158
  ? this.hap.Characteristic.SwingMode.SWING_ENABLED
159
159
  : this.hap.Characteristic.SwingMode.SWING_DISABLED;
160
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
160
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
161
161
  // RotationSpeed
162
162
  this.Fan.RotationSpeed = this.deviceStatus.fanSpeed ?? 0;
163
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
163
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
164
164
  // ChargingState
165
165
  this.Battery.ChargingState = this.deviceStatus.chargingStatus === 'charging'
166
166
  ? this.hap.Characteristic.ChargingState.CHARGING
167
167
  : this.hap.Characteristic.ChargingState.NOT_CHARGING;
168
168
  // BatteryLevel
169
169
  this.Battery.BatteryLevel = this.deviceStatus.battery;
170
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
170
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
171
171
  // StatusLowBattery
172
172
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
173
173
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
174
174
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
175
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
175
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
176
176
  // Firmware Version
177
177
  if (this.deviceStatus.version) {
178
178
  const version = this.deviceStatus.version.toString();
179
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
179
+ this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
180
180
  const deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
181
181
  this.accessory
182
182
  .getService(this.hap.Service.AccessoryInformation)
@@ -185,36 +185,36 @@ export class Fan extends deviceBase {
185
185
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
186
186
  .updateValue(deviceVersion);
187
187
  this.accessory.context.version = deviceVersion;
188
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
188
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`);
189
189
  }
190
190
  }
191
191
  async parseStatusWebhook() {
192
- await this.debugLog('parseStatusWebhook');
193
- await this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${this.webhookContext.version}, ${this.webhookContext.battery}, ${this.webhookContext.powerState}, ${this.webhookContext.oscillation}, ${this.webhookContext.chargingStatus}, ${this.webhookContext.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
192
+ this.debugLog('parseStatusWebhook');
193
+ this.debugLog(`(version, battery, powerState, oscillation, chargingStatus, fanSpeed) = Webhook:(${this.webhookContext.version}, ${this.webhookContext.battery}, ${this.webhookContext.powerState}, ${this.webhookContext.oscillation}, ${this.webhookContext.chargingStatus}, ${this.webhookContext.fanSpeed}), current:(${this.accessory.context.version}, ${this.Battery.BatteryLevel}, ${this.Fan.Active}, ${this.Fan.SwingMode}, ${this.Battery.ChargingState}, ${this.Fan.RotationSpeed})`);
194
194
  // Active
195
195
  this.Fan.Active = this.webhookContext.powerState === 'ON' ? this.hap.Characteristic.Active.ACTIVE : this.hap.Characteristic.Active.INACTIVE;
196
- await this.debugLog(`Active: ${this.Fan.Active}`);
196
+ this.debugLog(`Active: ${this.Fan.Active}`);
197
197
  // SwingMode
198
198
  this.Fan.SwingMode = this.webhookContext.oscillation === 'on'
199
199
  ? this.hap.Characteristic.SwingMode.SWING_ENABLED
200
200
  : this.hap.Characteristic.SwingMode.SWING_DISABLED;
201
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
201
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
202
202
  // RotationSpeed
203
203
  this.Fan.RotationSpeed = this.webhookContext.fanSpeed; // ?? 0
204
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
204
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
205
205
  // BatteryLevel
206
206
  this.Battery.BatteryLevel = this.webhookContext.battery;
207
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
207
+ this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
208
208
  // StatusLowBattery
209
209
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
210
210
  ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
211
211
  : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
212
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
212
+ this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
213
213
  // ChargingState
214
214
  this.Battery.ChargingState = this.webhookContext.chargingStatus === 'charging'
215
215
  ? this.hap.Characteristic.ChargingState.CHARGING
216
216
  : this.hap.Characteristic.ChargingState.NOT_CHARGING;
217
- await this.debugLog(`ChargingState: ${this.Battery.ChargingState}`);
217
+ this.debugLog(`ChargingState: ${this.Battery.ChargingState}`);
218
218
  // FirmwareVersion
219
219
  if (this.webhookContext.version) {
220
220
  const deviceVersion = this.webhookContext.version.replace(/^V|-.*$/g, '') ?? '0.0.0';
@@ -225,7 +225,7 @@ export class Fan extends deviceBase {
225
225
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
226
226
  .updateValue(deviceVersion);
227
227
  this.accessory.context.version = deviceVersion;
228
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
228
+ this.debugSuccessLog(`version: ${this.accessory.context.version}`);
229
229
  }
230
230
  }
231
231
  /**
@@ -233,7 +233,7 @@ export class Fan extends deviceBase {
233
233
  */
234
234
  async refreshStatus() {
235
235
  if (!this.device.enableCloudService && this.OpenAPI) {
236
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
236
+ this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
237
237
  }
238
238
  else if (this.BLE) {
239
239
  await this.BLERefreshStatus();
@@ -243,11 +243,11 @@ export class Fan extends deviceBase {
243
243
  }
244
244
  else {
245
245
  await this.offlineOff();
246
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
246
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
247
247
  }
248
248
  }
249
249
  async BLERefreshStatus() {
250
- await this.debugLog('BLERefreshStatus');
250
+ this.debugLog('BLERefreshStatus');
251
251
  const switchBotBLE = await this.switchbotBLE();
252
252
  if (switchBotBLE === undefined) {
253
253
  await this.BLERefreshConnection(switchBotBLE);
@@ -264,79 +264,79 @@ export class Fan extends deviceBase {
264
264
  await this.updateHomeKitCharacteristics();
265
265
  }
266
266
  else {
267
- await this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
267
+ this.errorLog(`failed to get serviceData, serviceData: ${JSON.stringify(serviceData)}`);
268
268
  await this.BLERefreshConnection(switchBotBLE);
269
269
  }
270
270
  })();
271
271
  }
272
272
  }
273
273
  async registerPlatformBLE() {
274
- await this.debugLog('registerPlatformBLE');
274
+ this.debugLog('registerPlatformBLE');
275
275
  if (this.config.options?.BLE) {
276
- await this.debugLog('is listening to Platform BLE.');
276
+ this.debugLog('is listening to Platform BLE.');
277
277
  try {
278
278
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
279
279
  this.device.bleMac = formattedDeviceId;
280
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
280
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
281
281
  this.platform.bleEventHandler[this.device.bleMac] = async (context) => {
282
282
  try {
283
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
283
+ this.debugLog(`received BLE: ${JSON.stringify(context)}`);
284
284
  this.serviceData = context;
285
285
  await this.BLEparseStatus();
286
286
  await this.updateHomeKitCharacteristics();
287
287
  }
288
288
  catch (e) {
289
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
289
+ this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
290
290
  }
291
291
  };
292
292
  }
293
293
  catch (error) {
294
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
294
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
295
295
  }
296
296
  }
297
297
  else {
298
- await this.debugLog('is not listening to Platform BLE');
298
+ this.debugLog('is not listening to Platform BLE');
299
299
  }
300
300
  }
301
301
  async openAPIRefreshStatus() {
302
- await this.debugLog('openAPIRefreshStatus');
302
+ this.debugLog('openAPIRefreshStatus');
303
303
  try {
304
- const { body } = await this.deviceRefreshStatus();
305
- const deviceStatus = await body;
306
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
304
+ const response = await this.deviceRefreshStatus();
305
+ const deviceStatus = response.body;
306
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
307
307
  if (await this.successfulStatusCodes(deviceStatus)) {
308
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
308
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
309
309
  this.deviceStatus = deviceStatus.body;
310
310
  await this.openAPIparseStatus();
311
311
  await this.updateHomeKitCharacteristics();
312
312
  }
313
313
  else {
314
- await this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
315
- await this.debugWarnLog(deviceStatus);
314
+ this.debugWarnLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
315
+ this.debugWarnLog(deviceStatus);
316
316
  }
317
317
  }
318
318
  catch (e) {
319
319
  await this.apiError(e);
320
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
320
+ this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
321
321
  }
322
322
  }
323
323
  async registerWebhook() {
324
324
  if (this.device.webhook) {
325
- await this.debugLog('is listening webhook.');
325
+ this.debugLog('is listening webhook.');
326
326
  this.platform.webhookEventHandler[this.device.deviceId] = async (context) => {
327
327
  try {
328
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
328
+ this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
329
329
  this.webhookContext = context;
330
330
  await this.parseStatusWebhook();
331
331
  await this.updateHomeKitCharacteristics();
332
332
  }
333
333
  catch (e) {
334
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
334
+ this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e.message ?? e}`);
335
335
  }
336
336
  };
337
337
  }
338
338
  else {
339
- await this.debugLog('is not listening webhook.');
339
+ this.debugLog('is not listening webhook.');
340
340
  }
341
341
  }
342
342
  /**
@@ -350,7 +350,7 @@ export class Fan extends deviceBase {
350
350
  */
351
351
  async pushChanges() {
352
352
  if (!this.device.enableCloudService && this.OpenAPI) {
353
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
353
+ this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
354
354
  }
355
355
  else if (this.BLE) {
356
356
  await this.BLEpushChanges();
@@ -358,21 +358,21 @@ export class Fan extends deviceBase {
358
358
  else if (this.OpenAPI && this.platform.config.credentials?.token) {
359
359
  await this.openAPIpushChanges();
360
360
  if (this.Fan.Active) {
361
- await this.debugLog(`Active: ${this.Fan.Active}`);
361
+ this.debugLog(`Active: ${this.Fan.Active}`);
362
362
  // Push RotationSpeed Update
363
- await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
363
+ this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
364
364
  await this.pushRotationSpeedChanges();
365
365
  // Push SwingMode Update
366
- await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
366
+ this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
367
367
  await this.pushSwingModeChanges();
368
368
  }
369
369
  else {
370
- await this.debugLog('BLE (RotationSpeed) & (SwingMode) changes will not happen, as the device is Off.');
370
+ this.debugLog('BLE (RotationSpeed) & (SwingMode) changes will not happen, as the device is Off.');
371
371
  }
372
372
  }
373
373
  else {
374
374
  await this.offlineOff();
375
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
375
+ this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
376
376
  }
377
377
  // Refresh the status from the API
378
378
  interval(15000)
@@ -383,14 +383,14 @@ export class Fan extends deviceBase {
383
383
  });
384
384
  }
385
385
  async BLEpushChanges() {
386
- await this.debugLog('BLEpushChanges');
386
+ this.debugLog('BLEpushChanges');
387
387
  if (this.Fan.Active !== this.accessory.context.Active) {
388
- await this.debugLog(`BLEpushChanges On: ${this.Fan.Active} OnCached: ${this.accessory.context.Active}`);
388
+ this.debugLog(`BLEpushChanges On: ${this.Fan.Active} OnCached: ${this.accessory.context.Active}`);
389
389
  const switchBotBLE = await this.platform.connectBLE(this.accessory, this.device);
390
390
  try {
391
391
  const formattedDeviceId = formatDeviceIdAsMac(this.device.deviceId);
392
392
  this.device.bleMac = formattedDeviceId;
393
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
393
+ this.debugLog(`bleMac: ${this.device.bleMac}`);
394
394
  if (switchBotBLE !== false) {
395
395
  switchBotBLE
396
396
  .discover({ model: this.device.bleModel, id: this.device.bleMac })
@@ -409,30 +409,30 @@ export class Fan extends deviceBase {
409
409
  });
410
410
  })
411
411
  .then(async () => {
412
- await this.successLog(`Active: ${this.Fan.Active} sent over SwitchBot BLE, sent successfully`);
412
+ this.successLog(`Active: ${this.Fan.Active} sent over SwitchBot BLE, sent successfully`);
413
413
  await this.updateHomeKitCharacteristics();
414
414
  })
415
415
  .catch(async (e) => {
416
416
  await this.apiError(e);
417
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
417
+ this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
418
418
  await this.BLEPushConnection();
419
419
  });
420
420
  }
421
421
  else {
422
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
422
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${JSON.stringify(switchBotBLE)}`);
423
423
  await this.BLEPushConnection();
424
424
  }
425
425
  }
426
426
  catch (error) {
427
- await this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
427
+ this.errorLog(`failed to format device ID as MAC, Error: ${error}`);
428
428
  }
429
429
  }
430
430
  else {
431
- await this.debugLog(`No change (BLEpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`);
431
+ this.debugLog(`No change (BLEpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`);
432
432
  }
433
433
  }
434
434
  async openAPIpushChanges() {
435
- await this.debugLog('openAPIpushChanges');
435
+ this.debugLog('openAPIpushChanges');
436
436
  if (this.Fan.Active !== this.accessory.context.Active) {
437
437
  const command = this.Fan.Active ? 'turnOn' : 'turnOff';
438
438
  const bodyChange = {
@@ -440,13 +440,13 @@ export class Fan extends deviceBase {
440
440
  parameter: 'default',
441
441
  commandType: 'command',
442
442
  };
443
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
443
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
444
444
  try {
445
- const { body } = await this.pushChangeRequest(bodyChange);
446
- const deviceStatus = await body;
447
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
445
+ const response = await this.pushChangeRequest(bodyChange);
446
+ const deviceStatus = response.body;
447
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
448
448
  if (await this.successfulStatusCodes(deviceStatus)) {
449
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
449
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
450
450
  await this.updateHomeKitCharacteristics();
451
451
  }
452
452
  else {
@@ -455,28 +455,28 @@ export class Fan extends deviceBase {
455
455
  }
456
456
  catch (e) {
457
457
  await this.apiError(e);
458
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
458
+ this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
459
459
  }
460
460
  }
461
461
  else {
462
- await this.debugLog(`No changes (openAPIpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`);
462
+ this.debugLog(`No changes (openAPIpushChanges), Active: ${this.Fan.Active}, ActiveCached: ${this.accessory.context.Active}`);
463
463
  }
464
464
  }
465
465
  async pushRotationSpeedChanges() {
466
- await this.debugLog('pushRotationSpeedChanges');
466
+ this.debugLog('pushRotationSpeedChanges');
467
467
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
468
468
  const bodyChange = {
469
469
  command: 'setWindSpeed',
470
470
  parameter: `${this.Fan.RotationSpeed}`,
471
471
  commandType: 'command',
472
472
  };
473
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
473
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
474
474
  try {
475
- const { body } = await this.pushChangeRequest(bodyChange);
476
- const deviceStatus = await body;
477
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
475
+ const response = await this.pushChangeRequest(bodyChange);
476
+ const deviceStatus = response.body;
477
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
478
478
  if (await this.successfulStatusCodes(deviceStatus)) {
479
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
479
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
480
480
  await this.updateHomeKitCharacteristics();
481
481
  }
482
482
  else {
@@ -485,15 +485,15 @@ export class Fan extends deviceBase {
485
485
  }
486
486
  catch (e) {
487
487
  await this.apiError(e);
488
- await this.errorLog(`failed pushRotationSpeedChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
488
+ this.errorLog(`failed pushRotationSpeedChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
489
489
  }
490
490
  }
491
491
  else {
492
- await this.debugLog(`No changes (pushRotationSpeedChanges), RotationSpeed: ${this.Fan.RotationSpeed}, RotationSpeedCached: ${this.accessory.context.RotationSpeed}`);
492
+ this.debugLog(`No changes (pushRotationSpeedChanges), RotationSpeed: ${this.Fan.RotationSpeed}, RotationSpeedCached: ${this.accessory.context.RotationSpeed}`);
493
493
  }
494
494
  }
495
495
  async pushSwingModeChanges() {
496
- await this.debugLog('pushSwingModeChanges');
496
+ this.debugLog('pushSwingModeChanges');
497
497
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
498
498
  const parameter = this.Fan.SwingMode === this.hap.Characteristic.SwingMode.SWING_ENABLED ? 'on' : 'off';
499
499
  const bodyChange = {
@@ -501,13 +501,13 @@ export class Fan extends deviceBase {
501
501
  parameter: `${parameter}`,
502
502
  commandType: 'command',
503
503
  };
504
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
504
+ this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
505
505
  try {
506
- const { body } = await this.pushChangeRequest(bodyChange);
507
- const deviceStatus = await body;
508
- await this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
506
+ const response = await this.pushChangeRequest(bodyChange);
507
+ const deviceStatus = response.body;
508
+ this.debugLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
509
509
  if (await this.successfulStatusCodes(deviceStatus)) {
510
- await this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
510
+ this.debugSuccessLog(`statusCode: ${deviceStatus.statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
511
511
  await this.updateHomeKitCharacteristics();
512
512
  }
513
513
  else {
@@ -516,11 +516,11 @@ export class Fan extends deviceBase {
516
516
  }
517
517
  catch (e) {
518
518
  await this.apiError(e);
519
- await this.errorLog(`failed pushSwingModeChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
519
+ this.errorLog(`failed pushSwingModeChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
520
520
  }
521
521
  }
522
522
  else {
523
- await this.debugLog(`No changes (pushSwingModeChanges), SwingMode: ${this.Fan.SwingMode}, SwingModeCached: ${this.accessory.context.SwingMode}`);
523
+ this.debugLog(`No changes (pushSwingModeChanges), SwingMode: ${this.Fan.SwingMode}, SwingModeCached: ${this.accessory.context.SwingMode}`);
524
524
  }
525
525
  }
526
526
  /**
@@ -528,10 +528,10 @@ export class Fan extends deviceBase {
528
528
  */
529
529
  async ActiveSet(value) {
530
530
  if (this.Fan.Active !== this.accessory.context.Active) {
531
- await this.infoLog(`Set Active: ${value}`);
531
+ this.infoLog(`Set Active: ${value}`);
532
532
  }
533
533
  else {
534
- await this.debugLog(`No Changes, Active: ${value}`);
534
+ this.debugLog(`No Changes, Active: ${value}`);
535
535
  }
536
536
  this.Fan.Active = value;
537
537
  this.doFanUpdate.next();
@@ -541,10 +541,10 @@ export class Fan extends deviceBase {
541
541
  */
542
542
  async RotationSpeedSet(value) {
543
543
  if (this.Fan.RotationSpeed !== this.accessory.context.RotationSpeed) {
544
- await this.infoLog(`Set RotationSpeed ${value}`);
544
+ this.infoLog(`Set RotationSpeed ${value}`);
545
545
  }
546
546
  else {
547
- await this.debugLog(`No Changes, RotationSpeed: ${value}`);
547
+ this.debugLog(`No Changes, RotationSpeed: ${value}`);
548
548
  }
549
549
  this.Fan.RotationSpeed = value;
550
550
  this.doFanUpdate.next();
@@ -554,10 +554,10 @@ export class Fan extends deviceBase {
554
554
  */
555
555
  async SwingModeSet(value) {
556
556
  if (this.Fan.SwingMode !== this.accessory.context.SwingMode) {
557
- await this.infoLog(`Set SwingMode ${value}`);
557
+ this.infoLog(`Set SwingMode ${value}`);
558
558
  }
559
559
  else {
560
- await this.debugLog(`No Changes, SwingMode: ${value}`);
560
+ this.debugLog(`No Changes, SwingMode: ${value}`);
561
561
  }
562
562
  this.Fan.SwingMode = value;
563
563
  this.doFanUpdate.next();
@@ -567,10 +567,10 @@ export class Fan extends deviceBase {
567
567
  */
568
568
  async OnSet(value) {
569
569
  if (this.LightBulb.On !== this.accessory.context.On) {
570
- await this.infoLog(`Set On: ${value}`);
570
+ this.infoLog(`Set On: ${value}`);
571
571
  }
572
572
  else {
573
- await this.debugLog(`No Changes, On: ${value}`);
573
+ this.debugLog(`No Changes, On: ${value}`);
574
574
  }
575
575
  this.LightBulb.On = value;
576
576
  this.doFanUpdate.next();
@@ -580,7 +580,7 @@ export class Fan extends deviceBase {
580
580
  */
581
581
  async BrightnessSet(value) {
582
582
  if (this.LightBulb.On && (this.LightBulb.Brightness !== this.accessory.context.Brightness)) {
583
- await this.infoLog(`Set Brightness: ${value}`);
583
+ this.infoLog(`Set Brightness: ${value}`);
584
584
  }
585
585
  else {
586
586
  if (this.LightBulb.On) {
@@ -613,14 +613,14 @@ export class Fan extends deviceBase {
613
613
  }
614
614
  async BLEPushConnection() {
615
615
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
616
- await this.warnLog('Using OpenAPI Connection to Push Changes');
616
+ this.warnLog('Using OpenAPI Connection to Push Changes');
617
617
  await this.openAPIpushChanges();
618
618
  }
619
619
  }
620
620
  async BLERefreshConnection(switchbot) {
621
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
621
+ this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
622
622
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
623
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
623
+ this.warnLog('Using OpenAPI Connection to Refresh Status');
624
624
  await this.openAPIRefreshStatus();
625
625
  }
626
626
  }