@switchbot/homebridge-switchbot 3.5.1-beta.1 → 3.5.1-beta.11

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 (197) hide show
  1. package/README.md +16 -0
  2. package/dist/device/blindtilt.d.ts +15 -6
  3. package/dist/device/blindtilt.d.ts.map +1 -1
  4. package/dist/device/blindtilt.js +203 -255
  5. package/dist/device/blindtilt.js.map +1 -1
  6. package/dist/device/bot.d.ts +9 -4
  7. package/dist/device/bot.d.ts.map +1 -1
  8. package/dist/device/bot.js +196 -218
  9. package/dist/device/bot.js.map +1 -1
  10. package/dist/device/ceilinglight.d.ts +9 -4
  11. package/dist/device/ceilinglight.d.ts.map +1 -1
  12. package/dist/device/ceilinglight.js +203 -249
  13. package/dist/device/ceilinglight.js.map +1 -1
  14. package/dist/device/colorbulb.d.ts +10 -5
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +329 -378
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts +9 -4
  19. package/dist/device/contact.d.ts.map +1 -1
  20. package/dist/device/contact.js +99 -142
  21. package/dist/device/contact.js.map +1 -1
  22. package/dist/device/curtain.d.ts +19 -7
  23. package/dist/device/curtain.d.ts.map +1 -1
  24. package/dist/device/curtain.js +203 -264
  25. package/dist/device/curtain.js.map +1 -1
  26. package/dist/device/device.d.ts +28 -32
  27. package/dist/device/device.d.ts.map +1 -1
  28. package/dist/device/device.js +186 -225
  29. package/dist/device/device.js.map +1 -1
  30. package/dist/device/fan.d.ts +9 -4
  31. package/dist/device/fan.d.ts.map +1 -1
  32. package/dist/device/fan.js +198 -227
  33. package/dist/device/fan.js.map +1 -1
  34. package/dist/device/hub.d.ts +9 -5
  35. package/dist/device/hub.d.ts.map +1 -1
  36. package/dist/device/hub.js +106 -231
  37. package/dist/device/hub.js.map +1 -1
  38. package/dist/device/humidifier.d.ts +12 -4
  39. package/dist/device/humidifier.d.ts.map +1 -1
  40. package/dist/device/humidifier.js +192 -232
  41. package/dist/device/humidifier.js.map +1 -1
  42. package/dist/device/iosensor.d.ts +9 -4
  43. package/dist/device/iosensor.d.ts.map +1 -1
  44. package/dist/device/iosensor.js +91 -157
  45. package/dist/device/iosensor.js.map +1 -1
  46. package/dist/device/lightstrip.d.ts +10 -5
  47. package/dist/device/lightstrip.d.ts.map +1 -1
  48. package/dist/device/lightstrip.js +287 -367
  49. package/dist/device/lightstrip.js.map +1 -1
  50. package/dist/device/lock.d.ts +10 -5
  51. package/dist/device/lock.d.ts.map +1 -1
  52. package/dist/device/lock.js +171 -216
  53. package/dist/device/lock.js.map +1 -1
  54. package/dist/device/meter.d.ts +9 -4
  55. package/dist/device/meter.d.ts.map +1 -1
  56. package/dist/device/meter.js +93 -158
  57. package/dist/device/meter.js.map +1 -1
  58. package/dist/device/meterplus.d.ts +9 -4
  59. package/dist/device/meterplus.d.ts.map +1 -1
  60. package/dist/device/meterplus.js +94 -155
  61. package/dist/device/meterplus.js.map +1 -1
  62. package/dist/device/motion.d.ts +9 -4
  63. package/dist/device/motion.d.ts.map +1 -1
  64. package/dist/device/motion.js +84 -142
  65. package/dist/device/motion.js.map +1 -1
  66. package/dist/device/plug.d.ts +9 -4
  67. package/dist/device/plug.d.ts.map +1 -1
  68. package/dist/device/plug.js +99 -124
  69. package/dist/device/plug.js.map +1 -1
  70. package/dist/device/robotvacuumcleaner.d.ts +9 -6
  71. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  72. package/dist/device/robotvacuumcleaner.js +170 -253
  73. package/dist/device/robotvacuumcleaner.js.map +1 -1
  74. package/dist/device/waterdetector.d.ts +12 -4
  75. package/dist/device/waterdetector.d.ts.map +1 -1
  76. package/dist/device/waterdetector.js +105 -129
  77. package/dist/device/waterdetector.js.map +1 -1
  78. package/dist/irdevice/airconditioner.d.ts +2 -1
  79. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  80. package/dist/irdevice/airconditioner.js +45 -51
  81. package/dist/irdevice/airconditioner.js.map +1 -1
  82. package/dist/irdevice/airpurifier.d.ts +2 -1
  83. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  84. package/dist/irdevice/airpurifier.js +17 -17
  85. package/dist/irdevice/airpurifier.js.map +1 -1
  86. package/dist/irdevice/camera.d.ts +2 -1
  87. package/dist/irdevice/camera.d.ts.map +1 -1
  88. package/dist/irdevice/camera.js +9 -9
  89. package/dist/irdevice/camera.js.map +1 -1
  90. package/dist/irdevice/fan.d.ts +2 -1
  91. package/dist/irdevice/fan.d.ts.map +1 -1
  92. package/dist/irdevice/fan.js +19 -19
  93. package/dist/irdevice/fan.js.map +1 -1
  94. package/dist/irdevice/irdevice.d.ts +24 -11
  95. package/dist/irdevice/irdevice.d.ts.map +1 -1
  96. package/dist/irdevice/irdevice.js +90 -68
  97. package/dist/irdevice/irdevice.js.map +1 -1
  98. package/dist/irdevice/light.d.ts +2 -1
  99. package/dist/irdevice/light.d.ts.map +1 -1
  100. package/dist/irdevice/light.js +15 -17
  101. package/dist/irdevice/light.js.map +1 -1
  102. package/dist/irdevice/other.d.ts +2 -1
  103. package/dist/irdevice/other.d.ts.map +1 -1
  104. package/dist/irdevice/other.js +76 -76
  105. package/dist/irdevice/other.js.map +1 -1
  106. package/dist/irdevice/tv.d.ts +2 -1
  107. package/dist/irdevice/tv.d.ts.map +1 -1
  108. package/dist/irdevice/tv.js +35 -35
  109. package/dist/irdevice/tv.js.map +1 -1
  110. package/dist/irdevice/vacuumcleaner.d.ts +2 -1
  111. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  112. package/dist/irdevice/vacuumcleaner.js +9 -9
  113. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  114. package/dist/irdevice/waterheater.d.ts +2 -1
  115. package/dist/irdevice/waterheater.d.ts.map +1 -1
  116. package/dist/irdevice/waterheater.js +9 -9
  117. package/dist/irdevice/waterheater.js.map +1 -1
  118. package/dist/platform.d.ts +15 -15
  119. package/dist/platform.d.ts.map +1 -1
  120. package/dist/platform.js +288 -271
  121. package/dist/platform.js.map +1 -1
  122. package/dist/settings.d.ts +49 -191
  123. package/dist/settings.d.ts.map +1 -1
  124. package/dist/settings.js +19 -0
  125. package/dist/settings.js.map +1 -1
  126. package/dist/types/bledevicestatus.d.ts +279 -0
  127. package/dist/types/bledevicestatus.d.ts.map +1 -0
  128. package/dist/types/bledevicestatus.js +2 -0
  129. package/dist/types/bledevicestatus.js.map +1 -0
  130. package/dist/types/devicelist.d.ts +89 -0
  131. package/dist/types/devicelist.d.ts.map +1 -0
  132. package/dist/types/devicelist.js +6 -0
  133. package/dist/types/devicelist.js.map +1 -0
  134. package/dist/types/deviceresponse.d.ts +13 -0
  135. package/dist/types/deviceresponse.d.ts.map +1 -0
  136. package/dist/types/deviceresponse.js +2 -0
  137. package/dist/types/deviceresponse.js.map +1 -0
  138. package/dist/types/devicestatus.d.ts +149 -0
  139. package/dist/types/devicestatus.d.ts.map +1 -0
  140. package/dist/types/devicestatus.js +3 -0
  141. package/dist/types/devicestatus.js.map +1 -0
  142. package/dist/types/devicewebhookstatus.d.ts +156 -0
  143. package/dist/types/devicewebhookstatus.d.ts.map +1 -0
  144. package/dist/types/devicewebhookstatus.js +2 -0
  145. package/dist/types/devicewebhookstatus.js.map +1 -0
  146. package/dist/types/irdevicelist.d.ts +10 -0
  147. package/dist/types/irdevicelist.d.ts.map +1 -0
  148. package/dist/types/irdevicelist.js +2 -0
  149. package/dist/types/irdevicelist.js.map +1 -0
  150. package/dist/types/pushbody.d.ts +6 -0
  151. package/dist/types/pushbody.d.ts.map +1 -0
  152. package/dist/types/pushbody.js +2 -0
  153. package/dist/types/pushbody.js.map +1 -0
  154. package/dist/utils.d.ts +25 -0
  155. package/dist/utils.d.ts.map +1 -1
  156. package/dist/utils.js +28 -0
  157. package/dist/utils.js.map +1 -1
  158. package/package.json +10 -10
  159. package/src/device/blindtilt.ts +224 -264
  160. package/src/device/bot.ts +208 -221
  161. package/src/device/ceilinglight.ts +211 -261
  162. package/src/device/colorbulb.ts +334 -397
  163. package/src/device/contact.ts +111 -146
  164. package/src/device/curtain.ts +220 -283
  165. package/src/device/device.ts +194 -245
  166. package/src/device/fan.ts +214 -230
  167. package/src/device/hub.ts +126 -246
  168. package/src/device/humidifier.ts +216 -243
  169. package/src/device/iosensor.ts +114 -166
  170. package/src/device/lightstrip.ts +302 -377
  171. package/src/device/lock.ts +187 -221
  172. package/src/device/meter.ts +116 -177
  173. package/src/device/meterplus.ts +117 -174
  174. package/src/device/motion.ts +99 -144
  175. package/src/device/plug.ts +110 -128
  176. package/src/device/robotvacuumcleaner.ts +189 -252
  177. package/src/device/waterdetector.ts +123 -139
  178. package/src/irdevice/airconditioner.ts +47 -52
  179. package/src/irdevice/airpurifier.ts +19 -18
  180. package/src/irdevice/camera.ts +11 -10
  181. package/src/irdevice/fan.ts +21 -20
  182. package/src/irdevice/irdevice.ts +95 -70
  183. package/src/irdevice/light.ts +17 -18
  184. package/src/irdevice/other.ts +78 -77
  185. package/src/irdevice/tv.ts +37 -36
  186. package/src/irdevice/vacuumcleaner.ts +11 -10
  187. package/src/irdevice/waterheater.ts +11 -10
  188. package/src/platform.ts +290 -272
  189. package/src/settings.ts +30 -239
  190. package/src/types/bledevicestatus.ts +305 -0
  191. package/src/types/devicelist.ts +124 -0
  192. package/src/types/deviceresponse.ts +15 -0
  193. package/src/types/devicestatus.ts +178 -0
  194. package/src/types/devicewebhookstatus.ts +196 -0
  195. package/src/types/irdevicelist.ts +15 -0
  196. package/src/types/pushbody.ts +9 -0
  197. package/src/utils.ts +33 -0
@@ -5,7 +5,8 @@
5
5
  import { irdeviceBase } from './irdevice.js';
6
6
 
7
7
  import type { SwitchBotPlatform } from '../platform.js';
8
- import type { irDevicesConfig, irdevice } from '../settings.js';
8
+ import type { irDevicesConfig } from '../settings.js';
9
+ import type { irdevice } from '../types/irdevicelist.js';
9
10
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
11
 
11
12
  /**
@@ -180,7 +181,7 @@ export class AirConditioner extends irdeviceBase {
180
181
  * AirConditioner: "command" "highSpeed" "default" = fan speed to high
181
182
  */
182
183
  async pushAirConditionerOnChanges(): Promise<void> {
183
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
184
+ await this.debugLog(`pushAirConditionerOnChanges Active: ${this.HeaterCooler.Active},`
184
185
  + ` disablePushOn: ${this.disablePushOn}`);
185
186
  if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
186
187
  const commandType: string = await this.commandType();
@@ -195,7 +196,7 @@ export class AirConditioner extends irdeviceBase {
195
196
  }
196
197
 
197
198
  async pushAirConditionerOffChanges(): Promise<void> {
198
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
199
+ await this.debugLog(`pushAirConditionerOffChanges Active: ${this.HeaterCooler.Active},`
199
200
  + ` disablePushOff: ${this.disablePushOff}`);
200
201
  if (this.HeaterCooler.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
201
202
  const commandType: string = await this.commandType();
@@ -210,7 +211,7 @@ export class AirConditioner extends irdeviceBase {
210
211
  }
211
212
 
212
213
  async pushAirConditionerStatusChanges(): Promise<void> {
213
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
214
+ await this.debugLog(`pushAirConditionerStatusChanges Active: ${this.HeaterCooler.Active},`
214
215
  + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
215
216
  if (!this.Busy) {
216
217
  this.Busy = true;
@@ -223,7 +224,7 @@ export class AirConditioner extends irdeviceBase {
223
224
  }
224
225
 
225
226
  async pushAirConditionerDetailsChanges(): Promise<void> {
226
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
227
+ await this.debugLog(`pushAirConditionerDetailsChanges Active: ${this.HeaterCooler.Active},`
227
228
  + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
228
229
  //await this.deviceContext();
229
230
  if (this.CurrentMode === undefined) {
@@ -240,7 +241,7 @@ export class AirConditioner extends irdeviceBase {
240
241
  if (this.CurrentMode === 1) {
241
242
  // Remove or make configurable?
242
243
  this.HeaterCooler.ThresholdTemperature = 25;
243
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentMode: ${this.CurrentMode},`
244
+ await this.debugLog(`CurrentMode: ${this.CurrentMode},`
244
245
  + ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
245
246
  }
246
247
  const parameter = `${this.HeaterCooler.ThresholdTemperature},${this.CurrentMode},${this.CurrentFanSpeed},${this.state}`;
@@ -343,9 +344,9 @@ export class AirConditioner extends irdeviceBase {
343
344
  }
344
345
 
345
346
  async pushChanges(bodyChange: any): Promise<void> {
346
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
347
+ await this.debugLog('pushChanges');
347
348
  if (this.device.connectionType === 'OpenAPI' && !this.disablePushDetail) {
348
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
349
+ await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
349
350
  try {
350
351
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
351
352
  const deviceStatus: any = await body.json();
@@ -362,35 +363,33 @@ export class AirConditioner extends irdeviceBase {
362
363
  await this.pushChangeError(e);
363
364
  }
364
365
  } else {
365
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
366
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
367
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
368
- + ` Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
369
- this.updateHomeKitCharacteristics();
366
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
367
+ await this.debugLog(`Connection Type: ${this.device.connectionType}, disablePushDetails: ${this.disablePushDetail}`);
368
+ await this.updateHomeKitCharacteristics();
370
369
  }
371
370
  }
372
371
 
373
372
  async CurrentTemperatureGet(): Promise<CharacteristicValue> {
374
373
  if (this.meter?.context?.CurrentTemperature) {
375
374
  this.accessory.context.CurrentTemperature = this.meter.context.CurrentTemperature;
376
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
375
+ await this.debugLog(''
377
376
  + `Using CurrentTemperature from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
378
377
  }
379
378
 
380
379
  this.HeaterCooler.CurrentTemperature = this.accessory.context.CurrentTemperature || 24;
381
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
380
+ await this.debugLog(`Get CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
382
381
  return this.HeaterCooler.CurrentTemperature;
383
382
  }
384
383
 
385
384
  async CurrentRelativeHumidityGet(): Promise<CharacteristicValue> {
386
385
  if (this.meter?.context?.CurrentRelativeHumidity) {
387
386
  this.accessory.context.CurrentRelativeHumidity = this.meter.context.CurrentRelativeHumidity;
388
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} `
387
+ await this.debugLog(''
389
388
  + `Using CurrentRelativeHumidity from ${this.meter.context.deviceType} (${this.meter.context.deviceID})`);
390
389
  }
391
390
 
392
391
  this.HumiditySensor!.CurrentRelativeHumidity = this.accessory.context.CurrentRelativeHumidity || 0;
393
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get`
392
+ await this.debugLog('Get'
394
393
  + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
395
394
  return this.HumiditySensor!.CurrentRelativeHumidity as CharacteristicValue;
396
395
  }
@@ -401,7 +400,7 @@ export class AirConditioner extends irdeviceBase {
401
400
  } else {
402
401
  this.HeaterCooler.RotationSpeed = this.CurrentFanSpeed - 1;
403
402
  }
404
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
403
+ await this.debugLog(`Get RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
405
404
  return this.HeaterCooler.RotationSpeed;
406
405
  }
407
406
 
@@ -412,24 +411,23 @@ export class AirConditioner extends irdeviceBase {
412
411
  this.CurrentFanSpeed = Number(value) + 1;
413
412
  }
414
413
  this.HeaterCooler.RotationSpeed = value;
415
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
416
- + `Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
414
+ await this.debugLog(`Set RotationSpeed: ${this.HeaterCooler.RotationSpeed}, CurrentFanSpeed: ${this.CurrentFanSpeed}`);
417
415
  this.pushAirConditionerStatusChanges();
418
416
  }
419
417
 
420
418
  async ActiveSet(value: CharacteristicValue): Promise<void> {
421
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
419
+ await this.debugLog(`Set Active: ${value}`);
422
420
 
423
421
  this.HeaterCooler.Active = value;
424
422
  if (this.HeaterCooler.Active === this.hap.Characteristic.Active.ACTIVE) {
425
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
423
+ await this.debugLog(`pushAirConditionerOnChanges, Active: ${this.HeaterCooler.Active}`);
426
424
  if (this.disablePushOn) {
427
425
  this.pushAirConditionerStatusChanges();
428
426
  } else {
429
427
  this.pushAirConditionerOnChanges();
430
428
  }
431
429
  } else {
432
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
430
+ await this.debugLog(`pushAirConditionerOffChanges, Active: ${this.HeaterCooler.Active}`);
433
431
  this.pushAirConditionerOffChanges();
434
432
  }
435
433
  }
@@ -437,7 +435,7 @@ export class AirConditioner extends irdeviceBase {
437
435
  async TargetHeaterCoolerStateGet(): Promise<CharacteristicValue> {
438
436
  const targetState = this.HeaterCooler.TargetHeaterCoolerState || this.accessory.context.TargetHeaterCoolerState;
439
437
  this.HeaterCooler.TargetHeaterCoolerState = this.ValidValues.includes(targetState) ? targetState : this.ValidValues[0];
440
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
438
+ await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) TargetHeaterCoolerState:`
441
439
  + ` ${this.HeaterCooler.TargetHeaterCoolerState}, ValidValues: ${this.ValidValues}, hide_automode: ${this.hide_automode}`);
442
440
  return this.HeaterCooler.TargetHeaterCoolerState;
443
441
  }
@@ -450,7 +448,7 @@ export class AirConditioner extends irdeviceBase {
450
448
  } else if (value === this.hap.Characteristic.TargetHeaterCoolerState.COOL) {
451
449
  this.TargetHeaterCoolerStateCOOL();
452
450
  } else {
453
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Set TargetHeaterCoolerState: `
451
+ this.errorLog('Set TargetHeaterCoolerState: '
454
452
  + `${this.HeaterCooler.TargetHeaterCoolerState}, hide_automode: ${this.hide_automode} `);
455
453
  }
456
454
  this.pushAirConditionerStatusChanges();
@@ -459,31 +457,30 @@ export class AirConditioner extends irdeviceBase {
459
457
  async TargetHeaterCoolerStateAUTO(): Promise<void> {
460
458
  this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.AUTO;
461
459
  this.CurrentMode = 1;
462
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (AUTO)`
460
+ await this.debugLog('Set (AUTO)'
463
461
  + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
464
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
462
+ await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
465
463
  }
466
464
 
467
465
  async TargetHeaterCoolerStateCOOL(): Promise<void> {
468
466
  this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.COOL;
469
467
  this.CurrentMode = 2;
470
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (COOL)`
468
+ await this.debugLog('Set (COOL)'
471
469
  + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
472
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
470
+ await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
473
471
  }
474
472
 
475
473
  async TargetHeaterCoolerStateHEAT(): Promise<void> {
476
474
  this.HeaterCooler.TargetHeaterCoolerState = this.hap.Characteristic.TargetHeaterCoolerState.HEAT;
477
475
  this.CurrentMode = 5;
478
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set (HEAT)`
476
+ await this.debugLog('Set (HEAT)'
479
477
  + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
480
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Switchbot CurrentMode: ${this.CurrentMode}`);
478
+ await this.debugLog(`Switchbot CurrentMode: ${this.CurrentMode}`);
481
479
  }
482
480
 
483
481
  async CurrentHeaterCoolerStateGet(): Promise<CharacteristicValue> {
484
482
  await this.UpdateCurrentHeaterCoolerState();
485
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
486
- + ` Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
483
+ await this.debugLog(`Get (${this.getTargetHeaterCoolerStateName()}) CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
487
484
 
488
485
  return this.HeaterCooler.CurrentHeaterCoolerState;
489
486
  }
@@ -537,84 +534,82 @@ export class AirConditioner extends irdeviceBase {
537
534
  this.HumiditySensor!.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity || this.accessory.context.CurrentRelativeHumidity;
538
535
  }
539
536
  }
540
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
537
+ await this.debugLog(`Get ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
541
538
  return this.HeaterCooler.ThresholdTemperature;
542
539
  }
543
540
 
544
541
  async ThresholdTemperatureSet(value: CharacteristicValue): Promise<void> {
545
542
  this.HeaterCooler.ThresholdTemperature = value;
546
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
543
+ await this.debugLog(`Set ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature},`
547
544
  + ` ThresholdTemperatureCached: ${this.accessory.context.ThresholdTemperature}`);
548
545
  this.pushAirConditionerStatusChanges();
549
546
  }
550
547
 
551
548
  async updateHomeKitCharacteristics(): Promise<void> {
549
+ await this.debugLog('updateHomeKitCharacteristics');
552
550
  // Active
553
551
  if (this.HeaterCooler.Active === undefined) {
554
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.HeaterCooler.Active}`);
552
+ await this.debugLog(`Active: ${this.HeaterCooler.Active}`);
555
553
  } else {
556
554
  this.accessory.context.Active = this.HeaterCooler.Active;
557
555
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.Active, this.HeaterCooler.Active);
558
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.HeaterCooler.Active}`);
556
+ await this.debugLog(`updateCharacteristic Active: ${this.HeaterCooler.Active}`);
559
557
  }
560
558
  // RotationSpeed
561
559
  if (this.HeaterCooler.RotationSpeed === undefined) {
562
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
560
+ await this.debugLog(`RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
563
561
  } else {
564
562
  this.accessory.context.RotationSpeed = this.HeaterCooler.RotationSpeed;
565
563
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.HeaterCooler.RotationSpeed);
566
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
564
+ await this.debugLog('updateCharacteristic'
567
565
  + ` RotationSpeed: ${this.HeaterCooler.RotationSpeed}`);
568
566
  }
569
567
  // CurrentTemperature
570
568
  if (this.HeaterCooler.CurrentTemperature === undefined) {
571
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
569
+ await this.debugLog(`CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
572
570
  } else {
573
571
  this.accessory.context.CurrentTemperature = this.HeaterCooler.CurrentTemperature;
574
572
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.HeaterCooler.CurrentTemperature);
575
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
573
+ await this.debugLog('updateCharacteristic'
576
574
  + ` CurrentTemperature: ${this.HeaterCooler.CurrentTemperature}`);
577
575
  }
578
576
  // CurrentRelativeHumidity
579
577
  if (this.meter) {
580
578
  if (this.HumiditySensor!.CurrentRelativeHumidity === undefined) {
581
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
582
- + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
579
+ await this.debugLog(`CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
583
580
  } else {
584
581
  this.accessory.context.CurrentRelativeHumidity = this.HumiditySensor!.CurrentRelativeHumidity;
585
582
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentRelativeHumidity,
586
583
  this.HumiditySensor!.CurrentRelativeHumidity);
587
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
584
+ await this.debugLog('updateCharacteristic'
588
585
  + ` CurrentRelativeHumidity: ${this.HumiditySensor!.CurrentRelativeHumidity}`);
589
586
  }
590
587
  }
591
588
  // TargetHeaterCoolerState
592
589
  if (this.HeaterCooler.TargetHeaterCoolerState === undefined) {
593
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
590
+ await this.debugLog(`TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
594
591
  } else {
595
592
  this.accessory.context.TargetHeaterCoolerState = this.HeaterCooler.TargetHeaterCoolerState;
596
593
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.TargetHeaterCoolerState, this.HeaterCooler.TargetHeaterCoolerState);
597
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
594
+ await this.debugLog('updateCharacteristic'
598
595
  + ` TargetHeaterCoolerState: ${this.HeaterCooler.TargetHeaterCoolerState}`);
599
596
  }
600
597
  // CurrentHeaterCoolerState
601
598
  if (this.HeaterCooler.CurrentHeaterCoolerState === undefined) {
602
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
603
- + ` CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
599
+ await this.debugLog(`CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
604
600
  } else {
605
601
  this.accessory.context.CurrentHeaterCoolerState = this.HeaterCooler.CurrentHeaterCoolerState;
606
602
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.HeaterCooler.CurrentHeaterCoolerState);
607
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
608
- + ` updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
603
+ await this.debugLog(`updateCharacteristic CurrentHeaterCoolerState: ${this.HeaterCooler.CurrentHeaterCoolerState}`);
609
604
  }
610
605
  // ThresholdTemperature
611
606
  if (this.HeaterCooler.ThresholdTemperature === undefined) {
612
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
607
+ await this.debugLog(`ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
613
608
  } else {
614
609
  this.accessory.context.ThresholdTemperature = this.HeaterCooler.ThresholdTemperature;
615
610
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.HeatingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
616
611
  this.HeaterCooler.Service.updateCharacteristic(this.hap.Characteristic.CoolingThresholdTemperature, this.HeaterCooler.ThresholdTemperature);
617
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
612
+ await this.debugLog('updateCharacteristic'
618
613
  + ` ThresholdTemperature: ${this.HeaterCooler.ThresholdTemperature}`);
619
614
  }
620
615
  }
@@ -5,7 +5,8 @@
5
5
  import { irdeviceBase } from './irdevice.js';
6
6
 
7
7
  import type { SwitchBotPlatform } from '../platform.js';
8
- import type { irDevicesConfig, irdevice } from '../settings.js';
8
+ import type { irDevicesConfig } from '../settings.js';
9
+ import type { irdevice } from '../types/irdevicelist.js';
9
10
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
11
 
11
12
  /**
@@ -105,7 +106,7 @@ export class AirPurifier extends irdeviceBase {
105
106
  }
106
107
 
107
108
  async ActiveSet(value: CharacteristicValue): Promise<void> {
108
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Set Active: ${value}`);
109
+ await this.debugLog(`Set Active: ${value}`);
109
110
 
110
111
  this.AirPurifier.Active = value;
111
112
  if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE) {
@@ -152,7 +153,7 @@ export class AirPurifier extends irdeviceBase {
152
153
  * AirPurifier: "command" "highSpeed" "default" = fan speed to high
153
154
  */
154
155
  async pushAirPurifierOnChanges(): Promise<void> {
155
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOnChanges Active: ${this.AirPurifier.Active},`
156
+ await this.debugLog(`pushAirPurifierOnChanges Active: ${this.AirPurifier.Active},`
156
157
  + ` disablePushOn: ${this.disablePushOn}`);
157
158
  if (this.AirPurifier.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
158
159
  const commandType: string = await this.commandType();
@@ -167,7 +168,7 @@ export class AirPurifier extends irdeviceBase {
167
168
  }
168
169
 
169
170
  async pushAirPurifierOffChanges(): Promise<void> {
170
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierOffChanges Active: ${this.AirPurifier.Active},`
171
+ await this.debugLog(`pushAirPurifierOffChanges Active: ${this.AirPurifier.Active},`
171
172
  + ` disablePushOff: ${this.disablePushOff}`);
172
173
  if (this.AirPurifier.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOn) {
173
174
  const commandType: string = await this.commandType();
@@ -182,7 +183,7 @@ export class AirPurifier extends irdeviceBase {
182
183
  }
183
184
 
184
185
  async pushAirPurifierStatusChanges(): Promise<void> {
185
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active},`
186
+ await this.debugLog(`pushAirPurifierStatusChanges Active: ${this.AirPurifier.Active},`
186
187
  + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
187
188
  if (!this.Busy) {
188
189
  this.Busy = true;
@@ -195,7 +196,7 @@ export class AirPurifier extends irdeviceBase {
195
196
  }
196
197
 
197
198
  async pushAirPurifierDetailsChanges(): Promise<void> {
198
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active},`
199
+ await this.debugLog(`pushAirPurifierDetailsChanges Active: ${this.AirPurifier.Active},`
199
200
  + ` disablePushOff: ${this.disablePushOff}, disablePushOn: ${this.disablePushOn}`);
200
201
  this.CurrentAPTemp = this.TemperatureSensor!.CurrentTemperature ?? 24;
201
202
  this.CurrentAPMode = this.CurrentMode ?? 1;
@@ -220,9 +221,9 @@ export class AirPurifier extends irdeviceBase {
220
221
  }
221
222
 
222
223
  async pushChanges(bodyChange: any): Promise<void> {
223
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
224
+ await this.debugLog('pushChanges');
224
225
  if (this.device.connectionType === 'OpenAPI') {
225
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
226
+ this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
226
227
  try {
227
228
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
228
229
  const deviceStatus: any = await body.json();
@@ -239,45 +240,45 @@ export class AirPurifier extends irdeviceBase {
239
240
  await this.pushChangeError(e);
240
241
  }
241
242
  } else {
242
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
243
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
243
+ this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
244
244
  }
245
245
  }
246
246
 
247
247
  async updateHomeKitCharacteristics(): Promise<void> {
248
+ await this.debugLog('updateHomeKitCharacteristics');
248
249
  // Active
249
250
  if (this.AirPurifier.Active === undefined) {
250
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.AirPurifier.Active}`);
251
+ await this.debugLog(`Active: ${this.AirPurifier.Active}`);
251
252
  } else {
252
253
  this.accessory.context.Active = this.AirPurifier.Active;
253
254
  this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.Active, this.AirPurifier.Active);
254
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.AirPurifier.Active}`);
255
+ await this.debugLog(`updateCharacteristic Active: ${this.AirPurifier.Active}`);
255
256
  }
256
257
  // CurrentAirPurifierState
257
258
  if (this.AirPurifier.CurrentAirPurifierState === undefined) {
258
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
259
+ await this.debugLog(`CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
259
260
  } else {
260
261
  this.accessory.context.CurrentAirPurifierState = this.AirPurifier.CurrentAirPurifierState;
261
262
  this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentAirPurifierState, this.AirPurifier.CurrentAirPurifierState);
262
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
263
+ await this.debugLog('updateCharacteristic'
263
264
  + ` CurrentAirPurifierState: ${this.AirPurifier.CurrentAirPurifierState}`);
264
265
  }
265
266
  // CurrentHeaterCoolerState
266
267
  if (this.CurrentHeaterCoolerState === undefined) {
267
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
268
+ await this.debugLog(`CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
268
269
  } else {
269
270
  this.accessory.context.CurrentHeaterCoolerState = this.CurrentHeaterCoolerState;
270
271
  this.AirPurifier.Service.updateCharacteristic(this.hap.Characteristic.CurrentHeaterCoolerState, this.CurrentHeaterCoolerState);
271
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
272
+ await this.debugLog('updateCharacteristic'
272
273
  + ` CurrentHeaterCoolerState: ${this.CurrentHeaterCoolerState}`);
273
274
  }
274
275
  // CurrentTemperature
275
276
  if (this.TemperatureSensor.CurrentTemperature === undefined) {
276
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
277
+ await this.debugLog(`CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
277
278
  } else {
278
279
  this.accessory.context.CurrentTemperature = this.TemperatureSensor.CurrentTemperature;
279
280
  this.TemperatureSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentTemperature, this.TemperatureSensor.CurrentTemperature);
280
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic`
281
+ await this.debugLog('updateCharacteristic'
281
282
  + ` CurrentTemperature: ${this.TemperatureSensor.CurrentTemperature}`);
282
283
  }
283
284
  }
@@ -5,7 +5,8 @@
5
5
  import { irdeviceBase } from './irdevice.js';
6
6
 
7
7
  import type { SwitchBotPlatform } from '../platform.js';
8
- import type { irDevicesConfig, irdevice } from '../settings.js';
8
+ import type { irDevicesConfig } from '../settings.js';
9
+ import type { irdevice } from '../types/irdevicelist.js';
9
10
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
11
 
11
12
  /**
@@ -47,7 +48,7 @@ export class Camera extends irdeviceBase {
47
48
  }
48
49
 
49
50
  async OnSet(value: CharacteristicValue): Promise<void> {
50
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
51
+ await this.debugLog(`On: ${value}`);
51
52
 
52
53
  this.Switch.On = value;
53
54
  if (this.Switch.On) {
@@ -68,7 +69,7 @@ export class Camera extends irdeviceBase {
68
69
  * Camera - "command" "channelSub" "default" = previous channel
69
70
  */
70
71
  async pushOnChanges(): Promise<void> {
71
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.Switch.On},`
72
+ await this.debugLog(`pushOnChanges On: ${this.Switch.On},`
72
73
  + ` disablePushOn: ${this.disablePushOn}`);
73
74
  if (this.Switch.On && !this.disablePushOn) {
74
75
  const commandType: string = await this.commandType();
@@ -83,7 +84,7 @@ export class Camera extends irdeviceBase {
83
84
  }
84
85
 
85
86
  async pushOffChanges(): Promise<void> {
86
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.Switch.On},`
87
+ await this.debugLog(`pushOffChanges On: ${this.Switch.On},`
87
88
  + ` disablePushOff: ${this.disablePushOff}`);
88
89
  if (!this.Switch.On && !this.disablePushOff) {
89
90
  const commandType: string = await this.commandType();
@@ -98,9 +99,9 @@ export class Camera extends irdeviceBase {
98
99
  }
99
100
 
100
101
  async pushChanges(bodyChange: any): Promise<void> {
101
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
102
+ await this.debugLog('pushChanges');
102
103
  if (this.device.connectionType === 'OpenAPI') {
103
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
104
+ this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
104
105
  try {
105
106
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
106
107
  const deviceStatus: any = await body.json();
@@ -117,19 +118,19 @@ export class Camera extends irdeviceBase {
117
118
  await this.pushChangeError(e);
118
119
  }
119
120
  } else {
120
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
121
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
121
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
122
122
  }
123
123
  }
124
124
 
125
125
  async updateHomeKitCharacteristics(): Promise<void> {
126
+ await this.debugLog('updateHomeKitCharacteristics');
126
127
  // On
127
128
  if (this.Switch.On === undefined) {
128
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.Switch.On}`);
129
+ await this.debugLog(`On: ${this.Switch.On}`);
129
130
  } else {
130
131
  this.accessory.context.On = this.Switch.On;
131
132
  this.Switch.Service.updateCharacteristic(this.hap.Characteristic.On, this.Switch.On);
132
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.Switch.On}`);
133
+ await this.debugLog(`updateCharacteristic On: ${this.Switch.On}`);
133
134
  }
134
135
  }
135
136
 
@@ -5,7 +5,8 @@
5
5
  import { irdeviceBase } from './irdevice.js';
6
6
 
7
7
  import type { SwitchBotPlatform } from '../platform.js';
8
- import type { irDevicesConfig, irdevice } from '../settings.js';
8
+ import type { irDevicesConfig } from '../settings.js';
9
+ import type { irdevice } from '../types/irdevicelist.js';
9
10
  import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
10
11
 
11
12
  /**
@@ -67,9 +68,9 @@ export class IRFan extends irdeviceBase {
67
68
  } else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.RotationSpeed) && !device.irfan?.swing_mode) {
68
69
  const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.RotationSpeed);
69
70
  this.Fan.Service.removeCharacteristic(characteristic);
70
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Rotation Speed Characteristic was removed.`);
71
+ this.debugLog('Rotation Speed Characteristic was removed.');
71
72
  } else {
72
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed Characteristic was not removed/added, `
73
+ this.debugLog('RotationSpeed Characteristic was not removed/added, '
73
74
  + `Clear Cache on ${this.accessory.displayName} to remove Chracteristic`);
74
75
  }
75
76
 
@@ -84,15 +85,15 @@ export class IRFan extends irdeviceBase {
84
85
  } else if (this.Fan.Service.testCharacteristic(this.hap.Characteristic.SwingMode) && !device.irfan?.swing_mode) {
85
86
  const characteristic = this.Fan.Service.getCharacteristic(this.hap.Characteristic.SwingMode);
86
87
  this.Fan.Service.removeCharacteristic(characteristic);
87
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Swing Mode Characteristic was removed.`);
88
+ this.debugLog('Swing Mode Characteristic was removed.');
88
89
  } else {
89
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Swing Mode Characteristic was not removed/added, `
90
+ this.debugLog('Swing Mode Characteristic was not removed/added, '
90
91
  + `Clear Cache on ${this.accessory.displayName} To Remove Chracteristic`);
91
92
  }
92
93
  }
93
94
 
94
95
  async SwingModeSet(value: CharacteristicValue): Promise<void> {
95
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} SwingMode: ${value}`);
96
+ await this.debugLog(`SwingMode: ${value}`);
96
97
  if (value > this.Fan.SwingMode) {
97
98
  this.Fan.SwingMode = 1;
98
99
  await this.pushFanOnChanges();
@@ -107,7 +108,7 @@ export class IRFan extends irdeviceBase {
107
108
  }
108
109
 
109
110
  async RotationSpeedSet(value: CharacteristicValue): Promise<void> {
110
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${value}`);
111
+ await this.debugLog(`RotationSpeed: ${value}`);
111
112
  if (value > this.Fan.RotationSpeed) {
112
113
  this.Fan.RotationSpeed = 1;
113
114
  this.pushFanSpeedUpChanges();
@@ -121,7 +122,7 @@ export class IRFan extends irdeviceBase {
121
122
  }
122
123
 
123
124
  async ActiveSet(value: CharacteristicValue): Promise<void> {
124
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${value}`);
125
+ await this.debugLog(`Active: ${value}`);
125
126
 
126
127
  this.Fan.Active = value;
127
128
  if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE) {
@@ -141,7 +142,7 @@ export class IRFan extends irdeviceBase {
141
142
  * Fan - "command" "highSpeed" "default" = fan speed to high
142
143
  */
143
144
  async pushFanOnChanges(): Promise<void> {
144
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushFanOnChanges Active: ${this.Fan.Active},`
145
+ await this.debugLog(`pushFanOnChanges Active: ${this.Fan.Active},`
145
146
  + ` disablePushOn: ${this.disablePushOn}`);
146
147
  if (this.Fan.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
147
148
  const commandType: string = await this.commandType();
@@ -156,7 +157,7 @@ export class IRFan extends irdeviceBase {
156
157
  }
157
158
 
158
159
  async pushFanOffChanges(): Promise<void> {
159
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLightOffChanges Active: ${this.Fan.Active},`
160
+ await this.debugLog(`pushLightOffChanges Active: ${this.Fan.Active},`
160
161
  + ` disablePushOff: ${this.disablePushOff}`);
161
162
  if (this.Fan.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
162
163
  const commandType: string = await this.commandType();
@@ -198,9 +199,9 @@ export class IRFan extends irdeviceBase {
198
199
  }
199
200
 
200
201
  async pushChanges(bodyChange: any): Promise<void> {
201
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushChanges`);
202
+ await this.debugLog('pushChanges');
202
203
  if (this.device.connectionType === 'OpenAPI') {
203
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
204
+ this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
204
205
  try {
205
206
  const { body, statusCode } = await this.pushChangeRequest(bodyChange);
206
207
  const deviceStatus: any = await body.json();
@@ -217,32 +218,32 @@ export class IRFan extends irdeviceBase {
217
218
  await this.pushChangeError(e);
218
219
  }
219
220
  } else {
220
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
221
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
221
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
222
222
  }
223
223
  }
224
224
 
225
225
  async updateHomeKitCharacteristics(): Promise<void> {
226
+ await this.debugLog('updateHomeKitCharacteristics');
226
227
  if (this.Fan.Active === undefined) {
227
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Fan.Active}`);
228
+ await this.debugLog(`Active: ${this.Fan.Active}`);
228
229
  } else {
229
230
  this.accessory.context.Active = this.Fan.Active;
230
231
  this.Fan.Service.updateCharacteristic(this.hap.Characteristic.Active, this.Fan.Active);
231
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Fan.Active}`);
232
+ await this.debugLog(`updateCharacteristic Active: ${this.Fan.Active}`);
232
233
  }
233
234
  if (this.Fan.SwingMode === undefined) {
234
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} SwingMode: ${this.Fan.SwingMode}`);
235
+ await this.debugLog(`SwingMode: ${this.Fan.SwingMode}`);
235
236
  } else {
236
237
  this.accessory.context.SwingMode = this.Fan.SwingMode;
237
238
  this.Fan.Service.updateCharacteristic(this.hap.Characteristic.SwingMode, this.Fan.SwingMode);
238
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
239
+ await this.debugLog(`updateCharacteristic SwingMode: ${this.Fan.SwingMode}`);
239
240
  }
240
241
  if (this.Fan.RotationSpeed === undefined) {
241
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} RotationSpeed: ${this.Fan.RotationSpeed}`);
242
+ await this.debugLog(`RotationSpeed: ${this.Fan.RotationSpeed}`);
242
243
  } else {
243
244
  this.accessory.context.RotationSpeed = this.Fan.RotationSpeed;
244
245
  this.Fan.Service.updateCharacteristic(this.hap.Characteristic.RotationSpeed, this.Fan.RotationSpeed);
245
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
246
+ await this.debugLog(`updateCharacteristic RotationSpeed: ${this.Fan.RotationSpeed}`);
246
247
  }
247
248
  }
248
249