@switchbot/homebridge-switchbot 2.8.0-beta.0 → 2.8.0-beta.2
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.
- package/.prettierrc +1 -1
- package/.vscode/settings.json +1 -1
- package/CHANGELOG.md +10 -0
- package/config.schema.json +8 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +49 -59
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +44 -50
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +60 -63
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +68 -70
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +22 -25
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +50 -58
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/hub.d.ts +6 -0
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +168 -26
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +49 -56
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +18 -20
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +59 -61
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +40 -41
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +3 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +65 -68
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +18 -20
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +20 -23
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +30 -33
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +48 -51
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +58 -62
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +29 -31
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +17 -20
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +27 -29
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +23 -26
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +19 -20
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +44 -47
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +17 -20
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +19 -20
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +44 -43
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/device/blindtilt.ts +106 -72
- package/src/device/bot.ts +94 -58
- package/src/device/ceilinglight.ts +102 -68
- package/src/device/colorbulb.ts +134 -82
- package/src/device/contact.ts +54 -33
- package/src/device/curtain.ts +130 -101
- package/src/device/hub.ts +198 -35
- package/src/device/humidifier.ts +128 -80
- package/src/device/iosensor.ts +43 -27
- package/src/device/lightstrip.ts +108 -67
- package/src/device/lock.ts +73 -45
- package/src/device/meter.ts +94 -75
- package/src/device/meterplus.ts +43 -27
- package/src/device/motion.ts +50 -32
- package/src/device/plug.ts +62 -39
- package/src/device/robotvacuumcleaner.ts +78 -54
- package/src/irdevice/airconditioner.ts +112 -84
- package/src/irdevice/airpurifier.ts +55 -34
- package/src/irdevice/camera.ts +35 -23
- package/src/irdevice/fan.ts +47 -33
- package/src/irdevice/light.ts +43 -29
- package/src/irdevice/other.ts +39 -23
- package/src/irdevice/tv.ts +65 -51
- package/src/irdevice/vacuumcleaner.ts +35 -23
- package/src/irdevice/waterheater.ts +43 -27
- package/src/platform.ts +85 -55
- package/src/settings.ts +41 -40
- package/src/utils.ts +1 -1
package/src/device/blindtilt.ts
CHANGED
|
@@ -80,10 +80,14 @@ export class BlindTilt {
|
|
|
80
80
|
doBlindTiltUpdate!: Subject<void>;
|
|
81
81
|
|
|
82
82
|
// Connection
|
|
83
|
-
private readonly BLE =
|
|
84
|
-
private readonly OpenAPI =
|
|
85
|
-
|
|
86
|
-
constructor(
|
|
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(
|
|
240
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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 &&
|
|
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(
|
|
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(
|
|
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(
|
|
449
|
-
|
|
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(
|
|
475
|
-
|
|
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(
|
|
507
|
-
|
|
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(
|
|
538
|
-
|
|
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(
|
|
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(
|
|
597
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
644
|
-
|
|
662
|
+
command: 'fullyOpen',
|
|
663
|
+
commandType: 'command',
|
|
645
664
|
});
|
|
646
665
|
} else if (position === 0) {
|
|
647
666
|
bodyChange = JSON.stringify({
|
|
648
|
-
|
|
649
|
-
|
|
667
|
+
command: direction === 'up' ? 'closeUp' : 'closeDown',
|
|
668
|
+
commandType: 'command',
|
|
650
669
|
});
|
|
651
670
|
} else {
|
|
652
671
|
bodyChange = JSON.stringify({
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
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(
|
|
672
|
-
|
|
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(
|
|
677
|
-
|
|
678
|
-
|
|
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 ||
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
769
|
-
|
|
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(
|
|
815
|
-
|
|
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(
|
|
987
|
-
|
|
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(
|
|
1024
|
-
|
|
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(
|
|
1041
|
-
|
|
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(
|
|
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
|
+
}
|