@switchbot/homebridge-switchbot 1.9.0 → 1.10.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 (116) hide show
  1. package/.eslintrc +14 -45
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +3 -3
  3. package/.github/ISSUE_TEMPLATE/feature-request.yml +2 -2
  4. package/.github/ISSUE_TEMPLATE/support-request.yml +3 -3
  5. package/.github/labeler.yml +1 -1
  6. package/.github/workflows/codeql-analysis.yml +29 -29
  7. package/.github/workflows/nodejs-beta.yml +1 -1
  8. package/.github/workflows/prerelease-beta.js +1 -1
  9. package/.github/workflows/stale.yml +1 -1
  10. package/.prettierrc +9 -0
  11. package/.vscode/extensions.json +2 -4
  12. package/.vscode/settings.json +13 -1
  13. package/CHANGELOG.md +16 -0
  14. package/README.md +100 -99
  15. package/SECURITY.md +2 -2
  16. package/config.schema.json +8 -0
  17. package/dist/devices/bots.d.ts +2 -2
  18. package/dist/devices/bots.d.ts.map +1 -1
  19. package/dist/devices/bots.js +91 -86
  20. package/dist/devices/bots.js.map +1 -1
  21. package/dist/devices/colorbulb.d.ts +15 -15
  22. package/dist/devices/colorbulb.d.ts.map +1 -1
  23. package/dist/devices/colorbulb.js +60 -71
  24. package/dist/devices/colorbulb.js.map +1 -1
  25. package/dist/devices/contact.d.ts +2 -2
  26. package/dist/devices/contact.d.ts.map +1 -1
  27. package/dist/devices/contact.js +33 -31
  28. package/dist/devices/contact.js.map +1 -1
  29. package/dist/devices/curtains.d.ts +2 -2
  30. package/dist/devices/curtains.d.ts.map +1 -1
  31. package/dist/devices/curtains.js +71 -71
  32. package/dist/devices/curtains.js.map +1 -1
  33. package/dist/devices/humidifiers.d.ts +2 -2
  34. package/dist/devices/humidifiers.d.ts.map +1 -1
  35. package/dist/devices/humidifiers.js +74 -76
  36. package/dist/devices/humidifiers.js.map +1 -1
  37. package/dist/devices/meters.d.ts +2 -2
  38. package/dist/devices/meters.d.ts.map +1 -1
  39. package/dist/devices/meters.js +29 -27
  40. package/dist/devices/meters.js.map +1 -1
  41. package/dist/devices/motion.d.ts +2 -2
  42. package/dist/devices/motion.d.ts.map +1 -1
  43. package/dist/devices/motion.js +34 -32
  44. package/dist/devices/motion.js.map +1 -1
  45. package/dist/devices/plugs.d.ts +7 -7
  46. package/dist/devices/plugs.d.ts.map +1 -1
  47. package/dist/devices/plugs.js +18 -23
  48. package/dist/devices/plugs.js.map +1 -1
  49. package/dist/irdevices/airconditioners.d.ts +5 -2
  50. package/dist/irdevices/airconditioners.d.ts.map +1 -1
  51. package/dist/irdevices/airconditioners.js +61 -56
  52. package/dist/irdevices/airconditioners.js.map +1 -1
  53. package/dist/irdevices/airpurifiers.d.ts +2 -2
  54. package/dist/irdevices/airpurifiers.d.ts.map +1 -1
  55. package/dist/irdevices/airpurifiers.js +12 -17
  56. package/dist/irdevices/airpurifiers.js.map +1 -1
  57. package/dist/irdevices/cameras.d.ts +2 -2
  58. package/dist/irdevices/cameras.d.ts.map +1 -1
  59. package/dist/irdevices/cameras.js +10 -13
  60. package/dist/irdevices/cameras.js.map +1 -1
  61. package/dist/irdevices/fans.d.ts +2 -2
  62. package/dist/irdevices/fans.d.ts.map +1 -1
  63. package/dist/irdevices/fans.js +15 -17
  64. package/dist/irdevices/fans.js.map +1 -1
  65. package/dist/irdevices/lights.d.ts +2 -2
  66. package/dist/irdevices/lights.d.ts.map +1 -1
  67. package/dist/irdevices/lights.js +10 -13
  68. package/dist/irdevices/lights.js.map +1 -1
  69. package/dist/irdevices/others.d.ts +2 -2
  70. package/dist/irdevices/others.d.ts.map +1 -1
  71. package/dist/irdevices/others.js +10 -13
  72. package/dist/irdevices/others.js.map +1 -1
  73. package/dist/irdevices/tvs.d.ts +2 -2
  74. package/dist/irdevices/tvs.d.ts.map +1 -1
  75. package/dist/irdevices/tvs.js +22 -30
  76. package/dist/irdevices/tvs.js.map +1 -1
  77. package/dist/irdevices/vacuumcleaners.d.ts +2 -2
  78. package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
  79. package/dist/irdevices/vacuumcleaners.js +11 -13
  80. package/dist/irdevices/vacuumcleaners.js.map +1 -1
  81. package/dist/irdevices/waterheaters.d.ts +2 -2
  82. package/dist/irdevices/waterheaters.d.ts.map +1 -1
  83. package/dist/irdevices/waterheaters.js +10 -13
  84. package/dist/irdevices/waterheaters.js.map +1 -1
  85. package/dist/platform.d.ts +3 -3
  86. package/dist/platform.d.ts.map +1 -1
  87. package/dist/platform.js +13 -14
  88. package/dist/platform.js.map +1 -1
  89. package/dist/settings.d.ts +1 -0
  90. package/dist/settings.d.ts.map +1 -1
  91. package/dist/settings.js.map +1 -1
  92. package/homebridge-ui/public/index.html +231 -245
  93. package/homebridge-ui/server.js +2 -4
  94. package/nodemon.json +2 -4
  95. package/package.json +15 -9
  96. package/src/devices/bots.ts +217 -186
  97. package/src/devices/colorbulb.ts +90 -84
  98. package/src/devices/contact.ts +85 -78
  99. package/src/devices/curtains.ts +152 -135
  100. package/src/devices/humidifiers.ts +162 -137
  101. package/src/devices/meters.ts +76 -73
  102. package/src/devices/motion.ts +87 -78
  103. package/src/devices/plugs.ts +27 -31
  104. package/src/irdevices/airconditioners.ts +91 -59
  105. package/src/irdevices/airpurifiers.ts +22 -23
  106. package/src/irdevices/cameras.ts +18 -19
  107. package/src/irdevices/fans.ts +27 -25
  108. package/src/irdevices/lights.ts +18 -20
  109. package/src/irdevices/others.ts +18 -19
  110. package/src/irdevices/tvs.ts +33 -41
  111. package/src/irdevices/vacuumcleaners.ts +19 -19
  112. package/src/irdevices/waterheaters.ts +21 -31
  113. package/src/platform.ts +32 -33
  114. package/src/settings.ts +9 -19
  115. package/tsconfig.json +5 -14
  116. package/.github/PULL_REQUEST_TEMPLATE/pull_requests.md +0 -27
@@ -1,4 +1,3 @@
1
-
2
1
  import { AxiosResponse } from 'axios';
3
2
  import { interval, Subject } from 'rxjs';
4
3
  import { SwitchBotPlatform } from '../platform';
@@ -25,7 +24,6 @@ export class Bot {
25
24
  private windowCoveringService?: Service;
26
25
  private statefulProgrammableSwitchService?: Service;
27
26
 
28
-
29
27
  // Characteristic Values
30
28
  On!: CharacteristicValue;
31
29
  OnCached!: CharacteristicValue;
@@ -59,11 +57,7 @@ export class Bot {
59
57
  botUpdateInProgress!: boolean;
60
58
  doBotUpdate!: Subject<void>;
61
59
 
62
- constructor(
63
- private readonly platform: SwitchBotPlatform,
64
- private accessory: PlatformAccessory,
65
- public device: device & devicesConfig,
66
- ) {
60
+ constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
67
61
  // default placeholders
68
62
  this.logs(device);
69
63
  this.scan(device);
@@ -114,9 +108,8 @@ export class Bot {
114
108
  this.removeStatefulProgrammableSwitchService(accessory);
115
109
 
116
110
  // Add switchService
117
- (this.switchService =
118
- accessory.getService(this.platform.Service.Switch) ||
119
- accessory.addService(this.platform.Service.Switch)), `${accessory.displayName} Switch`;
111
+ (this.switchService = accessory.getService(this.platform.Service.Switch) || accessory.addService(this.platform.Service.Switch)),
112
+ `${accessory.displayName} Switch`;
120
113
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Switch`);
121
114
 
122
115
  this.switchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -134,8 +127,8 @@ export class Bot {
134
127
 
135
128
  // Add switchService
136
129
  (this.garageDoorService =
137
- accessory.getService(this.platform.Service.GarageDoorOpener) ||
138
- accessory.addService(this.platform.Service.GarageDoorOpener)), `${accessory.displayName} Garage Door Opener`;
130
+ accessory.getService(this.platform.Service.GarageDoorOpener) || accessory.addService(this.platform.Service.GarageDoorOpener)),
131
+ `${accessory.displayName} Garage Door Opener`;
139
132
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Garage Door Opener`);
140
133
 
141
134
  this.garageDoorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -153,19 +146,20 @@ export class Bot {
153
146
  this.removeStatefulProgrammableSwitchService(accessory);
154
147
 
155
148
  // Add switchService
156
- (this.doorService =
157
- accessory.getService(this.platform.Service.Door) ||
158
- accessory.addService(this.platform.Service.Door)), `${accessory.displayName} Door`;
149
+ (this.doorService = accessory.getService(this.platform.Service.Door) || accessory.addService(this.platform.Service.Door)),
150
+ `${accessory.displayName} Door`;
159
151
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Door`);
160
152
 
161
153
  this.doorService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
162
- this.doorService.getCharacteristic(this.platform.Characteristic.TargetPosition)
154
+ this.doorService
155
+ .getCharacteristic(this.platform.Characteristic.TargetPosition)
163
156
  .setProps({
164
157
  validValues: [0, 100],
165
158
  minValue: 0,
166
159
  maxValue: 100,
167
160
  minStep: 100,
168
- }).onSet(this.handleOnSet.bind(this));
161
+ })
162
+ .onSet(this.handleOnSet.bind(this));
169
163
  this.doorService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
170
164
  } else if (device.bot?.deviceType === 'window') {
171
165
  this.removeFanService(accessory);
@@ -179,19 +173,20 @@ export class Bot {
179
173
  this.removeStatefulProgrammableSwitchService(accessory);
180
174
 
181
175
  // Add switchService
182
- (this.windowService =
183
- accessory.getService(this.platform.Service.Window) ||
184
- accessory.addService(this.platform.Service.Window)), `${accessory.displayName} Window`;
176
+ (this.windowService = accessory.getService(this.platform.Service.Window) || accessory.addService(this.platform.Service.Window)),
177
+ `${accessory.displayName} Window`;
185
178
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Window`);
186
179
 
187
180
  this.windowService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
188
- this.windowService.getCharacteristic(this.platform.Characteristic.TargetPosition)
181
+ this.windowService
182
+ .getCharacteristic(this.platform.Characteristic.TargetPosition)
189
183
  .setProps({
190
184
  validValues: [0, 100],
191
185
  minValue: 0,
192
186
  maxValue: 100,
193
187
  minStep: 100,
194
- }).onSet(this.handleOnSet.bind(this));
188
+ })
189
+ .onSet(this.handleOnSet.bind(this));
195
190
  this.windowService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
196
191
  } else if (device.bot?.deviceType === 'windowcovering') {
197
192
  this.removeFanService(accessory);
@@ -206,18 +201,20 @@ export class Bot {
206
201
 
207
202
  // Add switchService
208
203
  (this.windowCoveringService =
209
- accessory.getService(this.platform.Service.WindowCovering) ||
210
- accessory.addService(this.platform.Service.WindowCovering)), `${accessory.displayName} Window Covering`;
204
+ accessory.getService(this.platform.Service.WindowCovering) || accessory.addService(this.platform.Service.WindowCovering)),
205
+ `${accessory.displayName} Window Covering`;
211
206
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Window Covering`);
212
207
 
213
208
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
214
- this.windowCoveringService.getCharacteristic(this.platform.Characteristic.TargetPosition)
209
+ this.windowCoveringService
210
+ .getCharacteristic(this.platform.Characteristic.TargetPosition)
215
211
  .setProps({
216
212
  validValues: [0, 100],
217
213
  minValue: 0,
218
214
  maxValue: 100,
219
215
  minStep: 100,
220
- }).onSet(this.handleOnSet.bind(this));
216
+ })
217
+ .onSet(this.handleOnSet.bind(this));
221
218
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
222
219
  } else if (device.bot?.deviceType === 'lock') {
223
220
  this.removeFanService(accessory);
@@ -231,9 +228,8 @@ export class Bot {
231
228
  this.removeStatefulProgrammableSwitchService(accessory);
232
229
 
233
230
  // Add switchService
234
- (this.lockService =
235
- accessory.getService(this.platform.Service.LockMechanism) ||
236
- accessory.addService(this.platform.Service.LockMechanism)), `${accessory.displayName} Lock`;
231
+ (this.lockService = accessory.getService(this.platform.Service.LockMechanism) || accessory.addService(this.platform.Service.LockMechanism)),
232
+ `${accessory.displayName} Lock`;
237
233
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Lock`);
238
234
 
239
235
  this.lockService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -250,9 +246,8 @@ export class Bot {
250
246
  this.removeStatefulProgrammableSwitchService(accessory);
251
247
 
252
248
  // Add switchService
253
- (this.faucetService =
254
- accessory.getService(this.platform.Service.Faucet) ||
255
- accessory.addService(this.platform.Service.Faucet)), `${accessory.displayName} Faucet`;
249
+ (this.faucetService = accessory.getService(this.platform.Service.Faucet) || accessory.addService(this.platform.Service.Faucet)),
250
+ `${accessory.displayName} Faucet`;
256
251
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Faucet`);
257
252
 
258
253
  this.faucetService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -269,9 +264,8 @@ export class Bot {
269
264
  this.removeStatefulProgrammableSwitchService(accessory);
270
265
 
271
266
  // Add switchService
272
- (this.fanService =
273
- accessory.getService(this.platform.Service.Fan) ||
274
- accessory.addService(this.platform.Service.Fan)), `${accessory.displayName} Fan`;
267
+ (this.fanService = accessory.getService(this.platform.Service.Fan) || accessory.addService(this.platform.Service.Fan)),
268
+ `${accessory.displayName} Fan`;
275
269
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Fan`);
276
270
 
277
271
  this.fanService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -290,11 +284,13 @@ export class Bot {
290
284
  // Add switchService
291
285
  (this.statefulProgrammableSwitchService =
292
286
  accessory.getService(this.platform.Service.StatefulProgrammableSwitch) ||
293
- accessory.addService(this.platform.Service.StatefulProgrammableSwitch)), `${accessory.displayName} Stateful Programmable Switch`;
287
+ accessory.addService(this.platform.Service.StatefulProgrammableSwitch)),
288
+ `${accessory.displayName} Stateful Programmable Switch`;
294
289
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Stateful Programmable Switch`);
295
290
 
296
291
  this.statefulProgrammableSwitchService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
297
- this.statefulProgrammableSwitchService.getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
292
+ this.statefulProgrammableSwitchService
293
+ .getCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState)
298
294
  .onSet(this.handleOnSet.bind(this));
299
295
  } else {
300
296
  this.removeFanService(accessory);
@@ -308,9 +304,8 @@ export class Bot {
308
304
  this.removeStatefulProgrammableSwitchService(accessory);
309
305
 
310
306
  // Add outletService
311
- (this.outletService =
312
- accessory.getService(this.platform.Service.Outlet) ||
313
- accessory.addService(this.platform.Service.Outlet)), `${accessory.displayName} Outlet`;
307
+ (this.outletService = accessory.getService(this.platform.Service.Outlet) || accessory.addService(this.platform.Service.Outlet)),
308
+ `${accessory.displayName} Outlet`;
314
309
  this.infoLog(`Bot: ${accessory.displayName} Displaying as Outlet`);
315
310
 
316
311
  this.outletService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
@@ -324,12 +319,10 @@ export class Bot {
324
319
  accessory.removeService(this.batteryService!);
325
320
  } else if (device.ble && !this.batteryService) {
326
321
  this.debugLog(`Bot: ${accessory.displayName} Add Battery Service`);
327
- (this.batteryService =
328
- this.accessory.getService(this.platform.Service.Battery) ||
329
- this.accessory.addService(this.platform.Service.Battery)), `${accessory.displayName} Battery`;
322
+ (this.batteryService = this.accessory.getService(this.platform.Service.Battery) || this.accessory.addService(this.platform.Service.Battery)),
323
+ `${accessory.displayName} Battery`;
330
324
 
331
325
  this.batteryService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Battery`);
332
-
333
326
  } else {
334
327
  this.debugLog(`Bot: ${accessory.displayName} Battery Service Not Added`);
335
328
  }
@@ -363,12 +356,10 @@ export class Bot {
363
356
  } catch (e: any) {
364
357
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges`);
365
358
  if (this.deviceLogging === 'debug') {
366
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,`
367
- + ` Error Message: ${JSON.stringify(e.message)}`);
359
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,` + ` Error Message: ${JSON.stringify(e.message)}`);
368
360
  }
369
361
  if (this.platform.debugMode) {
370
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,`
371
- + ` Error: ${JSON.stringify(e)}`);
362
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges,` + ` Error: ${JSON.stringify(e)}`);
372
363
  }
373
364
  }
374
365
  this.botUpdateInProgress = false;
@@ -460,67 +451,76 @@ export class Bot {
460
451
  this.debugLog(`Bot: ${this.accessory.displayName} BLE refreshStatus`);
461
452
  const switchbot = await this.platform.connectBLE();
462
453
  // Convert to BLE Address
463
- this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
454
+ this.device.bleMac = this.device
455
+ .deviceId!.match(/.{1,2}/g)!
456
+ .join(':')
457
+ .toLowerCase();
464
458
  this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
465
459
  // Start to monitor advertisement packets
466
460
  if (switchbot === false) {
467
461
  this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection: ${switchbot}`);
468
462
  }
469
- switchbot.startScan({
470
- model: 'H',
471
- id: this.device.bleMac,
472
- }).then(() => {
473
- // Set an event hander
474
- switchbot.onadvertisement = (ad: ad) => {
475
- this.serviceData = ad.serviceData;
476
- this.mode = ad.serviceData.mode;
477
- this.state = ad.serviceData.state;
478
- this.battery = ad.serviceData.battery;
479
- this.debugLog(`Bot: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
480
- this.debugLog(`Bot: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},`
481
- + ` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`);
482
-
483
- if (this.serviceData) {
484
- this.connected = true;
485
- this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
463
+ switchbot
464
+ .startScan({
465
+ model: 'H',
466
+ id: this.device.bleMac,
467
+ })
468
+ .then(() => {
469
+ // Set an event hander
470
+ switchbot.onadvertisement = (ad: ad) => {
471
+ this.serviceData = ad.serviceData;
472
+ this.mode = ad.serviceData.mode;
473
+ this.state = ad.serviceData.state;
474
+ this.battery = ad.serviceData.battery;
475
+ this.debugLog(`Bot: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
476
+ this.debugLog(
477
+ `Bot: ${this.accessory.displayName}, model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},` +
478
+ ` mode: ${ad.serviceData.mode}, state: ${ad.serviceData.state}, battery: ${ad.serviceData.battery}`,
479
+ );
480
+
481
+ if (this.serviceData) {
482
+ this.connected = true;
483
+ this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
484
+ } else {
485
+ this.connected = false;
486
+ this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
487
+ }
488
+ };
489
+ // Wait 2 seconds
490
+ return switchbot.wait(this.scanDuration * 1000);
491
+ })
492
+ .then(async () => {
493
+ // Stop to monitor
494
+ switchbot.stopScan();
495
+ if (this.connected) {
496
+ this.parseStatus();
497
+ this.updateHomeKitCharacteristics();
486
498
  } else {
487
- this.connected = false;
488
- this.debugLog(`Bot: ${this.accessory.displayName} connected: ${this.connected}`);
499
+ this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
500
+ if (this.platform.config.credentials?.openToken) {
501
+ this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
502
+ this.SwitchToOpenAPI = true;
503
+ await this.openAPIRefreshStatus();
504
+ }
505
+ }
506
+ })
507
+ .catch(async (e: any) => {
508
+ this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
509
+ if (this.deviceLogging === 'debug') {
510
+ this.errorLog(
511
+ `Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
512
+ );
513
+ }
514
+ if (this.platform.debugMode) {
515
+ this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
489
516
  }
490
- };
491
- // Wait 2 seconds
492
- return switchbot.wait(this.scanDuration * 1000);
493
- }).then(async () => {
494
- // Stop to monitor
495
- switchbot.stopScan();
496
- if (this.connected) {
497
- this.parseStatus();
498
- this.updateHomeKitCharacteristics();
499
- } else {
500
- this.errorLog(`Bot: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
501
517
  if (this.platform.config.credentials?.openToken) {
502
518
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
503
519
  this.SwitchToOpenAPI = true;
504
520
  await this.openAPIRefreshStatus();
505
521
  }
506
- }
507
- }).catch(async (e: any) => {
508
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
509
- if (this.deviceLogging === 'debug') {
510
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
511
- + ` Error Message: ${JSON.stringify(e.message)}`);
512
- }
513
- if (this.platform.debugMode) {
514
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
515
- + ` Error: ${JSON.stringify(e)}`);
516
- }
517
- if (this.platform.config.credentials?.openToken) {
518
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
519
- this.SwitchToOpenAPI = true;
520
- await this.openAPIRefreshStatus();
521
- }
522
- this.apiError(e);
523
- });
522
+ this.apiError(e);
523
+ });
524
524
  }
525
525
 
526
526
  private async openAPIRefreshStatus() {
@@ -535,12 +535,12 @@ export class Bot {
535
535
  } catch (e: any) {
536
536
  this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
537
537
  if (this.deviceLogging === 'debug') {
538
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
539
- + ` Error Message: ${JSON.stringify(e.message)}`);
538
+ this.errorLog(
539
+ `Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
540
+ );
540
541
  }
541
542
  if (this.platform.debugMode) {
542
- this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
543
- + ` Error: ${JSON.stringify(e)}`);
543
+ this.errorLog(`Bot: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
544
544
  }
545
545
  this.apiError(e);
546
546
  }
@@ -570,20 +570,25 @@ export class Bot {
570
570
 
571
571
  private async BLEpushChanges() {
572
572
  this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges On: ${this.On} OnCached: ${this.OnCached}`);
573
- if ((this.On !== this.OnCached) || this.allowPush) {
573
+ if (this.On !== this.OnCached || this.allowPush) {
574
574
  this.debugLog(`Bot: ${this.accessory.displayName} BLE pushChanges`);
575
575
  const switchbot = await this.platform.connectBLE();
576
576
  // Convert to BLE Address
577
- this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
577
+ this.device.bleMac = this.device
578
+ .deviceId!.match(/.{1,2}/g)!
579
+ .join(':')
580
+ .toLowerCase();
578
581
  this.debugLog(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
579
582
  //if (switchbot !== false) {
580
583
  if (this.botMode === 'press') {
581
584
  this.debugLog(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
582
- switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
583
- .then((device_list: { press: (arg0: { id: string | undefined; }) => any; }[]) => {
585
+ switchbot
586
+ .discover({ model: 'H', quick: true, id: this.device.bleMac })
587
+ .then((device_list: { press: (arg0: { id: string | undefined }) => any }[]) => {
584
588
  this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
585
589
  return device_list[0].press({ id: this.device.bleMac });
586
- }).then(() => {
590
+ })
591
+ .then(() => {
587
592
  this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
588
593
  this.On = false;
589
594
  this.OnCached = this.On;
@@ -596,15 +601,16 @@ export class Bot {
596
601
  }
597
602
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}, Switch Timeout`);
598
603
  }, 500);
599
- }).catch(async (e: any) => {
604
+ })
605
+ .catch(async (e: any) => {
600
606
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
601
607
  if (this.deviceLogging === 'debug') {
602
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
603
- + ` Error Message: ${JSON.stringify(e.message)}`);
608
+ this.errorLog(
609
+ `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
610
+ );
604
611
  }
605
612
  if (this.platform.debugMode) {
606
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
607
- + ` Error: ${JSON.stringify(e)}`);
613
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
608
614
  }
609
615
  if (this.platform.config.credentials?.openToken) {
610
616
  this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
@@ -614,29 +620,33 @@ export class Bot {
614
620
  });
615
621
  } else if (this.botMode === 'switch') {
616
622
  this.debugLog(`Bot: ${this.accessory.displayName} Press Mode: ${this.botMode}`);
617
- switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list: any) => {
618
- this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
619
- return this.turnOnOff(device_list);
620
- }).then(() => {
621
- this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
622
- this.OnCached = this.On;
623
- this.accessory.context.On = this.OnCached;
624
- }).catch(async (e: any) => {
625
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
626
- if (this.deviceLogging === 'debug') {
627
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
628
- + ` Error Message: ${JSON.stringify(e.message)}`);
629
- }
630
- if (this.platform.debugMode) {
631
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
632
- + ` Error: ${JSON.stringify(e)}`);
633
- }
634
- if (this.platform.config.credentials?.openToken) {
635
- this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
636
- await this.openAPIpushChanges();
637
- }
638
- this.apiError(e);
639
- });
623
+ switchbot
624
+ .discover({ model: 'H', quick: true, id: this.device.bleMac })
625
+ .then((device_list: any) => {
626
+ this.infoLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
627
+ return this.turnOnOff(device_list);
628
+ })
629
+ .then(() => {
630
+ this.debugLog(`Bot: ${this.accessory.displayName} Done.`);
631
+ this.OnCached = this.On;
632
+ this.accessory.context.On = this.OnCached;
633
+ })
634
+ .catch(async (e: any) => {
635
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
636
+ if (this.deviceLogging === 'debug') {
637
+ this.errorLog(
638
+ `Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
639
+ );
640
+ }
641
+ if (this.platform.debugMode) {
642
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,` + ` Error: ${JSON.stringify(e)}`);
643
+ }
644
+ if (this.platform.config.credentials?.openToken) {
645
+ this.warnLog(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
646
+ await this.openAPIpushChanges();
647
+ }
648
+ this.apiError(e);
649
+ });
640
650
  } else {
641
651
  throw new Error(`Bot: ${this.accessory.displayName} Bot Mode: ${this.botMode}`);
642
652
  }
@@ -663,7 +673,7 @@ export class Bot {
663
673
  private async openAPIpushChanges() {
664
674
  if (this.platform.config.credentials?.openToken) {
665
675
  try {
666
- if ((this.On !== this.OnCached) || this.allowPush) {
676
+ if (this.On !== this.OnCached || this.allowPush) {
667
677
  this.debugLog(`Bot: ${this.accessory.displayName} OpenAPI pushChanges`);
668
678
  const payload = {
669
679
  commandType: 'command',
@@ -686,11 +696,13 @@ export class Bot {
686
696
  throw new Error(`Bot: ${this.accessory.displayName} Device Paramters not set for this Bot.`);
687
697
  }
688
698
 
689
- this.infoLog(`Bot: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
690
- + ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
699
+ this.infoLog(
700
+ `Bot: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},` +
701
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`,
702
+ );
691
703
 
692
704
  // Make the API request
693
- const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
705
+ const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
694
706
  this.debugLog(`Bot: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
695
707
  this.statusCode(push);
696
708
  this.OnCached = this.On;
@@ -699,12 +711,12 @@ export class Bot {
699
711
  } catch (e: any) {
700
712
  this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
701
713
  if (this.deviceLogging === 'debug') {
702
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
703
- + ` Error Message: ${JSON.stringify(e.message)}`);
714
+ this.errorLog(
715
+ `Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
716
+ );
704
717
  }
705
718
  if (this.platform.debugMode) {
706
- this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
707
- + ` Error: ${JSON.stringify(e)}`);
719
+ this.errorLog(`Bot: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error: ${JSON.stringify(e)}`);
708
720
  }
709
721
  this.apiError(e);
710
722
  }
@@ -720,16 +732,24 @@ export class Bot {
720
732
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
721
733
  } else {
722
734
  if (this.On) {
723
- this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState,
724
- this.platform.Characteristic.TargetDoorState.OPEN);
725
- this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState,
726
- this.platform.Characteristic.CurrentDoorState.OPEN);
735
+ this.garageDoorService?.updateCharacteristic(
736
+ this.platform.Characteristic.TargetDoorState,
737
+ this.platform.Characteristic.TargetDoorState.OPEN,
738
+ );
739
+ this.garageDoorService?.updateCharacteristic(
740
+ this.platform.Characteristic.CurrentDoorState,
741
+ this.platform.Characteristic.CurrentDoorState.OPEN,
742
+ );
727
743
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
728
744
  } else {
729
- this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.TargetDoorState,
730
- this.platform.Characteristic.TargetDoorState.CLOSED);
731
- this.garageDoorService?.updateCharacteristic(this.platform.Characteristic.CurrentDoorState,
732
- this.platform.Characteristic.CurrentDoorState.CLOSED);
745
+ this.garageDoorService?.updateCharacteristic(
746
+ this.platform.Characteristic.TargetDoorState,
747
+ this.platform.Characteristic.TargetDoorState.CLOSED,
748
+ );
749
+ this.garageDoorService?.updateCharacteristic(
750
+ this.platform.Characteristic.CurrentDoorState,
751
+ this.platform.Characteristic.CurrentDoorState.CLOSED,
752
+ );
733
753
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetDoorState: Open, CurrentDoorState: Open`);
734
754
  }
735
755
  }
@@ -741,14 +761,12 @@ export class Bot {
741
761
  if (this.On) {
742
762
  this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
743
763
  this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
744
- this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState,
745
- this.platform.Characteristic.PositionState.STOPPED);
764
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
746
765
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
747
766
  } else {
748
767
  this.doorService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
749
768
  this.doorService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
750
- this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState,
751
- this.platform.Characteristic.PositionState.STOPPED);
769
+ this.doorService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
752
770
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
753
771
  }
754
772
  }
@@ -760,14 +778,12 @@ export class Bot {
760
778
  if (this.On) {
761
779
  this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
762
780
  this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
763
- this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState,
764
- this.platform.Characteristic.PositionState.STOPPED);
781
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
765
782
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
766
783
  } else {
767
784
  this.windowService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
768
785
  this.windowService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
769
- this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState,
770
- this.platform.Characteristic.PositionState.STOPPED);
786
+ this.windowService?.updateCharacteristic(this.platform.Characteristic.PositionState, this.platform.Characteristic.PositionState.STOPPED);
771
787
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
772
788
  }
773
789
  }
@@ -779,14 +795,18 @@ export class Bot {
779
795
  if (this.On) {
780
796
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 100);
781
797
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 100);
782
- this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState,
783
- this.platform.Characteristic.PositionState.STOPPED);
798
+ this.windowCoveringService?.updateCharacteristic(
799
+ this.platform.Characteristic.PositionState,
800
+ this.platform.Characteristic.PositionState.STOPPED,
801
+ );
784
802
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 100, CurrentPosition: 100`);
785
803
  } else {
786
804
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.TargetPosition, 0);
787
805
  this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.CurrentPosition, 0);
788
- this.windowCoveringService?.updateCharacteristic(this.platform.Characteristic.PositionState,
789
- this.platform.Characteristic.PositionState.STOPPED);
806
+ this.windowCoveringService?.updateCharacteristic(
807
+ this.platform.Characteristic.PositionState,
808
+ this.platform.Characteristic.PositionState.STOPPED,
809
+ );
790
810
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic TargetPosition: 0, CurrentPosition: 0`);
791
811
  }
792
812
  }
@@ -796,16 +816,21 @@ export class Bot {
796
816
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
797
817
  } else {
798
818
  if (this.On) {
799
- this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState,
800
- this.platform.Characteristic.LockTargetState.UNSECURED);
801
- this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState,
802
- this.platform.Characteristic.LockCurrentState.UNSECURED);
819
+ this.lockService?.updateCharacteristic(
820
+ this.platform.Characteristic.LockTargetState,
821
+ this.platform.Characteristic.LockTargetState.UNSECURED,
822
+ );
823
+ this.lockService?.updateCharacteristic(
824
+ this.platform.Characteristic.LockCurrentState,
825
+ this.platform.Characteristic.LockCurrentState.UNSECURED,
826
+ );
803
827
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: UNSECURED, LockCurrentState: UNSECURED`);
804
828
  } else {
805
- this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState,
806
- this.platform.Characteristic.LockTargetState.SECURED);
807
- this.lockService?.updateCharacteristic(this.platform.Characteristic.LockCurrentState,
808
- this.platform.Characteristic.LockCurrentState.SECURED);
829
+ this.lockService?.updateCharacteristic(this.platform.Characteristic.LockTargetState, this.platform.Characteristic.LockTargetState.SECURED);
830
+ this.lockService?.updateCharacteristic(
831
+ this.platform.Characteristic.LockCurrentState,
832
+ this.platform.Characteristic.LockCurrentState.SECURED,
833
+ );
809
834
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic LockTargetState: SECURED, LockCurrentState: SECURED`);
810
835
  }
811
836
  }
@@ -815,12 +840,10 @@ export class Bot {
815
840
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
816
841
  } else {
817
842
  if (this.On) {
818
- this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active,
819
- this.platform.Characteristic.Active.ACTIVE);
843
+ this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.ACTIVE);
820
844
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
821
845
  } else {
822
- this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active,
823
- this.platform.Characteristic.Active.INACTIVE);
846
+ this.faucetService?.updateCharacteristic(this.platform.Characteristic.Active, this.platform.Characteristic.Active.INACTIVE);
824
847
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic Active: ${this.On}`);
825
848
  }
826
849
  }
@@ -843,13 +866,17 @@ export class Bot {
843
866
  this.debugLog(`Bot: ${this.accessory.displayName} On: ${this.On}`);
844
867
  } else {
845
868
  if (this.On) {
846
- this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent,
847
- this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
869
+ this.statefulProgrammableSwitchService?.updateCharacteristic(
870
+ this.platform.Characteristic.ProgrammableSwitchEvent,
871
+ this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
872
+ );
848
873
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 1);
849
874
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 1`);
850
875
  } else {
851
- this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchEvent,
852
- this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
876
+ this.statefulProgrammableSwitchService?.updateCharacteristic(
877
+ this.platform.Characteristic.ProgrammableSwitchEvent,
878
+ this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS,
879
+ );
853
880
  this.statefulProgrammableSwitchService?.updateCharacteristic(this.platform.Characteristic.ProgrammableSwitchOutputState, 0);
854
881
  this.debugLog(`Bot: ${this.accessory.displayName} updateCharacteristic ProgrammableSwitchEvent: SINGLE, ProgrammableSwitchOutputState: 0`);
855
882
  }
@@ -925,7 +952,7 @@ export class Bot {
925
952
  //throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
926
953
  }
927
954
 
928
- private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
955
+ private statusCode(push: AxiosResponse<{ statusCode: number }>) {
929
956
  switch (push.data.statusCode) {
930
957
  case 151:
931
958
  this.errorLog(`Bot: ${this.accessory.displayName} Command not supported by this device type.`);
@@ -945,8 +972,10 @@ export class Bot {
945
972
  this.offlineOff();
946
973
  break;
947
974
  case 190:
948
- this.errorLog(`Bot: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
949
- + ` Or command: ${JSON.stringify(push.data)} format is invalid`);
975
+ this.errorLog(
976
+ `Bot: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
977
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`,
978
+ );
950
979
  break;
951
980
  case 100:
952
981
  this.debugLog(`Bot: ${this.accessory.displayName} Command successfully sent.`);
@@ -978,9 +1007,11 @@ export class Bot {
978
1007
  } else {
979
1008
  this.On = true;
980
1009
  }
981
- } else if (this.device.bot?.deviceType === 'door'
982
- || this.device.bot?.deviceType === 'window'
983
- || this.device.bot?.deviceType === 'windowcovering') {
1010
+ } else if (
1011
+ this.device.bot?.deviceType === 'door' ||
1012
+ this.device.bot?.deviceType === 'window' ||
1013
+ this.device.bot?.deviceType === 'windowcovering'
1014
+ ) {
984
1015
  this.debugLog(`Bot: ${this.accessory.displayName} TargetPosition: ${value}`);
985
1016
  if (value === 0) {
986
1017
  this.On = false;
@@ -1193,8 +1224,8 @@ export class Bot {
1193
1224
  }
1194
1225
 
1195
1226
  /**
1196
- * Logging for Device
1197
- */
1227
+ * Logging for Device
1228
+ */
1198
1229
  infoLog(...log: any[]) {
1199
1230
  if (this.enablingDeviceLogging()) {
1200
1231
  this.platform.log.info(String(...log));