Working on README

This commit is contained in:
Serge Wagener
2022-02-15 11:30:45 +01:00
parent 60545b2909
commit 3248262e7a
3 changed files with 104 additions and 26 deletions
+11
View File
@@ -118,17 +118,28 @@ export class WindowCovering implements AccessoryPlugin {
}
updateDirection() {
let direction;
if (this.targetPosition < this.currentPosition) {
direction = 'DECREASING';
this.positionState = this.platform.Characteristic.PositionState.DECREASING;
} else if (this.targetPosition > this.currentPosition) {
direction = 'INCREASING';
this.positionState = this.platform.Characteristic.PositionState.INCREASING;
} else {
direction = 'STOPPED';
this.positionState = this.platform.Characteristic.PositionState.STOPPED;
}
this.platform.log.debug(
'updateDirection for', this.accessory.name,
': current =', this.currentPosition,
'target =', this.targetPosition,
'direction:', direction,
);
}
convertRange(value: number, oldmin: number, oldmax: number, newmin: number, newmax: number, inverted: boolean): number {
let result = (((value - oldmin) * (newmax - newmin)) / (oldmax - oldmin)) + newmin;
result = Math.round(result);
if (inverted) {
result = newmax - result;
}