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

111
README.md
View File

@ -3,19 +3,22 @@
**Version v2 is a complete rewrite from scratch and a breaking update.** **Version v2 is a complete rewrite from scratch and a breaking update.**
You need to adapt your `config.json` ! You need to adapt your `config.json` !
## Currently supported ## Currently supported accessories
This plugin currently supports the following services (and characteristics): This plugin currently supports the following services (and characteristics):
* LightBulb (on/off, brightness, hue, saturation, r, g, b, w) | Type | Description |
* Fan (active) |:----------------------------------------|:--------------------------------------------------------|
* TemperatureSensor (current temperature) | ContactSensor | Simple contact sensor, for example for windows |
* Thermostat (current- / target temperature, currentheatingcoolingstate) | [Doorbell](#doorbell) | Doorbell, sends message to devices on ring |
* MotionSensor (motion detected) | [Fan](#fan) | Simple on/off fan, may be extended in future |
* OccupancySensor (presence detected) | [Lightbulb](#lightbulb) | Everything, from simple light to dimmable, RGB and RGBW |
* ContactSensor (contact state) | [MotionSensor](#motionsensor) | Detects and reports motion |
* Switch (on/off) | [OccupancySensor](#occupancysensor) | Detects presence in a room |
* Outlet (on/off) | [Outlet](#outlet) | Simple on/off wall outlet |
* WindowCovering (CurrentPosition, TargetPosition). | [TemperatureSensor](#temperaturesensor) | Temperature sensor |
| [Thermostat](#thermostat) | Thermostat with temperature sensor and heating state |
| [Switch](#switch) | Simple on/off switch |
| [WindowCovering](#windowcovering) | Window covering (shutters, blinds, ...) |
Other accessories are being worked on and will be added as soon as ready. Other accessories are being worked on and will be added as soon as ready.
@ -62,38 +65,100 @@ The following parameters are available to configure the plugin as platform in ho
If the `port` and `tls` parameters are not specified the plugin defaults to port 2424 without tls encryption. If the `port` and `tls` parameters are not specified the plugin defaults to port 2424 without tls encryption.
### Common accessories characteristics ### Common accessories characteristics
The following characteristics are valid for all accessories. The following characteristics are valid for all accessories:
Mandatory: | Parameter | Possible values | Mandatory | Description |
|:-------------|:----------------------------------------------|:----------|:--------------------------------|
| type | <type> from the above list of supported types | Yes | Type of accessory |
| name | Any \<string> | Yes | Visible name in HomeKit |
| manufacturer | Any \<string> | No | Visible manufacturer in HomeKit |
| model | Any \<string> | No | Visible model in HomeKit |
#### Example:
```json ```json
{ {
"type": "OccupancySensor", "type": "OccupancySensor",
"name": "Presence kitchen", "name": "Presence kitchen",
}
```
Optional:
```json
{
"manufacturer": "Preussen", "manufacturer": "Preussen",
"model": "Motion 360 KNX", "model": "Motion 360 KNX",
} }
``` ```
### Doorbell ### Doorbell
*TODO* A doorbell is an accessory that simply sends a message to all devices enrolled in the home that someone rang the doorbell.
HomeKit displays a message that "This accessory is not currently supported by the Home app.".
Further investigation is needed, but for now it still works.
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
| Parameter | Possible values | Mandatory | Description |
|:-------------|:----------------|:----------|:---------------------------------------|
| SinglePress | <item> | Yes | SHNG item to monitor for doorbell ring |
#### Example:
```json
{
"type": "Doorbell",
"name": "Main door",
"SinglePress": "Technik.Asterisk.Klingel"
}
```
### Fan ### Fan
*TODO* For now this accessory only supports turning the fan on and off. Further improvements are possible, but i don't have the needed hardware for testing.
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
| Parameter | Possible values | Mandatory | Description |
|:----------|:----------------|:----------|:---------------------------------------|
| Active | <item> | Yes | SHNG item to set and get the fan state |
#### Example:
```json
{
"type": "Fan",
"name": "Fan bathroom",
"Active": "OG.Bad.Ventilator"
}
```
### LightBulb ### LightBulb
*TODO* *TODO*
### Occupancy sensor ### Occupancy sensor
*TODO* This sensor is tripped if it detects presence in a room.
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
| Parameter | Possible values | Mandatory | Description |
|:------------------|:----------------|:----------|:----------------------------------|
| OccupancyDetected | <item> | Yes | SHNG item to monitor for presence |
#### Example:
```json
{
"type": "OccupancySensor",
"name": "Presence bathroom",
"manufacturer": "Preussen",
"model": "Motion 360 KNX",
"OccupancyDetected": "OG.Bad.Praesenz"
}
```
### Motion sensor ### Motion sensor
*TODO* This sensor is tripped if it detects motion in a room.
#### Characteristics in addition to [common characteristics](#common-accessories-characteristics)
| Parameter | Possible values | Mandatory | Description |
|:---------------|:----------------|:----------|:--------------------------------|
| MotionDetected | <item> | Yes | SHNG item to monitor for motion |
#### Example:
```json
{
"type": "OccupancySensor",
"name": "Presence bathroom",
"OccupancyDetected": "EG.Flur.Bewegung"
}
```
### Contact sensor ### Contact sensor
*TODO* *TODO*

View File

@ -118,17 +118,28 @@ export class WindowCovering implements AccessoryPlugin {
} }
updateDirection() { updateDirection() {
let direction;
if (this.targetPosition < this.currentPosition) { if (this.targetPosition < this.currentPosition) {
direction = 'DECREASING';
this.positionState = this.platform.Characteristic.PositionState.DECREASING; this.positionState = this.platform.Characteristic.PositionState.DECREASING;
} else if (this.targetPosition > this.currentPosition) { } else if (this.targetPosition > this.currentPosition) {
direction = 'INCREASING';
this.positionState = this.platform.Characteristic.PositionState.INCREASING; this.positionState = this.platform.Characteristic.PositionState.INCREASING;
} else { } else {
direction = 'STOPPED';
this.positionState = this.platform.Characteristic.PositionState.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 { convertRange(value: number, oldmin: number, oldmax: number, newmin: number, newmax: number, inverted: boolean): number {
let result = (((value - oldmin) * (newmax - newmin)) / (oldmax - oldmin)) + newmin; let result = (((value - oldmin) * (newmax - newmin)) / (oldmax - oldmin)) + newmin;
result = Math.round(result);
if (inverted) { if (inverted) {
result = newmax - result; result = newmax - result;
} }

View File

@ -1,12 +1,13 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2018", // ~node10 "target": "ES2019",
"module": "commonjs", "module": "commonjs",
"lib": [ "lib": [
"es2015", "es2015",
"es2016", "es2016",
"es2017", "es2017",
"es2018" "es2018",
"es2019"
], ],
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
@ -22,6 +23,7 @@
"src/Accessories/.ts" "src/Accessories/.ts"
], ],
"exclude": [ "exclude": [
"**/*.spec.ts" "**/*.spec.ts",
"node_modules"
] ]
} }