@switchbot/homebridge-switchbot 2.7.1 → 2.8.0-beta.1

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 (119) hide show
  1. package/.github/npm-version-script.js +81 -0
  2. package/.prettierrc +1 -1
  3. package/.vscode/settings.json +1 -1
  4. package/CHANGELOG.md +10 -0
  5. package/config.schema.json +8 -0
  6. package/dist/device/blindtilt.d.ts.map +1 -1
  7. package/dist/device/blindtilt.js +49 -59
  8. package/dist/device/blindtilt.js.map +1 -1
  9. package/dist/device/bot.d.ts.map +1 -1
  10. package/dist/device/bot.js +44 -50
  11. package/dist/device/bot.js.map +1 -1
  12. package/dist/device/ceilinglight.d.ts.map +1 -1
  13. package/dist/device/ceilinglight.js +60 -63
  14. package/dist/device/ceilinglight.js.map +1 -1
  15. package/dist/device/colorbulb.d.ts.map +1 -1
  16. package/dist/device/colorbulb.js +68 -70
  17. package/dist/device/colorbulb.js.map +1 -1
  18. package/dist/device/contact.d.ts.map +1 -1
  19. package/dist/device/contact.js +22 -25
  20. package/dist/device/contact.js.map +1 -1
  21. package/dist/device/curtain.d.ts.map +1 -1
  22. package/dist/device/curtain.js +50 -58
  23. package/dist/device/curtain.js.map +1 -1
  24. package/dist/device/hub.d.ts +6 -0
  25. package/dist/device/hub.d.ts.map +1 -1
  26. package/dist/device/hub.js +168 -26
  27. package/dist/device/hub.js.map +1 -1
  28. package/dist/device/humidifier.d.ts.map +1 -1
  29. package/dist/device/humidifier.js +49 -56
  30. package/dist/device/humidifier.js.map +1 -1
  31. package/dist/device/iosensor.d.ts.map +1 -1
  32. package/dist/device/iosensor.js +18 -20
  33. package/dist/device/iosensor.js.map +1 -1
  34. package/dist/device/lightstrip.d.ts.map +1 -1
  35. package/dist/device/lightstrip.js +59 -61
  36. package/dist/device/lightstrip.js.map +1 -1
  37. package/dist/device/lock.d.ts.map +1 -1
  38. package/dist/device/lock.js +40 -41
  39. package/dist/device/lock.js.map +1 -1
  40. package/dist/device/meter.d.ts +3 -3
  41. package/dist/device/meter.d.ts.map +1 -1
  42. package/dist/device/meter.js +65 -68
  43. package/dist/device/meter.js.map +1 -1
  44. package/dist/device/meterplus.d.ts.map +1 -1
  45. package/dist/device/meterplus.js +18 -20
  46. package/dist/device/meterplus.js.map +1 -1
  47. package/dist/device/motion.d.ts.map +1 -1
  48. package/dist/device/motion.js +20 -23
  49. package/dist/device/motion.js.map +1 -1
  50. package/dist/device/plug.d.ts.map +1 -1
  51. package/dist/device/plug.js +30 -33
  52. package/dist/device/plug.js.map +1 -1
  53. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  54. package/dist/device/robotvacuumcleaner.js +48 -51
  55. package/dist/device/robotvacuumcleaner.js.map +1 -1
  56. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  57. package/dist/irdevice/airconditioner.js +57 -61
  58. package/dist/irdevice/airconditioner.js.map +1 -1
  59. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  60. package/dist/irdevice/airpurifier.js +29 -31
  61. package/dist/irdevice/airpurifier.js.map +1 -1
  62. package/dist/irdevice/camera.d.ts.map +1 -1
  63. package/dist/irdevice/camera.js +17 -20
  64. package/dist/irdevice/camera.js.map +1 -1
  65. package/dist/irdevice/fan.d.ts.map +1 -1
  66. package/dist/irdevice/fan.js +27 -29
  67. package/dist/irdevice/fan.js.map +1 -1
  68. package/dist/irdevice/light.d.ts.map +1 -1
  69. package/dist/irdevice/light.js +23 -26
  70. package/dist/irdevice/light.js.map +1 -1
  71. package/dist/irdevice/other.d.ts.map +1 -1
  72. package/dist/irdevice/other.js +19 -20
  73. package/dist/irdevice/other.js.map +1 -1
  74. package/dist/irdevice/tv.d.ts.map +1 -1
  75. package/dist/irdevice/tv.js +44 -47
  76. package/dist/irdevice/tv.js.map +1 -1
  77. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  78. package/dist/irdevice/vacuumcleaner.js +17 -20
  79. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  80. package/dist/irdevice/waterheater.d.ts.map +1 -1
  81. package/dist/irdevice/waterheater.js +19 -20
  82. package/dist/irdevice/waterheater.js.map +1 -1
  83. package/dist/platform.d.ts.map +1 -1
  84. package/dist/platform.js +44 -43
  85. package/dist/platform.js.map +1 -1
  86. package/dist/settings.d.ts +1 -0
  87. package/dist/settings.d.ts.map +1 -1
  88. package/dist/settings.js.map +1 -1
  89. package/dist/utils.js +1 -1
  90. package/dist/utils.js.map +1 -1
  91. package/package.json +1 -1
  92. package/src/device/blindtilt.ts +106 -72
  93. package/src/device/bot.ts +94 -58
  94. package/src/device/ceilinglight.ts +102 -68
  95. package/src/device/colorbulb.ts +134 -82
  96. package/src/device/contact.ts +54 -33
  97. package/src/device/curtain.ts +130 -101
  98. package/src/device/hub.ts +198 -35
  99. package/src/device/humidifier.ts +128 -80
  100. package/src/device/iosensor.ts +43 -27
  101. package/src/device/lightstrip.ts +108 -67
  102. package/src/device/lock.ts +73 -45
  103. package/src/device/meter.ts +94 -75
  104. package/src/device/meterplus.ts +43 -27
  105. package/src/device/motion.ts +50 -32
  106. package/src/device/plug.ts +62 -39
  107. package/src/device/robotvacuumcleaner.ts +78 -54
  108. package/src/irdevice/airconditioner.ts +111 -83
  109. package/src/irdevice/airpurifier.ts +55 -34
  110. package/src/irdevice/camera.ts +35 -23
  111. package/src/irdevice/fan.ts +47 -33
  112. package/src/irdevice/light.ts +43 -29
  113. package/src/irdevice/other.ts +39 -23
  114. package/src/irdevice/tv.ts +65 -51
  115. package/src/irdevice/vacuumcleaner.ts +35 -23
  116. package/src/irdevice/waterheater.ts +43 -27
  117. package/src/platform.ts +85 -55
  118. package/src/settings.ts +41 -40
  119. package/src/utils.ts +1 -1
@@ -26,7 +26,11 @@ export class TV {
26
26
  disablePushDetail?: boolean;
27
27
  deviceLogging!: string;
28
28
 
29
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
29
+ constructor(
30
+ private readonly platform: SwitchBotPlatform,
31
+ private accessory: PlatformAccessory,
32
+ public device: irdevice & irDevicesConfig,
33
+ ) {
30
34
  // default placeholders
31
35
  this.logs(device);
32
36
  this.config(device);
@@ -222,30 +226,32 @@ export class TV {
222
226
  * TV "command" "channelSub" "default" previous channel
223
227
  */
224
228
  async pushTvOnChanges(): Promise<void> {
225
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges Active: ${this.Active},`
226
- + ` disablePushOn: ${this.disablePushOn}`);
229
+ this.debugLog(
230
+ `${this.device.remoteType}: ${this.accessory.displayName} pushTvOnChanges Active: ${this.Active},` + ` disablePushOn: ${this.disablePushOn}`,
231
+ );
227
232
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
228
233
  const commandType: string = await this.commandType();
229
234
  const command: string = await this.commandOn();
230
235
  const bodyChange = JSON.stringify({
231
- 'command': command,
232
- 'parameter': 'default',
233
- 'commandType': commandType,
236
+ command: command,
237
+ parameter: 'default',
238
+ commandType: commandType,
234
239
  });
235
240
  await this.pushTVChanges(bodyChange);
236
241
  }
237
242
  }
238
243
 
239
244
  async pushTvOffChanges(): Promise<void> {
240
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges Active: ${this.Active},`
241
- + ` disablePushOff: ${this.disablePushOff}`);
245
+ this.debugLog(
246
+ `${this.device.remoteType}: ${this.accessory.displayName} pushTvOffChanges Active: ${this.Active},` + ` disablePushOff: ${this.disablePushOff}`,
247
+ );
242
248
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
243
249
  const commandType: string = await this.commandType();
244
250
  const command: string = await this.commandOff();
245
251
  const bodyChange = JSON.stringify({
246
- 'command': command,
247
- 'parameter': 'default',
248
- 'commandType': commandType,
252
+ command: command,
253
+ parameter: 'default',
254
+ commandType: commandType,
249
255
  });
250
256
  await this.pushTVChanges(bodyChange);
251
257
  }
@@ -255,9 +261,9 @@ export class TV {
255
261
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
256
262
  if (!this.disablePushDetail) {
257
263
  const bodyChange = JSON.stringify({
258
- 'command': 'Ok',
259
- 'parameter': 'default',
260
- 'commandType': 'command',
264
+ command: 'Ok',
265
+ parameter: 'default',
266
+ commandType: 'command',
261
267
  });
262
268
  await this.pushTVChanges(bodyChange);
263
269
  }
@@ -267,9 +273,9 @@ export class TV {
267
273
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
268
274
  if (!this.disablePushDetail) {
269
275
  const bodyChange = JSON.stringify({
270
- 'command': 'Back',
271
- 'parameter': 'default',
272
- 'commandType': 'command',
276
+ command: 'Back',
277
+ parameter: 'default',
278
+ commandType: 'command',
273
279
  });
274
280
  await this.pushTVChanges(bodyChange);
275
281
  }
@@ -279,9 +285,9 @@ export class TV {
279
285
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
280
286
  if (!this.disablePushDetail) {
281
287
  const bodyChange = JSON.stringify({
282
- 'command': 'Menu',
283
- 'parameter': 'default',
284
- 'commandType': 'command',
288
+ command: 'Menu',
289
+ parameter: 'default',
290
+ commandType: 'command',
285
291
  });
286
292
  await this.pushTVChanges(bodyChange);
287
293
  }
@@ -291,9 +297,9 @@ export class TV {
291
297
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
292
298
  if (!this.disablePushDetail) {
293
299
  const bodyChange = JSON.stringify({
294
- 'command': 'Up',
295
- 'parameter': 'default',
296
- 'commandType': 'command',
300
+ command: 'Up',
301
+ parameter: 'default',
302
+ commandType: 'command',
297
303
  });
298
304
  await this.pushTVChanges(bodyChange);
299
305
  }
@@ -303,9 +309,9 @@ export class TV {
303
309
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
304
310
  if (!this.disablePushDetail) {
305
311
  const bodyChange = JSON.stringify({
306
- 'command': 'Down',
307
- 'parameter': 'default',
308
- 'commandType': 'command',
312
+ command: 'Down',
313
+ parameter: 'default',
314
+ commandType: 'command',
309
315
  });
310
316
  await this.pushTVChanges(bodyChange);
311
317
  }
@@ -315,9 +321,9 @@ export class TV {
315
321
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
316
322
  if (!this.disablePushDetail) {
317
323
  const bodyChange = JSON.stringify({
318
- 'command': 'Right',
319
- 'parameter': 'default',
320
- 'commandType': 'command',
324
+ command: 'Right',
325
+ parameter: 'default',
326
+ commandType: 'command',
321
327
  });
322
328
  await this.pushTVChanges(bodyChange);
323
329
  }
@@ -327,9 +333,9 @@ export class TV {
327
333
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
328
334
  if (!this.disablePushDetail) {
329
335
  const bodyChange = JSON.stringify({
330
- 'command': 'Left',
331
- 'parameter': 'default',
332
- 'commandType': 'command',
336
+ command: 'Left',
337
+ parameter: 'default',
338
+ commandType: 'command',
333
339
  });
334
340
  await this.pushTVChanges(bodyChange);
335
341
  }
@@ -339,9 +345,9 @@ export class TV {
339
345
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
340
346
  if (!this.disablePushDetail) {
341
347
  const bodyChange = JSON.stringify({
342
- 'command': 'volumeAdd',
343
- 'parameter': 'default',
344
- 'commandType': 'command',
348
+ command: 'volumeAdd',
349
+ parameter: 'default',
350
+ commandType: 'command',
345
351
  });
346
352
  await this.pushTVChanges(bodyChange);
347
353
  }
@@ -351,9 +357,9 @@ export class TV {
351
357
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
352
358
  if (!this.disablePushDetail) {
353
359
  const bodyChange = JSON.stringify({
354
- 'command': 'volumeSub',
355
- 'parameter': 'default',
356
- 'commandType': 'command',
360
+ command: 'volumeSub',
361
+ parameter: 'default',
362
+ commandType: 'command',
357
363
  });
358
364
  await this.pushTVChanges(bodyChange);
359
365
  }
@@ -376,13 +382,16 @@ export class TV {
376
382
  this.updateHomeKitCharacteristics();
377
383
  } catch (e: any) {
378
384
  this.apiError(e);
379
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushTVChanges with ${this.device.connectionType}`
380
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
385
+ this.errorLog(
386
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushTVChanges with ${this.device.connectionType}` +
387
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
381
388
  );
382
389
  }
383
390
  } else {
384
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
385
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
391
+ this.warnLog(
392
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
393
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
394
+ );
386
395
  }
387
396
  }
388
397
 
@@ -403,7 +412,7 @@ export class TV {
403
412
  }
404
413
  }
405
414
 
406
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
415
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
407
416
  if (device.disablePushOn === undefined) {
408
417
  this.disablePushOn = false;
409
418
  } else {
@@ -411,7 +420,7 @@ export class TV {
411
420
  }
412
421
  }
413
422
 
414
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
423
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
415
424
  if (device.disablePushOff === undefined) {
416
425
  this.disablePushOff = false;
417
426
  } else {
@@ -419,7 +428,7 @@ export class TV {
419
428
  }
420
429
  }
421
430
 
422
- async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
431
+ async disablePushDetailChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
423
432
  if (device.disablePushDetail === undefined) {
424
433
  this.disablePushDetail = false;
425
434
  } else {
@@ -472,8 +481,10 @@ export class TV {
472
481
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
473
482
  break;
474
483
  case 171:
475
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
476
- + `Hub: ${this.device.hubDeviceId}`);
484
+ this.errorLog(
485
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
486
+ `Hub: ${this.device.hubDeviceId}`,
487
+ );
477
488
  break;
478
489
  case 190:
479
490
  this.errorLog(
@@ -488,8 +499,10 @@ export class TV {
488
499
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
489
500
  break;
490
501
  default:
491
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
492
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
502
+ this.infoLog(
503
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
504
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
505
+ );
493
506
  }
494
507
  }
495
508
 
@@ -500,8 +513,9 @@ export class TV {
500
513
 
501
514
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
502
515
  let FirmwareRevision: string;
503
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
504
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
516
+ this.debugLog(
517
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
518
+ );
505
519
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
506
520
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
507
521
  if (accessory.context.FirmwareRevision) {
@@ -20,7 +20,11 @@ export class VacuumCleaner {
20
20
  disablePushOff?: boolean;
21
21
  deviceLogging!: string;
22
22
 
23
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
23
+ constructor(
24
+ private readonly platform: SwitchBotPlatform,
25
+ private accessory: PlatformAccessory,
26
+ public device: irdevice & irDevicesConfig,
27
+ ) {
24
28
  // default placeholders
25
29
  this.logs(device);
26
30
  this.config(device);
@@ -76,30 +80,30 @@ export class VacuumCleaner {
76
80
  * Vacuum Cleaner "command" "turnOn" "default" set to ON state
77
81
  */
78
82
  async pushOnChanges(): Promise<void> {
79
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},`
80
- + ` disablePushOn: ${this.disablePushOn}`);
83
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOnChanges On: ${this.On},` + ` disablePushOn: ${this.disablePushOn}`);
81
84
  if (this.On && !this.disablePushOn) {
82
85
  const commandType: string = await this.commandType();
83
86
  const command: string = await this.commandOn();
84
87
  const bodyChange = JSON.stringify({
85
- 'command': command,
86
- 'parameter': 'default',
87
- 'commandType': commandType,
88
+ command: command,
89
+ parameter: 'default',
90
+ commandType: commandType,
88
91
  });
89
92
  await this.pushChanges(bodyChange);
90
93
  }
91
94
  }
92
95
 
93
96
  async pushOffChanges(): Promise<void> {
94
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},`
95
- + ` disablePushOff: ${this.disablePushOff}`);
97
+ this.debugLog(
98
+ `${this.device.remoteType}: ${this.accessory.displayName} pushOffChanges On: ${this.On},` + ` disablePushOff: ${this.disablePushOff}`,
99
+ );
96
100
  if (!this.On && !this.disablePushOff) {
97
101
  const commandType: string = await this.commandType();
98
102
  const command: string = await this.commandOff();
99
103
  const bodyChange = JSON.stringify({
100
- 'command': command,
101
- 'parameter': 'default',
102
- 'commandType': commandType,
104
+ command: command,
105
+ parameter: 'default',
106
+ commandType: commandType,
103
107
  });
104
108
  await this.pushChanges(bodyChange);
105
109
  }
@@ -122,13 +126,16 @@ export class VacuumCleaner {
122
126
  this.updateHomeKitCharacteristics();
123
127
  } catch (e: any) {
124
128
  this.apiError(e);
125
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
126
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
129
+ this.errorLog(
130
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
131
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
127
132
  );
128
133
  }
129
134
  } else {
130
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
131
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
135
+ this.warnLog(
136
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
137
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
138
+ );
132
139
  }
133
140
  }
134
141
 
@@ -142,7 +149,7 @@ export class VacuumCleaner {
142
149
  }
143
150
  }
144
151
 
145
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
152
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
146
153
  if (device.disablePushOn === undefined) {
147
154
  this.disablePushOn = false;
148
155
  } else {
@@ -150,7 +157,7 @@ export class VacuumCleaner {
150
157
  }
151
158
  }
152
159
 
153
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
160
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
154
161
  if (device.disablePushOff === undefined) {
155
162
  this.disablePushOff = false;
156
163
  } else {
@@ -203,8 +210,10 @@ export class VacuumCleaner {
203
210
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
204
211
  break;
205
212
  case 171:
206
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
207
- + `Hub: ${this.device.hubDeviceId}`);
213
+ this.errorLog(
214
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
215
+ `Hub: ${this.device.hubDeviceId}`,
216
+ );
208
217
  break;
209
218
  case 190:
210
219
  this.errorLog(
@@ -219,8 +228,10 @@ export class VacuumCleaner {
219
228
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
220
229
  break;
221
230
  default:
222
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
223
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
231
+ this.infoLog(
232
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
233
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
234
+ );
224
235
  }
225
236
  }
226
237
 
@@ -230,8 +241,9 @@ export class VacuumCleaner {
230
241
 
231
242
  FirmwareRevision(accessory: PlatformAccessory, device: irdevice & irDevicesConfig): string {
232
243
  let FirmwareRevision: string;
233
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
234
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
244
+ this.debugLog(
245
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
246
+ );
235
247
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
236
248
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
237
249
  if (accessory.context.FirmwareRevision) {
@@ -20,7 +20,11 @@ export class WaterHeater {
20
20
  disablePushOff?: boolean;
21
21
  deviceLogging!: string;
22
22
 
23
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: irdevice & irDevicesConfig) {
23
+ constructor(
24
+ private readonly platform: SwitchBotPlatform,
25
+ private accessory: PlatformAccessory,
26
+ public device: irdevice & irDevicesConfig,
27
+ ) {
24
28
  // default placeholders
25
29
  this.logs({ device });
26
30
  this.config({ device });
@@ -81,30 +85,34 @@ export class WaterHeater {
81
85
  * WaterHeater "command" "turnOn" "default" set to ON state
82
86
  */
83
87
  async pushWaterHeaterOnChanges(): Promise<void> {
84
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOnChanges Active: ${this.Active},`
85
- + ` disablePushOn: ${this.disablePushOn}`);
88
+ this.debugLog(
89
+ `${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOnChanges Active: ${this.Active},` +
90
+ ` disablePushOn: ${this.disablePushOn}`,
91
+ );
86
92
  if (this.Active === this.platform.Characteristic.Active.ACTIVE && !this.disablePushOn) {
87
93
  const commandType: string = await this.commandType();
88
94
  const command: string = await this.commandOn();
89
95
  const bodyChange = JSON.stringify({
90
- 'command': command,
91
- 'parameter': 'default',
92
- 'commandType': commandType,
96
+ command: command,
97
+ parameter: 'default',
98
+ commandType: commandType,
93
99
  });
94
100
  await this.pushChanges(bodyChange);
95
101
  }
96
102
  }
97
103
 
98
104
  async pushWaterHeaterOffChanges(): Promise<void> {
99
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOffChanges Active: ${this.Active},`
100
- + ` disablePushOff: ${this.disablePushOff}`);
105
+ this.debugLog(
106
+ `${this.device.remoteType}: ${this.accessory.displayName} pushWaterHeaterOffChanges Active: ${this.Active},` +
107
+ ` disablePushOff: ${this.disablePushOff}`,
108
+ );
101
109
  if (this.Active === this.platform.Characteristic.Active.INACTIVE && !this.disablePushOff) {
102
110
  const commandType: string = await this.commandType();
103
111
  const command: string = await this.commandOff();
104
112
  const bodyChange = JSON.stringify({
105
- 'command': command,
106
- 'parameter': 'default',
107
- 'commandType': commandType,
113
+ command: command,
114
+ parameter: 'default',
115
+ commandType: commandType,
108
116
  });
109
117
  await this.pushChanges(bodyChange);
110
118
  }
@@ -127,13 +135,16 @@ export class WaterHeater {
127
135
  this.updateHomeKitCharacteristics();
128
136
  } catch (e: any) {
129
137
  this.apiError(e);
130
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}`
131
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
138
+ this.errorLog(
139
+ `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType}` +
140
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
132
141
  );
133
142
  }
134
143
  } else {
135
- this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName}`
136
- + ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
144
+ this.warnLog(
145
+ `${this.device.remoteType}: ${this.accessory.displayName}` +
146
+ ` Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`,
147
+ );
137
148
  }
138
149
  }
139
150
 
@@ -147,7 +158,7 @@ export class WaterHeater {
147
158
  }
148
159
  }
149
160
 
150
- async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
161
+ async disablePushOnChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
151
162
  if (device.disablePushOn === undefined) {
152
163
  this.disablePushOn = false;
153
164
  } else {
@@ -155,7 +166,7 @@ export class WaterHeater {
155
166
  }
156
167
  }
157
168
 
158
- async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
169
+ async disablePushOffChanges({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
159
170
  if (device.disablePushOff === undefined) {
160
171
  this.disablePushOff = false;
161
172
  } else {
@@ -208,8 +219,10 @@ export class WaterHeater {
208
219
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline, statusCode: ${statusCode}`);
209
220
  break;
210
221
  case 171:
211
- this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
212
- + `Hub: ${this.device.hubDeviceId}`);
222
+ this.errorLog(
223
+ `${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
224
+ `Hub: ${this.device.hubDeviceId}`,
225
+ );
213
226
  break;
214
227
  case 190:
215
228
  this.errorLog(
@@ -224,19 +237,22 @@ export class WaterHeater {
224
237
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
225
238
  break;
226
239
  default:
227
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: `
228
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
240
+ this.infoLog(
241
+ `${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode: ` +
242
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
243
+ );
229
244
  }
230
245
  }
231
246
 
232
- async apiError({ e }: { e: any; }): Promise<void> {
247
+ async apiError({ e }: { e: any }): Promise<void> {
233
248
  this.valveService.updateCharacteristic(this.platform.Characteristic.Active, e);
234
249
  }
235
250
 
236
- FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig; }): string {
251
+ FirmwareRevision({ accessory, device }: { accessory: PlatformAccessory; device: irdevice & irDevicesConfig }): string {
237
252
  let FirmwareRevision: string;
238
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName}`
239
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
253
+ this.debugLog(
254
+ `${this.device.remoteType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
255
+ );
240
256
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
241
257
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
242
258
  if (accessory.context.FirmwareRevision) {
@@ -257,7 +273,7 @@ export class WaterHeater {
257
273
  }
258
274
  }
259
275
 
260
- async config({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
276
+ async config({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
261
277
  let config = {};
262
278
  if (device.irwh) {
263
279
  config = device.irwh;
@@ -291,7 +307,7 @@ export class WaterHeater {
291
307
  }
292
308
  }
293
309
 
294
- async logs({ device }: { device: irdevice & irDevicesConfig; }): Promise<void> {
310
+ async logs({ device }: { device: irdevice & irDevicesConfig }): Promise<void> {
295
311
  if (this.platform.debugMode) {
296
312
  this.deviceLogging = this.accessory.context.logging = 'debugMode';
297
313
  this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);