@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
@@ -80,10 +80,14 @@ export class BlindTilt {
80
80
  doBlindTiltUpdate!: Subject<void>;
81
81
 
82
82
  // Connection
83
- private readonly BLE = (this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI');
84
- private readonly OpenAPI = (this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI');
85
-
86
- constructor(private readonly platform: SwitchBotPlatform, private accessory: PlatformAccessory, public device: device & devicesConfig) {
83
+ private readonly BLE = this.device.connectionType === 'BLE' || this.device.connectionType === 'BLE/OpenAPI';
84
+ private readonly OpenAPI = this.device.connectionType === 'OpenAPI' || this.device.connectionType === 'BLE/OpenAPI';
85
+
86
+ constructor(
87
+ private readonly platform: SwitchBotPlatform,
88
+ private accessory: PlatformAccessory,
89
+ public device: device & devicesConfig,
90
+ ) {
87
91
  // default placeholders
88
92
  this.logs(device);
89
93
  this.refreshRate(device);
@@ -236,8 +240,10 @@ export class BlindTilt {
236
240
  await this.pushChanges();
237
241
  } catch (e: any) {
238
242
  this.apiError(e);
239
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,`
240
- + ` Error Message: ${JSON.stringify(e.message)}`);
243
+ this.errorLog(
244
+ `${this.device.deviceType}: ${this.accessory.displayName} failed pushChanges with ${this.device.connectionType} Connection,` +
245
+ ` Error Message: ${JSON.stringify(e.message)}`,
246
+ );
241
247
  }
242
248
  this.blindTiltUpdateInProgress = false;
243
249
  });
@@ -255,8 +261,9 @@ export class BlindTilt {
255
261
  await this.openAPIparseStatus();
256
262
  } else {
257
263
  await this.offlineOff();
258
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
259
- + ` ${this.device.connectionType}, parseStatus will not happen.`);
264
+ this.debugWarnLog(
265
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, parseStatus will not happen.`,
266
+ );
260
267
  }
261
268
  }
262
269
 
@@ -351,8 +358,8 @@ export class BlindTilt {
351
358
  this.debugLog();
352
359
  }
353
360
  this.debugLog(
354
- `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},`
355
- + ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
361
+ `${this.device.deviceType}: ${this.accessory.displayName} LightLevel: ${this.lightLevel},` +
362
+ ` CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
356
363
  );
357
364
  }
358
365
  // Battery
@@ -362,8 +369,9 @@ export class BlindTilt {
362
369
  } else {
363
370
  this.StatusLowBattery = this.platform.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
364
371
  }
365
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},`
366
- + ` StatusLowBattery: ${this.StatusLowBattery}`);
372
+ this.debugLog(
373
+ `${this.device.deviceType}: ${this.accessory.displayName} BatteryLevel: ${this.BatteryLevel},` + ` StatusLowBattery: ${this.StatusLowBattery}`,
374
+ );
367
375
  }
368
376
 
369
377
  async openAPIparseStatus(): Promise<void> {
@@ -388,7 +396,7 @@ export class BlindTilt {
388
396
 
389
397
  if (this.setNewTarget && this.moving) {
390
398
  await this.setMinMax();
391
- if (this.TargetPosition > this.CurrentPosition || (homekitTiltAngle && (this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle))) {
399
+ if (this.TargetPosition > this.CurrentPosition || (homekitTiltAngle && this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle)) {
392
400
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Closing, CurrentPosition: ${this.CurrentPosition} `);
393
401
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
394
402
  this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
@@ -399,15 +407,17 @@ export class BlindTilt {
399
407
  this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
400
408
  this.debugLog(`${this.device.deviceType}: ${this.CurrentPosition} DECREASING PositionState: ${this.PositionState}`);
401
409
  } else {
402
- this.debugLog(`${this.device.deviceType}: ${this.CurrentPosition} Standby because reached position,` +
403
- ` CurrentPosition: ${this.CurrentPosition}`);
410
+ this.debugLog(
411
+ `${this.device.deviceType}: ${this.CurrentPosition} Standby because reached position,` + ` CurrentPosition: ${this.CurrentPosition}`,
412
+ );
404
413
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
405
414
  this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
406
415
  this.debugLog(`${this.device.deviceType}: ${this.CurrentPosition} STOPPED PositionState: ${this.PositionState}`);
407
416
  }
408
417
  } else {
409
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Standby because device not moving,` +
410
- ` CurrentPosition: ${this.CurrentPosition}`);
418
+ this.debugLog(
419
+ `${this.device.deviceType}: ${this.accessory.displayName} Standby because device not moving,` + ` CurrentPosition: ${this.CurrentPosition}`,
420
+ );
411
421
  this.TargetPosition = this.CurrentPosition;
412
422
  if (homekitTiltAngle) {
413
423
  this.TargetHorizontalTiltAngle = this.CurrentHorizontalTiltAngle;
@@ -445,8 +455,10 @@ export class BlindTilt {
445
455
  await this.openAPIRefreshStatus();
446
456
  } else {
447
457
  await this.offlineOff();
448
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
449
- + ` ${this.device.connectionType}, refreshStatus will not happen.`);
458
+ this.debugWarnLog(
459
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` +
460
+ ` ${this.device.connectionType}, refreshStatus will not happen.`,
461
+ );
450
462
  }
451
463
  }
452
464
 
@@ -471,8 +483,10 @@ export class BlindTilt {
471
483
  // Set an event hander
472
484
  switchbot.onadvertisement = async (ad: any) => {
473
485
  this.address = ad.address;
474
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},`
475
- + ` BLE Address Found: ${this.address}`);
486
+ this.debugLog(
487
+ `${this.device.deviceType}: ${this.accessory.displayName} Config BLE Address: ${this.device.bleMac},` +
488
+ ` BLE Address Found: ${this.address}`,
489
+ );
476
490
  this.serviceData = ad.serviceData;
477
491
  this.calibration = ad.serviceData.calibration;
478
492
  this.battery = ad.serviceData.battery;
@@ -483,7 +497,8 @@ export class BlindTilt {
483
497
  this.debugLog(
484
498
  `${this.device.deviceType}: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, ` +
485
499
  `position: ${ad.serviceData.position}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}, ` +
486
- `inMotion: ${ad.serviceData.inMotion}`);
500
+ `inMotion: ${ad.serviceData.inMotion}`,
501
+ );
487
502
 
488
503
  if (this.serviceData) {
489
504
  this.connected = true;
@@ -503,8 +518,10 @@ export class BlindTilt {
503
518
  })
504
519
  .catch(async (e: any) => {
505
520
  this.apiError(e);
506
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}`
507
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
521
+ this.errorLog(
522
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLERefreshStatus with ${this.device.connectionType}` +
523
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
524
+ );
508
525
  await this.BLERefreshConnection(switchbot);
509
526
  });
510
527
  } else {
@@ -522,10 +539,7 @@ export class BlindTilt {
522
539
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Devices: ${JSON.stringify(deviceStatus.body)}`);
523
540
  this.statusCode(statusCode);
524
541
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
525
- this.debugLog(
526
- `${this.device.deviceType}: ${this.accessory.displayName
527
- } refreshStatus: ${JSON.stringify(deviceStatus)}`,
528
- );
542
+ this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(deviceStatus)}`);
529
543
  this.slidePosition = deviceStatus.body.slidePosition;
530
544
  this.direction = deviceStatus.body.direction;
531
545
  this.moving = deviceStatus.body.moving;
@@ -534,8 +548,10 @@ export class BlindTilt {
534
548
  this.updateHomeKitCharacteristics();
535
549
  } catch (e: any) {
536
550
  this.apiError(e);
537
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}`
538
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
551
+ this.errorLog(
552
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIRefreshStatus with ${this.device.connectionType}` +
553
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
554
+ );
539
555
  }
540
556
  }
541
557
 
@@ -548,8 +564,9 @@ export class BlindTilt {
548
564
  await this.openAPIpushChanges();
549
565
  } else {
550
566
  await this.offlineOff();
551
- this.debugWarnLog(`${this.device.deviceType}: ${this.accessory.displayName} Connection Type:`
552
- + ` ${this.device.connectionType}, pushChanges will not happen.`);
567
+ this.debugWarnLog(
568
+ `${this.device.deviceType}: ${this.accessory.displayName} Connection Type:` + ` ${this.device.connectionType}, pushChanges will not happen.`,
569
+ );
553
570
  }
554
571
  // Refresh the status from the API
555
572
  interval(15000)
@@ -593,8 +610,10 @@ export class BlindTilt {
593
610
  })
594
611
  .catch(async (e: any) => {
595
612
  this.apiError(e);
596
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}`
597
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`);
613
+ this.errorLog(
614
+ `${this.device.deviceType}: ${this.accessory.displayName} failed BLEpushChanges with ${this.device.connectionType}` +
615
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
616
+ );
598
617
  await this.BLEPushConnection();
599
618
  });
600
619
  } else {
@@ -602,7 +621,8 @@ export class BlindTilt {
602
621
  await this.BLEPushConnection();
603
622
  }
604
623
  } else {
605
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges, CurrentPosition & TargetPosition Are the Same.` +
624
+ this.debugLog(
625
+ `${this.device.deviceType}: ${this.accessory.displayName} No BLEpushChanges, CurrentPosition & TargetPosition Are the Same.` +
606
626
  ` CurrentPosition: ${this.CurrentPosition}, TargetPosition ${this.TargetPosition}`,
607
627
  );
608
628
  }
@@ -630,29 +650,28 @@ export class BlindTilt {
630
650
 
631
651
  async openAPIpushChanges(): Promise<void> {
632
652
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} openAPIpushChanges`);
633
- const hasDifferentAndRelevantHorizontalTiltAngle = (
634
- this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
635
- && this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle);
636
- if ((this.TargetPosition !== this.CurrentPosition) || hasDifferentAndRelevantHorizontalTiltAngle || this.device.disableCaching) {
653
+ const hasDifferentAndRelevantHorizontalTiltAngle =
654
+ this.mappingMode === BlindTiltMappingMode.UseTiltForDirection && this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle;
655
+ if (this.TargetPosition !== this.CurrentPosition || hasDifferentAndRelevantHorizontalTiltAngle || this.device.disableCaching) {
637
656
  const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.TargetPosition), Number(this.TargetHorizontalTiltAngle));
638
657
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Pushing ${this.TargetPosition} (device = ${direction};${position})`);
639
658
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Mode: ${this.Mode}`);
640
659
  let bodyChange = '';
641
660
  if (position === 100) {
642
661
  bodyChange = JSON.stringify({
643
- 'command': 'fullyOpen',
644
- 'commandType': 'command',
662
+ command: 'fullyOpen',
663
+ commandType: 'command',
645
664
  });
646
665
  } else if (position === 0) {
647
666
  bodyChange = JSON.stringify({
648
- 'command': direction === 'up' ? 'closeUp' : 'closeDown',
649
- 'commandType': 'command',
667
+ command: direction === 'up' ? 'closeUp' : 'closeDown',
668
+ commandType: 'command',
650
669
  });
651
670
  } else {
652
671
  bodyChange = JSON.stringify({
653
- 'command': 'setPosition',
654
- 'parameter': `${direction};${position}`,
655
- 'commandType': 'command',
672
+ command: 'setPosition',
673
+ parameter: `${direction};${position}`,
674
+ commandType: 'command',
656
675
  });
657
676
  }
658
677
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Sending request to SwitchBot API, body: ${bodyChange},`);
@@ -668,14 +687,16 @@ export class BlindTilt {
668
687
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Headers: ${JSON.stringify(headers)}`);
669
688
  } catch (e: any) {
670
689
  this.apiError(e);
671
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}`
672
- + ` Connection, Error Message: ${JSON.stringify(e.message)}`,
690
+ this.errorLog(
691
+ `${this.device.deviceType}: ${this.accessory.displayName} failed openAPIpushChanges with ${this.device.connectionType}` +
692
+ ` Connection, Error Message: ${JSON.stringify(e.message)}`,
673
693
  );
674
694
  }
675
695
  } else {
676
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same.`
677
- + ` CurrentPosition: ${this.CurrentPosition}, TargetPosition ${this.TargetPosition}`
678
- + ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}, TargetPosition ${this.TargetHorizontalTiltAngle}`,
696
+ this.debugLog(
697
+ `${this.device.deviceType}: ${this.accessory.displayName} No OpenAPI Changes, CurrentPosition & TargetPosition Are the Same.` +
698
+ ` CurrentPosition: ${this.CurrentPosition}, TargetPosition ${this.TargetPosition}` +
699
+ ` CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}, TargetPosition ${this.TargetHorizontalTiltAngle}`,
679
700
  );
680
701
  }
681
702
  }
@@ -699,7 +720,6 @@ export class BlindTilt {
699
720
  this.startUpdatingBlindTiltIfNeeded();
700
721
  }
701
722
 
702
-
703
723
  /**
704
724
  * Handle requests to set the value of the "Target Position" characteristic
705
725
  */
@@ -720,21 +740,24 @@ export class BlindTilt {
720
740
  async startUpdatingBlindTiltIfNeeded(): Promise<void> {
721
741
  await this.setMinMax();
722
742
  this.debugLog('setMinMax');
723
- if (this.TargetPosition > this.CurrentPosition || (this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle)) {
743
+ if (this.TargetPosition > this.CurrentPosition || this.TargetHorizontalTiltAngle !== this.CurrentHorizontalTiltAngle) {
724
744
  this.PositionState = this.platform.Characteristic.PositionState.INCREASING;
725
745
  this.setNewTarget = true;
726
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` +
727
- ` CurrentPosition: ${this.CurrentPosition}`);
746
+ this.debugLog(
747
+ `${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` + ` CurrentPosition: ${this.CurrentPosition}`,
748
+ );
728
749
  } else if (this.TargetPosition < this.CurrentPosition) {
729
750
  this.PositionState = this.platform.Characteristic.PositionState.DECREASING;
730
751
  this.setNewTarget = true;
731
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` +
732
- ` CurrentPosition: ${this.CurrentPosition}`);
752
+ this.debugLog(
753
+ `${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` + ` CurrentPosition: ${this.CurrentPosition}`,
754
+ );
733
755
  } else {
734
756
  this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
735
757
  this.setNewTarget = false;
736
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` +
737
- ` CurrentPosition: ${this.CurrentPosition}`);
758
+ this.debugLog(
759
+ `${this.device.deviceType}: ${this.accessory.displayName} value: ${this.CurrentPosition},` + ` CurrentPosition: ${this.CurrentPosition}`,
760
+ );
738
761
  }
739
762
  this.windowCoveringService.setCharacteristic(this.platform.Characteristic.PositionState, this.PositionState);
740
763
  this.windowCoveringService.getCharacteristic(this.platform.Characteristic.PositionState).updateValue(this.PositionState);
@@ -765,8 +788,10 @@ export class BlindTilt {
765
788
  this.mqttPublish('CurrentHorizontalTiltAngle', this.CurrentHorizontalTiltAngle);
766
789
  }
767
790
  this.accessory.context.CurrentHorizontalTiltAngle = this.CurrentHorizontalTiltAngle;
768
- this.windowCoveringService.updateCharacteristic(this.platform.Characteristic.CurrentHorizontalTiltAngle,
769
- Number(this.CurrentHorizontalTiltAngle));
791
+ this.windowCoveringService.updateCharacteristic(
792
+ this.platform.Characteristic.CurrentHorizontalTiltAngle,
793
+ Number(this.CurrentHorizontalTiltAngle),
794
+ );
770
795
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}
771
796
  updateCharacteristic CurrentHorizontalTiltAngle: ${this.CurrentHorizontalTiltAngle}`);
772
797
  }
@@ -811,8 +836,10 @@ export class BlindTilt {
811
836
  }
812
837
  this.accessory.context.CurrentAmbientLightLevel = this.CurrentAmbientLightLevel;
813
838
  this.lightSensorService?.updateCharacteristic(this.platform.Characteristic.CurrentAmbientLightLevel, this.CurrentAmbientLightLevel);
814
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
815
- + ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`);
839
+ this.debugLog(
840
+ `${this.device.deviceType}: ${this.accessory.displayName}` +
841
+ ` updateCharacteristic CurrentAmbientLightLevel: ${this.CurrentAmbientLightLevel}`,
842
+ );
816
843
  }
817
844
  }
818
845
  if (this.BLE) {
@@ -983,8 +1010,10 @@ export class BlindTilt {
983
1010
  if (this.updateRate > device.scanDuration) {
984
1011
  this.scanDuration = this.updateRate;
985
1012
  if (this.BLE) {
986
- this.warnLog(`${this.device.deviceType}: `
987
- + `${this.accessory.displayName} scanDuration is less than updateRate, overriding scanDuration with updateRate`);
1013
+ this.warnLog(
1014
+ `${this.device.deviceType}: ` +
1015
+ `${this.accessory.displayName} scanDuration is less than updateRate, overriding scanDuration with updateRate`,
1016
+ );
988
1017
  }
989
1018
  } else {
990
1019
  this.scanDuration = this.accessory.context.scanDuration = device.scanDuration;
@@ -1020,8 +1049,10 @@ export class BlindTilt {
1020
1049
  this.offlineOff();
1021
1050
  break;
1022
1051
  case 171:
1023
- this.errorLog(`${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. `
1024
- + `Hub: ${this.device.hubDeviceId}`);
1052
+ this.errorLog(
1053
+ `${this.device.deviceType}: ${this.accessory.displayName} Hub Device is offline, statusCode: ${statusCode}. ` +
1054
+ `Hub: ${this.device.hubDeviceId}`,
1055
+ );
1025
1056
  this.offlineOff();
1026
1057
  break;
1027
1058
  case 190:
@@ -1037,8 +1068,10 @@ export class BlindTilt {
1037
1068
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} Request successful, statusCode: ${statusCode}`);
1038
1069
  break;
1039
1070
  default:
1040
- this.infoLog(`${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: `
1041
- + `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`);
1071
+ this.infoLog(
1072
+ `${this.device.deviceType}: ${this.accessory.displayName} Unknown statusCode: ` +
1073
+ `${statusCode}, Submit Bugs Here: ' + 'https://tinyurl.com/SwitchBotBug`,
1074
+ );
1042
1075
  }
1043
1076
  }
1044
1077
 
@@ -1065,8 +1098,9 @@ export class BlindTilt {
1065
1098
 
1066
1099
  FirmwareRevision(accessory: PlatformAccessory<Context>, device: device & devicesConfig): CharacteristicValue {
1067
1100
  let FirmwareRevision: string;
1068
- this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName}`
1069
- + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`);
1101
+ this.debugLog(
1102
+ `${this.device.deviceType}: ${this.accessory.displayName}` + ` accessory.context.FirmwareRevision: ${accessory.context.FirmwareRevision}`,
1103
+ );
1070
1104
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} device.firmware: ${device.firmware}`);
1071
1105
  this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} this.platform.version: ${this.platform.version}`);
1072
1106
  if (accessory.context.FirmwareRevision) {
@@ -1342,4 +1376,4 @@ export class BlindTilt {
1342
1376
  enablingDeviceLogging(): boolean {
1343
1377
  return this.deviceLogging.includes('debug') || this.deviceLogging === 'standard';
1344
1378
  }
1345
- }
1379
+ }