@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
@@ -41,10 +41,14 @@ export class Plug {
41
41
  doPlugUpdate!: Subject<void>;
42
42
 
43
43
  // Connection
44
- private readonly BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI');
45
- private readonly OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI');
46
-
47
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
44
+ private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
45
+ private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
46
+
47
+ constructor(
48
+ private readonly platform: SwitchBotPlatform,
49
+ private accessory: PlatformAccessory,
50
+ public device: device & devicesConfig,
51
+ ) {
48
52
  // default placeholders
49
53
  this.logs(device);
50
54
  this.scan(device);
@@ -114,8 +118,10 @@ export class Plug {
114
118
  await this.pushChanges();
115
119
  } catch (e: any) {
116
120
  this.apiError(e);
117
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
118
- + ` Error Message: ${JSON.stringify(e.message)}`);
121
+ this.errorLog(
122
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
123
+ ` Error Message: ${JSON.stringify(e.message)}`,
124
+ );
119
125
  }
120
126
  this.plugUpdateInProgress = false;
121
127
  });
@@ -133,8 +139,9 @@ export class Plug {
133
139
  await this.openAPIparseStatus();
134
140
  } else {
135
141
  await this.offlineOff();
136
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
137
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
142
+ this.debugWarnLog(
143
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
144
+ );
138
145
  }
139
146
  }
140
147
 
@@ -175,8 +182,10 @@ export class Plug {
175
182
  await this.openAPIRefreshStatus();
176
183
  } else {
177
184
  await this.offlineOff();
178
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
179
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
185
+ this.debugWarnLog(
186
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
187
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
188
+ );
180
189
  }
181
190
  }
182
191
 
@@ -201,8 +210,10 @@ export class Plug {
201
210
  // Set an event hander
202
211
  switchbot.onadvertisement = async (ad: any) => {
203
212
  this.address = ad.address;
204
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
205
- + ` BLE Address Found: ${this.address}`);
213
+ this.debugLog(
214
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
215
+ ` BLE Address Found: ${this.address}`,
216
+ );
206
217
  this.serviceData = ad.serviceData;
207
218
  this.state = ad.serviceData.state;
208
219
  this.delay = ad.serviceData.delay;
@@ -236,8 +247,10 @@ export class Plug {
236
247
  })
237
248
  .catch(async (e: any) => {
238
249
  this.apiError(e);
239
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
240
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
250
+ this.errorLog(
251
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
252
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
253
+ );
241
254
  await this.BLERefreshConnection(switchbot);
242
255
  });
243
256
  } else {
@@ -255,17 +268,16 @@ export class Plug {
255
268
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
256
269
  this.statusCode(statusCode);
257
270
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
258
- this.debugLog(
259
- `${this.device.deviceType}: ${this.accessory.displayName
260
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
261
- );
271
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
262
272
  this.power = deviceStatus.body.power;
263
273
  this.openAPIparseStatus();
264
274
  this.updateHomeKitCharacteristics();
265
275
  } catch (e: any) {
266
276
  this.apiError(e);
267
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
268
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
277
+ this.errorLog(
278
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
279
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
280
+ );
269
281
  }
270
282
  }
271
283
 
@@ -288,8 +300,9 @@ export class Plug {
288
300
  await this.openAPIpushChanges();
289
301
  } else {
290
302
  await this.offlineOff();
291
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
292
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
303
+ this.debugWarnLog(
304
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
305
+ );
293
306
  }
294
307
  // Refresh the status from the API
295
308
  interval(15000)
@@ -335,14 +348,15 @@ export class Plug {
335
348
  })
336
349
  .catch(async (e: any) => {
337
350
  this.apiError(e);
338
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
339
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
351
+ this.errorLog(
352
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
353
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
354
+ );
340
355
  await this.BLEPushConnection();
341
356
  });
342
357
  } else {
343
358
  this.debugLog(
344
- `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
345
- + `OnCached: ${this.accessory.context.On}`,
359
+ `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
346
360
  );
347
361
  }
348
362
  }
@@ -357,9 +371,9 @@ export class Plug {
357
371
  command = 'turnOff';
358
372
  }
359
373
  const bodyChange = JSON.stringify({
360
- 'command': `${command}`,
361
- 'parameter': 'default',
362
- 'commandType': 'command',
374
+ command: `${command}`,
375
+ parameter: 'default',
376
+ commandType: 'command',
363
377
  });
364
378
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
365
379
  try {
@@ -374,13 +388,17 @@ export class Plug {
374
388
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
375
389
  } catch (e: any) {
376
390
  this.apiError(e);
377
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
378
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
391
+ this.errorLog(
392
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
393
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
379
394
  );
380
395
  }
381
396
  } else {
382
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` + `On: ${this.On}, `
383
- + `OnCached: ${this.accessory.context.On}`);
397
+ this.debugLog(
398
+ `${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
399
+ `On: ${this.On}, ` +
400
+ `OnCached: ${this.accessory.context.On}`,
401
+ );
384
402
  }
385
403
  }
386
404
 
@@ -521,8 +539,10 @@ export class Plug {
521
539
  this.offlineOff();
522
540
  break;
523
541
  case 171:
524
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
525
- + `Hub: ${this.device.hubDeviceId}`);
542
+ this.errorLog(
543
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
544
+ `Hub: ${this.device.hubDeviceId}`,
545
+ );
526
546
  this.offlineOff();
527
547
  break;
528
548
  case 190:
@@ -538,8 +558,10 @@ export class Plug {
538
558
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
539
559
  break;
540
560
  default:
541
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
542
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
561
+ this.infoLog(
562
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
563
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
564
+ );
543
565
  }
544
566
  }
545
567
 
@@ -556,8 +578,9 @@ export class Plug {
556
578
 
557
579
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
558
580
  let FirmwareRevision: string;
559
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
560
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
581
+ this.debugLog(
582
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
583
+ );
561
584
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
562
585
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
563
586
  if (accessory.context.FirmwareRevision) {
@@ -39,10 +39,14 @@ export class RobotVacuumCleaner {
39
39
  doRobotVacuumCleanerUpdate!: Subject<void>;
40
40
 
41
41
  // Connection
42
- private readonly BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI');
43
- private readonly OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI');
44
-
45
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
42
+ private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
43
+ private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
44
+
45
+ constructor(
46
+ private readonly platform: SwitchBotPlatform,
47
+ private accessory: PlatformAccessory,
48
+ public device: device & devicesConfig,
49
+ ) {
46
50
  // default placeholders
47
51
  this.logs(device);
48
52
  this.scan(device);
@@ -127,13 +131,15 @@ export class RobotVacuumCleaner {
127
131
  if (this.On !== this.accessory.context.On) {
128
132
  await this.pushChanges();
129
133
  }
130
- if (this.On && (this.Brightness !== this.accessory.context.Brightness)) {
134
+ if (this.On && this.Brightness !== this.accessory.context.Brightness) {
131
135
  await this.openAPIpushBrightnessChanges();
132
136
  }
133
137
  } catch (e: any) {
134
138
  this.apiError(e);
135
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
136
- + ` Error Message: ${JSON.stringify(e.message)}`);
139
+ this.errorLog(
140
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
141
+ ` Error Message: ${JSON.stringify(e.message)}`,
142
+ );
137
143
  }
138
144
  this.robotVacuumCleanerUpdateInProgress = false;
139
145
  });
@@ -145,14 +151,15 @@ export class RobotVacuumCleaner {
145
151
  async parseStatus(): Promise<void> {
146
152
  if (!this.device.enableCloudService && this.OpenAPI) {
147
153
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} parseStatus enableCloudService: ${this.device.enableCloudService}`);
148
- } else/*if (this.BLE) {
154
+ } /*if (this.BLE) {
149
155
  await this.BLEparseStatus();
150
- } else*/if (this.OpenAPI && this.platform.config.credentials?.token) {
156
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
151
157
  await this.openAPIparseStatus();
152
158
  } else {
153
159
  await this.offlineOff();
154
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
155
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
160
+ this.debugWarnLog(
161
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
162
+ );
156
163
  }
157
164
  }
158
165
 
@@ -187,14 +194,16 @@ export class RobotVacuumCleaner {
187
194
  async refreshStatus(): Promise<void> {
188
195
  if (!this.device.enableCloudService && this.OpenAPI) {
189
196
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus enableCloudService: ${this.device.enableCloudService}`);
190
- } else/*if (this.BLE) {
197
+ } /*if (this.BLE) {
191
198
  await this.BLERefreshStatus();
192
- } else*/if (this.OpenAPI && this.platform.config.credentials?.token) {
199
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
193
200
  await this.openAPIRefreshStatus();
194
201
  } else {
195
202
  await this.offlineOff();
196
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
197
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
203
+ this.debugWarnLog(
204
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
205
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
206
+ );
198
207
  }
199
208
  }
200
209
 
@@ -219,8 +228,10 @@ export class RobotVacuumCleaner {
219
228
  // Set an event hander
220
229
  switchbot.onadvertisement = async (ad: any) => {
221
230
  this.address = ad.address;
222
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
223
- + ` BLE Address Found: ${this.address}`);
231
+ this.debugLog(
232
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
233
+ ` BLE Address Found: ${this.address}`,
234
+ );
224
235
  this.serviceData = ad.serviceData;
225
236
  this.state = ad.serviceData.state;
226
237
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
@@ -248,8 +259,10 @@ export class RobotVacuumCleaner {
248
259
  })
249
260
  .catch(async (e: any) => {
250
261
  this.apiError(e);
251
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
252
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
262
+ this.errorLog(
263
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
264
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
265
+ );
253
266
  await this.BLERefreshConnection(switchbot);
254
267
  });
255
268
  } else {
@@ -267,17 +280,16 @@ export class RobotVacuumCleaner {
267
280
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
268
281
  this.statusCode(statusCode);
269
282
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
270
- this.debugLog(
271
- `${this.device.deviceType}: ${this.accessory.displayName
272
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
273
- );
283
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
274
284
  this.power = deviceStatus.body.power;
275
285
  this.openAPIparseStatus();
276
286
  this.updateHomeKitCharacteristics();
277
287
  } catch (e: any) {
278
288
  this.apiError(e);
279
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
280
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
289
+ this.errorLog(
290
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
291
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
292
+ );
281
293
  }
282
294
  }
283
295
 
@@ -293,14 +305,15 @@ export class RobotVacuumCleaner {
293
305
  async pushChanges(): Promise<void> {
294
306
  if (!this.device.enableCloudService && this.OpenAPI) {
295
307
  this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} pushChanges enableCloudService: ${this.device.enableCloudService}`);
296
- } else/* if (this.BLE) {
308
+ } /* if (this.BLE) {
297
309
  await this.BLEpushChanges();
298
- } else*/if (this.OpenAPI && this.platform.config.credentials?.token) {
310
+ } else*/ else if (this.OpenAPI && this.platform.config.credentials?.token) {
299
311
  await this.openAPIpushChanges();
300
312
  } else {
301
313
  await this.offlineOff();
302
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
303
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
314
+ this.debugWarnLog(
315
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
316
+ );
304
317
  }
305
318
  // Refresh the status from the API
306
319
  interval(15000)
@@ -346,14 +359,15 @@ export class RobotVacuumCleaner {
346
359
  })
347
360
  .catch(async (e: any) => {
348
361
  this.apiError(e);
349
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
350
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
362
+ this.errorLog(
363
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
364
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
365
+ );
351
366
  await this.BLEPushConnection();
352
367
  });
353
368
  } else {
354
369
  this.debugLog(
355
- `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, `
356
- + `OnCached: ${this.accessory.context.On}`,
370
+ `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges.` + `On: ${this.On}, ` + `OnCached: ${this.accessory.context.On}`,
357
371
  );
358
372
  }
359
373
  }
@@ -368,9 +382,9 @@ export class RobotVacuumCleaner {
368
382
  command = 'turnOff';
369
383
  }
370
384
  const bodyChange = JSON.stringify({
371
- 'command': `${command}`,
372
- 'parameter': 'default',
373
- 'commandType': 'command',
385
+ command: `${command}`,
386
+ parameter: 'default',
387
+ commandType: 'command',
374
388
  });
375
389
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
376
390
  try {
@@ -385,13 +399,17 @@ export class RobotVacuumCleaner {
385
399
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
386
400
  } catch (e: any) {
387
401
  this.apiError(e);
388
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
389
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
402
+ this.errorLog(
403
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
404
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
390
405
  );
391
406
  }
392
407
  } else {
393
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` + `On: ${this.On}, `
394
- + `OnCached: ${this.accessory.context.On}`);
408
+ this.debugLog(
409
+ `${this.device.deviceType}: ${this.accessory.displayName} No openAPIpushChanges.` +
410
+ `On: ${this.On}, ` +
411
+ `OnCached: ${this.accessory.context.On}`,
412
+ );
395
413
  }
396
414
  }
397
415
 
@@ -410,8 +428,9 @@ export class RobotVacuumCleaner {
410
428
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
411
429
  } catch (e: any) {
412
430
  this.apiError(e);
413
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
414
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
431
+ this.errorLog(
432
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
433
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
415
434
  );
416
435
  }
417
436
  }
@@ -427,9 +446,9 @@ export class RobotVacuumCleaner {
427
446
  parameter = 'default';
428
447
  }
429
448
  const body = JSON.stringify({
430
- 'command': `${command}`,
431
- 'parameter': `${parameter}`,
432
- 'commandType': 'command',
449
+ command: `${command}`,
450
+ parameter: `${parameter}`,
451
+ commandType: 'command',
433
452
  });
434
453
  return body;
435
454
  }
@@ -454,9 +473,9 @@ export class RobotVacuumCleaner {
454
473
  parameter = 'default';
455
474
  }
456
475
  const body = JSON.stringify({
457
- 'command': `${command}`,
458
- 'parameter': `${parameter}`,
459
- 'commandType': 'command',
476
+ command: `${command}`,
477
+ parameter: `${parameter}`,
478
+ commandType: 'command',
460
479
  });
461
480
  return body;
462
481
  }
@@ -635,8 +654,10 @@ export class RobotVacuumCleaner {
635
654
  this.offlineOff();
636
655
  break;
637
656
  case 171:
638
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
639
- + `Hub: ${this.device.hubDeviceId}`);
657
+ this.errorLog(
658
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
659
+ `Hub: ${this.device.hubDeviceId}`,
660
+ );
640
661
  this.offlineOff();
641
662
  break;
642
663
  case 190:
@@ -652,8 +673,10 @@ export class RobotVacuumCleaner {
652
673
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
653
674
  break;
654
675
  default:
655
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
656
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
676
+ this.infoLog(
677
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
678
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
679
+ );
657
680
  }
658
681
  }
659
682
 
@@ -670,8 +693,9 @@ export class RobotVacuumCleaner {
670
693
 
671
694
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
672
695
  let FirmwareRevision: string;
673
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
674
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
696
+ this.debugLog(
697
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
698
+ );
675
699
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
676
700
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
677
701
  if (accessory.context.FirmwareRevision) {