From 3248262e7aaef18cff8643b1ab28f235b0ad2773 Mon Sep 17 00:00:00 2001 From: Serge Wagener Date: Tue, 15 Feb 2022 11:30:45 +0100 Subject: [PATCH] Working on README --- README.md | 111 +++++++++++++++++++++++------- src/Accessories/WindowCovering.ts | 11 +++ tsconfig.json | 8 ++- 3 files changed, 104 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 15572ae..df63696 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,22 @@ **Version v2 is a complete rewrite from scratch and a breaking update.** You need to adapt your `config.json` ! -## Currently supported +## Currently supported accessories This plugin currently supports the following services (and characteristics): -* LightBulb (on/off, brightness, hue, saturation, r, g, b, w) -* Fan (active) -* TemperatureSensor (current temperature) -* Thermostat (current- / target temperature, currentheatingcoolingstate) -* MotionSensor (motion detected) -* OccupancySensor (presence detected) -* ContactSensor (contact state) -* Switch (on/off) -* Outlet (on/off) -* WindowCovering (CurrentPosition, TargetPosition). +| Type | Description | +|:----------------------------------------|:--------------------------------------------------------| +| ContactSensor | Simple contact sensor, for example for windows | +| [Doorbell](#doorbell) | Doorbell, sends message to devices on ring | +| [Fan](#fan) | Simple on/off fan, may be extended in future | +| [Lightbulb](#lightbulb) | Everything, from simple light to dimmable, RGB and RGBW | +| [MotionSensor](#motionsensor) | Detects and reports motion | +| [OccupancySensor](#occupancysensor) | Detects presence in a room | +| [Outlet](#outlet) | Simple on/off wall outlet | +| [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. @@ -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. ### 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 | from the above list of supported types | Yes | Type of accessory | +| name | Any \ | Yes | Visible name in HomeKit | +| manufacturer | Any \ | No | Visible manufacturer in HomeKit | +| model | Any \ | No | Visible model in HomeKit | +#### Example: ```json { "type": "OccupancySensor", "name": "Presence kitchen", -} -``` - -Optional: -```json -{ "manufacturer": "Preussen", "model": "Motion 360 KNX", } ``` ### 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 | | Yes | SHNG item to monitor for doorbell ring | + +#### Example: +```json +{ + "type": "Doorbell", + "name": "Main door", + "SinglePress": "Technik.Asterisk.Klingel" +} +``` ### 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 | | Yes | SHNG item to set and get the fan state | + +#### Example: + +```json +{ + "type": "Fan", + "name": "Fan bathroom", + "Active": "OG.Bad.Ventilator" +} +``` ### LightBulb *TODO* ### 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 | | 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 -*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 | | Yes | SHNG item to monitor for motion | + + +#### Example: +```json +{ + "type": "OccupancySensor", + "name": "Presence bathroom", + "OccupancyDetected": "EG.Flur.Bewegung" +} +``` ### Contact sensor *TODO* diff --git a/src/Accessories/WindowCovering.ts b/src/Accessories/WindowCovering.ts index d9389bf..ad690d3 100644 --- a/src/Accessories/WindowCovering.ts +++ b/src/Accessories/WindowCovering.ts @@ -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; } diff --git a/tsconfig.json b/tsconfig.json index 5eba9c1..b6ca3f7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "ES2018", // ~node10 + "target": "ES2019", "module": "commonjs", "lib": [ "es2015", "es2016", "es2017", - "es2018" + "es2018", + "es2019" ], "declaration": true, "declarationMap": true, @@ -22,6 +23,7 @@ "src/Accessories/.ts" ], "exclude": [ - "**/*.spec.ts" + "**/*.spec.ts", + "node_modules" ] } \ No newline at end of file