Compare commits
No commits in common. "master" and "v2.0.6" have entirely different histories.
@ -1,12 +1,14 @@
|
|||||||
# homebridge-smarthomeng
|
# homebridge-smarthomeng
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
||||||
[](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
|
|
||||||
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
||||||
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
||||||
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
||||||
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
[](https://www.npmjs.com/package/homebridge-smarthomeng)
|
||||||
|
|
||||||
|
**Version v2 is a complete rewrite from scratch and a breaking update.**
|
||||||
|
You need to adapt your [`config.json`](#example-configuration-file) !
|
||||||
|
|
||||||
## Currently supported accessories
|
## Currently supported accessories
|
||||||
This plugin currently supports the following services (and characteristics):
|
This plugin currently supports the following services (and characteristics):
|
||||||
|
|
||||||
@ -404,11 +406,9 @@ This accessory type can be used for shutters or blinds. Because the differnce be
|
|||||||
| TargetPosition | \<item> | Yes | | SHNG item to monitor and set the target position |
|
| TargetPosition | \<item> | Yes | | SHNG item to monitor and set the target position |
|
||||||
| CurrentPositionMin | \<number> | No | 0 | Your device's minimum value for current position |
|
| CurrentPositionMin | \<number> | No | 0 | Your device's minimum value for current position |
|
||||||
| CurrentPositionMax | \<number> | No | 100 | Your device's maximum value for current position |
|
| CurrentPositionMax | \<number> | No | 100 | Your device's maximum value for current position |
|
||||||
| CurrentPositionDecimals | \<number> | No | 0 | Number of decimals to round to |
|
|
||||||
| CurrentPositionInverted | \<boolean> | No | false | Should the values be inverted, ex: 0 for Homekit = 100 for device |
|
| CurrentPositionInverted | \<boolean> | No | false | Should the values be inverted, ex: 0 for Homekit = 100 for device |
|
||||||
| TargetPositionMin | \<number> | No | 0 | Your device's minimum value for target position |
|
| TargetPositionMin | \<number> | No | 0 | Your device's minimum value for target position |
|
||||||
| TargetPositionMax | \<number> | No | 100 | Your device's maximum value for target position |
|
| TargetPositionMax | \<number> | No | 100 | Your device's maximum value for target position |
|
||||||
| TargetPositionDecimals | \<number> | No | 0 | Number of decimals to round to |
|
|
||||||
| TargetPositionInverted | \<boolean> | No | false | Should the values be inverted, ex: 0 for Homekit = 100 for device |
|
| TargetPositionInverted | \<boolean> | No | false | Should the values be inverted, ex: 0 for Homekit = 100 for device |
|
||||||
| CurrentHorizontalTiltAngle | \<item> | No | | SHNG item to monitor current horizontal tilt angle |
|
| CurrentHorizontalTiltAngle | \<item> | No | | SHNG item to monitor current horizontal tilt angle |
|
||||||
| TargetHorizontalTiltAngle | \<item> | No | | SHNG item to monitor and set the target horizontal tilt angle |
|
| TargetHorizontalTiltAngle | \<item> | No | | SHNG item to monitor and set the target horizontal tilt angle |
|
||||||
|
|||||||
4046
package-lock.json
generated
4046
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -2,7 +2,7 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"displayName": "SmartHomeNG",
|
"displayName": "SmartHomeNG",
|
||||||
"name": "homebridge-smarthomeng",
|
"name": "homebridge-smarthomeng",
|
||||||
"version": "2.0.8",
|
"version": "2.0.6",
|
||||||
"description": "SmartHomeNG plugin for Homebridge",
|
"description": "SmartHomeNG plugin for Homebridge",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -27,17 +27,17 @@
|
|||||||
"homebridge-plugin"
|
"homebridge-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ws": "^8.12.1"
|
"ws": "^8.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.13.0",
|
"@types/node": "^16.10.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
"@typescript-eslint/parser": "^5.52.0",
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
"eslint": "^8.34.0",
|
"eslint": "^8.0.1",
|
||||||
"homebridge": "^1.6.0",
|
"homebridge": "^1.3.5",
|
||||||
"nodemon": "^2.0.20",
|
"nodemon": "^2.0.13",
|
||||||
"rimraf": "^4.1.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.3.0",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,8 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
private readonly informationService: Service;
|
private readonly informationService: Service;
|
||||||
|
|
||||||
public name: string;
|
public name: string;
|
||||||
private currentPosition = 0; private currentPositionMin = 0; private currentPositionMax = 100;
|
private currentPosition = 0; private currentPositionMin = 0; private currentPositionMax = 100; private currentPositionInverted = false;
|
||||||
private currentPositionDecimals = 0; private currentPositionInverted = false;
|
private targetPosition = 0; private targetPositionMin = 0; private targetPositionMax = 100; private targetPositionInverted = false;
|
||||||
private targetPosition = 0; private targetPositionMin = 0; private targetPositionMax = 100;
|
|
||||||
private targetPositionDecimals = 0; private targetPositionInverted = false;
|
|
||||||
private positionState = this.platform.Characteristic.PositionState.STOPPED;
|
private positionState = this.platform.Characteristic.PositionState.STOPPED;
|
||||||
private currentHorizontalTiltAngle = 0; private targetHorizontalTiltAngle = 0;
|
private currentHorizontalTiltAngle = 0; private targetHorizontalTiltAngle = 0;
|
||||||
private currentVerticalTiltAngle = 0; private targetVerticalTiltAngle = 0;
|
private currentVerticalTiltAngle = 0; private targetVerticalTiltAngle = 0;
|
||||||
@ -72,11 +70,9 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
|
|
||||||
this.currentPositionMax = accessory.currentpositionmax ? accessory.currentpositionmax : this.currentPositionMax;
|
this.currentPositionMax = accessory.currentpositionmax ? accessory.currentpositionmax : this.currentPositionMax;
|
||||||
this.currentPositionMin = accessory.currentpositionmin ? accessory.currentpositionmin : this.currentPositionMin;
|
this.currentPositionMin = accessory.currentpositionmin ? accessory.currentpositionmin : this.currentPositionMin;
|
||||||
this.currentPositionDecimals = accessory.currentpositiondecimals ? accessory.currentpositiondecimals : this.currentPositionDecimals;
|
|
||||||
this.currentPositionInverted = accessory.currentpositioninverted ? accessory.currentpositioninverted : this.currentPositionInverted;
|
this.currentPositionInverted = accessory.currentpositioninverted ? accessory.currentpositioninverted : this.currentPositionInverted;
|
||||||
this.targetPositionMax = accessory.targetpositionmax ? accessory.targetpositionmax : this.targetPositionMax;
|
this.targetPositionMax = accessory.targetpositionmax ? accessory.targetpositionmax : this.targetPositionMax;
|
||||||
this.targetPositionMin = accessory.targetpositionmin ? accessory.targetpositionmin : this.targetPositionMin;
|
this.targetPositionMin = accessory.targetpositionmin ? accessory.targetpositionmin : this.targetPositionMin;
|
||||||
this.targetPositionDecimals = accessory.targetpositiondecimals ? accessory.targetpositiondecimals : this.targetPositionDecimals;
|
|
||||||
this.targetPositionInverted = accessory.targetpositioninverted ? accessory.targetpositioninverted : this.targetPositionInverted;
|
this.targetPositionInverted = accessory.targetpositioninverted ? accessory.targetpositioninverted : this.targetPositionInverted;
|
||||||
this.platform.log.info("WindowCovering '%s' created!", accessory.name);
|
this.platform.log.info("WindowCovering '%s' created!", accessory.name);
|
||||||
}
|
}
|
||||||
@ -111,7 +107,7 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
value as number,
|
value as number,
|
||||||
0, 100,
|
0, 100,
|
||||||
this.targetPositionMin, this.targetPositionMax,
|
this.targetPositionMin, this.targetPositionMax,
|
||||||
this.targetPositionDecimals, this.targetPositionInverted,
|
this.targetPositionInverted,
|
||||||
);
|
);
|
||||||
this.platform.shng.setItem(this.accessory.targetposition, transposedTarget);
|
this.platform.shng.setItem(this.accessory.targetposition, transposedTarget);
|
||||||
}
|
}
|
||||||
@ -156,7 +152,7 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
value as number,
|
value as number,
|
||||||
this.currentPositionMin, this.currentPositionMax,
|
this.currentPositionMin, this.currentPositionMax,
|
||||||
0, 100,
|
0, 100,
|
||||||
0, this.currentPositionInverted,
|
this.currentPositionInverted,
|
||||||
);
|
);
|
||||||
this.deviceService.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.currentPosition);
|
this.deviceService.updateCharacteristic(this.platform.Characteristic.CurrentPosition, this.currentPosition);
|
||||||
} else {
|
} else {
|
||||||
@ -173,7 +169,7 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
value as number,
|
value as number,
|
||||||
this.targetPositionMin, this.targetPositionMax,
|
this.targetPositionMin, this.targetPositionMax,
|
||||||
0, 100,
|
0, 100,
|
||||||
0, this.targetPositionInverted,
|
this.targetPositionInverted,
|
||||||
);
|
);
|
||||||
this.deviceService.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
this.deviceService.updateCharacteristic(this.platform.Characteristic.TargetPosition, this.targetPosition);
|
||||||
} else {
|
} else {
|
||||||
@ -239,14 +235,9 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
convertRange(value: number, oldmin: number, oldmax: number, newmin: number, newmax: number, inverted: boolean): number {
|
||||||
convertRange(value: number, oldmin: number, oldmax: number, newmin: number, newmax: number, decimals: number, inverted: boolean): number {
|
|
||||||
let result = (((value - oldmin) * (newmax - newmin)) / (oldmax - oldmin)) + newmin;
|
let result = (((value - oldmin) * (newmax - newmin)) / (oldmax - oldmin)) + newmin;
|
||||||
if(decimals > 0) {
|
result = Math.round(result);
|
||||||
result = parseFloat(result.toFixed(decimals));
|
|
||||||
} else {
|
|
||||||
result = Math.round(result);
|
|
||||||
}
|
|
||||||
if (inverted) {
|
if (inverted) {
|
||||||
result = newmax - result;
|
result = newmax - result;
|
||||||
}
|
}
|
||||||
@ -255,7 +246,6 @@ export class WindowCovering implements AccessoryPlugin {
|
|||||||
'from range', oldmin, '-', oldmax,
|
'from range', oldmin, '-', oldmax,
|
||||||
'to', newmin, '-', newmax,
|
'to', newmin, '-', newmax,
|
||||||
'with inverted', inverted,
|
'with inverted', inverted,
|
||||||
'and', decimals, 'decimals',
|
|
||||||
'=', result,
|
'=', result,
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user