From abe95f516f696d2a44cb9fbcc3acbb26c707cd91 Mon Sep 17 00:00:00 2001 From: Chester Date: Mon, 7 Mar 2022 16:30:32 +0100 Subject: [PATCH 1/6] added garagedoor --- src/Accessories/GarageDoor.ts | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/Accessories/GarageDoor.ts diff --git a/src/Accessories/GarageDoor.ts b/src/Accessories/GarageDoor.ts new file mode 100644 index 0000000..c45811b --- /dev/null +++ b/src/Accessories/GarageDoor.ts @@ -0,0 +1,96 @@ +import { + AccessoryPlugin, + CharacteristicValue, + Service, + Nullable, +} from 'homebridge'; + +import { SmartHomeNGPlatform } from '../platform'; + +export class GarageDoor implements AccessoryPlugin { + private readonly deviceService: Service; + private readonly informationService: Service; + + public name: string; + //private currentPosition = 0; private currentPositionMin = 0; private currentPositionMax = 100; private currentPositionInverted = false; + //private = this.platform.Characteristic.PositionState.STOPPED; + private targetDoorState = this.platform.Characteristic.CurrentDoorState.CLOSED; + private currentDoorState = this.platform.Characteristic.CurrentDoorState.STOPPED; + + constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) { + this.name = accessory.name; + this.deviceService = new this.platform.Service.GarageDoorOpener(accessory.name); + + // create handlers for required characteristics + this.deviceService.getCharacteristic(this.platform.Characteristic.CurrentDoorState) + .onGet(this.getCurrentDoorState.bind(this)) + .onSet(this.setCurrentDoorState.bind(this)); + + this.deviceService.getCharacteristic(this.platform.Characteristic.TargetDoorState) + .onGet(this.getTargetDoorState.bind(this)) + .onSet(this.setTargetDoorState.bind(this)); + + this.informationService = + new this.platform.Service.AccessoryInformation() + .setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer) + .setCharacteristic(this.platform.Characteristic.Model, accessory.model) + .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.currentdoorstate); // FIXME + + this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this)); + this.platform.shng.addMonitor(accessory.targetdoorstate, this.shngTargetDoorStateCallback.bind(this)); +/* + if (accessory.obstructiondetected) { + this.platform.shng.addMonitor(accessory.obstructiondetected, this.shngObstructionDetectedCallback.bind(this)); + } +*/ + this.platform.log.info("GarageDoor '%s' created!", accessory.name); + } + + identify(): void { + this.platform.log.info('Identify!'); + } + + getServices(): Service[] { + return [this.informationService, this.deviceService]; + } + + getCurrentDoorState(): Nullable { + this.platform.log.info('getCurrentDoorState:', this.accessory.name, 'is currently', this.currentDoorState); + return this.currentDoorState; + } + + setCurrentDoorState(value: CharacteristicValue) { + this.currentDoorState = value as number; + this.platform.log.info('setCurrentDoorState:', this.accessory.name, 'was set to', this.currentDoorState); + this.platform.shng.setItem(this.accessory.currentDoorState, this.currentDoorState); + } + + getTargetDoorState(): Nullable { + this.platform.log.info('getTargetDoorState:', this.accessory.name, 'is currently', this.targetDoorState); + return this.targetDoorState; + } + + setTargetDoorState(value: CharacteristicValue) { + this.targetDoorState = value as number; + this.platform.log.info('setTargetDoorState:', this.accessory.name, 'was set to', this.targetDoorState); + this.platform.shng.setItem(this.accessory.targetDoorState, this.targetDoorState); + } + + shngCurrentDoorStateCallback(value: unknown): void { + this.platform.log.debug('shngCurrentDoorStateCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); + if (typeof value === 'number') { + this.currentDoorState = value; + } else { + this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value); + } + } + + shngTargetDoorStateCallback(value: unknown): void { + this.platform.log.debug('shngTargetDoorStateCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); + if (typeof value === 'number') { + this.targetDoorState = value; + } else { + this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value); + } + } +} From 77df0609ca2bd9d3da9011e8d052c64f5e97ff99 Mon Sep 17 00:00:00 2001 From: Chester Date: Mon, 7 Mar 2022 16:44:43 +0100 Subject: [PATCH 2/6] garage door added --- package-lock.json | 4 ++-- src/Accessories/VideoDoorbell.ts | 2 +- src/platform.ts | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 71e0321..fb9c9d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-smarthomeng", - "version": "2.0.0", + "version": "2.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "homebridge-smarthomeng", - "version": "2.0.0", + "version": "2.0.4", "license": "Apache-2.0", "dependencies": { "ws": "^8.4.2" diff --git a/src/Accessories/VideoDoorbell.ts b/src/Accessories/VideoDoorbell.ts index 915081c..7f00bc7 100644 --- a/src/Accessories/VideoDoorbell.ts +++ b/src/Accessories/VideoDoorbell.ts @@ -29,7 +29,7 @@ export class Doorbell implements AccessoryPlugin { .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.singlepress); this.platform.shng.addMonitor(accessory.contactstate, this.shngCallback.bind(this)); - this.platform.log.info('ContactSensor', accessory.name, 'created!'); + this.platform.log.info('Doorbell', accessory.name, 'created!'); } identify(): void { diff --git a/src/platform.ts b/src/platform.ts index a290853..43157c7 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -21,6 +21,7 @@ import { Doorbell } from './Accessories/Doorbell'; import { SecuritySystem } from './Accessories/SecuritySystem'; import { OccupancySensor } from './Accessories/OccupancySensor'; import { MotionSensor } from './Accessories/MotionSensor'; +import { GarageDoor } from './Accessories/GarageDoor'; function uncapitalizeKeys(obj): Record { function isObject(o: unknown): boolean { @@ -146,6 +147,11 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin { devices.push(new WindowCovering(this, accessory)); break; + // GarageDoor + case 'garagedoor': + devices.push(new GarageDoor(this, accessory)); + break; + // Show error for (yet ?) unsupported device default: this.log.warn('Accessory type', accessory.type, 'for', accessory.name, 'not recognized !'); From 6b46c9cdb8c19ab4df744ab0d65c680686b18733 Mon Sep 17 00:00:00 2001 From: Chester Date: Mon, 7 Mar 2022 17:11:36 +0100 Subject: [PATCH 3/6] Added garage door description --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 2917cbd..d7f9994 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ This plugin currently supports the following services (and characteristics): | [TemperatureSensor](#temperature-sensor) | Temperature sensor | | [Thermostat](#thermostat) | Thermostat with temperature sensor and heating state | | [WindowCovering](#window-covering) | Window covering (shutters, blinds, ...) | +| [GarageDoor](#garage-door) | Garage door opener | Other accessories are being worked on and will be added as soon as ready. @@ -399,6 +400,32 @@ The above optional parameters allow you to specify the neede range for your devi } ``` +### Garage Door +This accessory type can be used for opening/closing garage doors or any automatic gates. + +#### Characteristics in addition to [common characteristics](#common-accessories-characteristics) +| Parameter | Possible values | Mandatory | Default | Description | +|:---------------------------|:----------------|:----------|:--------|:------------------------------------------------------------------| +| CurrentDoorState | \ | Yes | | SHNG item to monitor the current door state | +| TargetDoorState | \ | Yes | | SHNG item to monitor and set the target position | +| ObstructionDetected | \ | No | | SHNG item to monitor if the door is blocked | + +#### Additional comments + +CurrentDoorState can be OPEN, CLOSED, OPENING, CLOSING and STOPPED. TargetDoorState can be OPEN or CLOSED. +ObstructionDetected can be set to true if there is a physical problem opening/closing the door. + +#### Example +```json +{ + "type": "GarageDoor", + "name": "GarageRechts", + "currentdoorstate": "garage.rechts.cds", + "targetdoorstate": "garage.rechts.tds", + "obstructiondetected": "garage.rechts.od" +} +``` + ### Example configuration file This is an example config file which just uses this plugin and some example SmartHomeNG items. From 6f373379aedff159dc9dbd0003fe1cc959e5580c Mon Sep 17 00:00:00 2001 From: Chester Date: Mon, 7 Mar 2022 21:12:55 +0100 Subject: [PATCH 4/6] Adding humidity sensor --- README.md | 83 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index d7f9994..dab610d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ This plugin currently supports the following services (and characteristics): | [ContactSensor](#contact-sensor) | 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 | +| [GarageDoor](#garage-door) | Garage door opener | +| [HumiditySensor](#humidity-sensor) | Humidity sensor | | [Lightbulb](#lightbulb) | Everything, from simple light to dimmable, RGB and RGBW | | [MotionSensor](#motion-sensor) | Detects and reports motion | | [OccupancySensor](#occupancy-sensor) | Detects presence in a room | @@ -28,7 +30,6 @@ This plugin currently supports the following services (and characteristics): | [TemperatureSensor](#temperature-sensor) | Temperature sensor | | [Thermostat](#thermostat) | Thermostat with temperature sensor and heating state | | [WindowCovering](#window-covering) | Window covering (shutters, blinds, ...) | -| [GarageDoor](#garage-door) | Garage door opener | Other accessories are being worked on and will be added as soon as ready. @@ -156,6 +157,60 @@ For now this accessory only supports turning the fan on and off. Further improve } ``` +### Garage Door +This accessory is used for opening/closing garage doors or any other automatic gate. + +#### Characteristics in addition to [common characteristics](#common-accessories-characteristics) +| Parameter | Possible values | Mandatory | Default | Description | +|:---------------------------|:----------------|:----------|:--------|:------------------------------------------------------------------| +| CurrentDoorState | \ | Yes | | SHNG item to monitor the current door state | +| TargetDoorState | \ | Yes | | SHNG item to monitor and set the target position | +| ObstructionDetected | \ | No | | SHNG item to monitor if the door is blocked | + +#### Additional comments + +Valid values for 'CurrentDoorState': +* OPEN = 0 +* CLOSED = 1 +* OPENING = 2 +* CLOSING = 3 +* STOPPED = 4 + +Valid values for 'TargetDoorState': +* OPEN = 0 +* CLOSED = 1 + +'ObstructionDetected' may be set 'true' if there is any physical problem opening/closing the door. + +#### Example +```json +{ + "type": "GarageDoor", + "name": "GarageRechts", + "currentdoorstate": "garage.rechts.cds", + "targetdoorstate": "garage.rechts.tds", + "obstructiondetected": "garage.rechts.od" +} +``` + +### Humidity sensor +This accessory is used for showing the current humidity value. + +#### Characteristics in addition to [common characteristics](#common-accessories-characteristics) +| Parameter | Possible values | Mandatory | Description | +|:-------------------|:----------------|:----------|:-------------------------------------| +| CurrentHumidity | \ | Yes | SHNG item to monitor humidity | + + +#### Example: +```json +{ + "type": "HumiditySensor", + "name": "Luftfeuchtigkeit Glashaus", + "CurrentHumidity": "Glashaus.Luftfeuchtigkeit" +} +``` + ### LightBulb Lightbulb can be as simple as a generic on/off light, but can also be as complex as a full RGBW led strip. @@ -400,32 +455,6 @@ The above optional parameters allow you to specify the neede range for your devi } ``` -### Garage Door -This accessory type can be used for opening/closing garage doors or any automatic gates. - -#### Characteristics in addition to [common characteristics](#common-accessories-characteristics) -| Parameter | Possible values | Mandatory | Default | Description | -|:---------------------------|:----------------|:----------|:--------|:------------------------------------------------------------------| -| CurrentDoorState | \ | Yes | | SHNG item to monitor the current door state | -| TargetDoorState | \ | Yes | | SHNG item to monitor and set the target position | -| ObstructionDetected | \ | No | | SHNG item to monitor if the door is blocked | - -#### Additional comments - -CurrentDoorState can be OPEN, CLOSED, OPENING, CLOSING and STOPPED. TargetDoorState can be OPEN or CLOSED. -ObstructionDetected can be set to true if there is a physical problem opening/closing the door. - -#### Example -```json -{ - "type": "GarageDoor", - "name": "GarageRechts", - "currentdoorstate": "garage.rechts.cds", - "targetdoorstate": "garage.rechts.tds", - "obstructiondetected": "garage.rechts.od" -} -``` - ### Example configuration file This is an example config file which just uses this plugin and some example SmartHomeNG items. From 447e0a68ef7c4f82eadde6150875493e49ca2222 Mon Sep 17 00:00:00 2001 From: Chester Date: Tue, 8 Mar 2022 14:18:35 +0100 Subject: [PATCH 5/6] added GarageDoor and HumiditySensor --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dab610d..acda71d 100644 --- a/README.md +++ b/README.md @@ -194,12 +194,12 @@ Valid values for 'TargetDoorState': ``` ### Humidity sensor -This accessory is used for showing the current humidity value. +This accessory shows the current relative humidity in %. #### Characteristics in addition to [common characteristics](#common-accessories-characteristics) -| Parameter | Possible values | Mandatory | Description | -|:-------------------|:----------------|:----------|:-------------------------------------| -| CurrentHumidity | \ | Yes | SHNG item to monitor humidity | +| Parameter | Possible values | Mandatory | Description | +|:-------------------|:----------------|:----------|:-----------------------------------------------| +| CurrentHumidity | \ | Yes | SHNG item to monitor relative humidity in % | #### Example: @@ -373,7 +373,7 @@ This accessory can monitor and change the on/off state of something. It is very ``` ### Temperature sensor -This sensor show the actual temperature. +This sensor shows the actual temperature. #### Characteristics in addition to [common characteristics](#common-accessories-characteristics) | Parameter | Possible values | Mandatory | Description | From 3561e0c3d64f55db0dbc07cd9ecb051489197c13 Mon Sep 17 00:00:00 2001 From: Chester Date: Tue, 8 Mar 2022 15:13:53 +0100 Subject: [PATCH 6/6] added humidity sensor --- src/Accessories/GarageDoor.ts | 69 ++++++++++++++++++++++++------- src/Accessories/HumiditySensor.ts | 59 ++++++++++++++++++++++++++ src/platform.ts | 12 ++++-- 3 files changed, 122 insertions(+), 18 deletions(-) create mode 100644 src/Accessories/HumiditySensor.ts diff --git a/src/Accessories/GarageDoor.ts b/src/Accessories/GarageDoor.ts index c45811b..e79b495 100644 --- a/src/Accessories/GarageDoor.ts +++ b/src/Accessories/GarageDoor.ts @@ -12,23 +12,15 @@ export class GarageDoor implements AccessoryPlugin { private readonly informationService: Service; public name: string; - //private currentPosition = 0; private currentPositionMin = 0; private currentPositionMax = 100; private currentPositionInverted = false; - //private = this.platform.Characteristic.PositionState.STOPPED; private targetDoorState = this.platform.Characteristic.CurrentDoorState.CLOSED; private currentDoorState = this.platform.Characteristic.CurrentDoorState.STOPPED; + private obstructionDetected = false; constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) { this.name = accessory.name; this.deviceService = new this.platform.Service.GarageDoorOpener(accessory.name); // create handlers for required characteristics - this.deviceService.getCharacteristic(this.platform.Characteristic.CurrentDoorState) - .onGet(this.getCurrentDoorState.bind(this)) - .onSet(this.setCurrentDoorState.bind(this)); - - this.deviceService.getCharacteristic(this.platform.Characteristic.TargetDoorState) - .onGet(this.getTargetDoorState.bind(this)) - .onSet(this.setTargetDoorState.bind(this)); this.informationService = new this.platform.Service.AccessoryInformation() @@ -36,13 +28,32 @@ export class GarageDoor implements AccessoryPlugin { .setCharacteristic(this.platform.Characteristic.Model, accessory.model) .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.currentdoorstate); // FIXME - this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this)); - this.platform.shng.addMonitor(accessory.targetdoorstate, this.shngTargetDoorStateCallback.bind(this)); -/* + if (accessory.currentdoorstate) { + this.platform.shng.addMonitor(accessory.currentdoorstate, this.shngCurrentDoorStateCallback.bind(this)); + this.deviceService.getCharacteristic(this.platform.Characteristic.CurrentDoorState) + .onGet(this.getCurrentDoorState.bind(this)) + .onSet(this.setCurrentDoorState.bind(this)); + } else { + this.platform.log.error('GarageDoor: missing \"currentdoorstate\" in config.json!'); + } + + if (accessory.targetdoorstate) { + this.platform.shng.addMonitor(accessory.targetdoorstate, this.shngTargetDoorStateCallback.bind(this)); + this.deviceService.getCharacteristic(this.platform.Characteristic.TargetDoorState) + .onGet(this.getTargetDoorState.bind(this)) + .onSet(this.setTargetDoorState.bind(this)); + } else { + this.platform.log.error('GarageDoor: missing \"targetdoorstate\" in config.json!'); + } + if (accessory.obstructiondetected) { this.platform.shng.addMonitor(accessory.obstructiondetected, this.shngObstructionDetectedCallback.bind(this)); + this.deviceService.getCharacteristic(this.platform.Characteristic.ObstructionDetected) + .onGet(this.getObstructionDetected.bind(this)) + .onSet(this.setObstructionDetected.bind(this)); + } -*/ + this.platform.log.info("GarageDoor '%s' created!", accessory.name); } @@ -55,6 +66,8 @@ export class GarageDoor implements AccessoryPlugin { } getCurrentDoorState(): Nullable { + //getCurrentDoorState(value: CharacteristicValue) { + // this.currentDoorState = value as number; this.platform.log.info('getCurrentDoorState:', this.accessory.name, 'is currently', this.currentDoorState); return this.currentDoorState; } @@ -62,10 +75,12 @@ export class GarageDoor implements AccessoryPlugin { setCurrentDoorState(value: CharacteristicValue) { this.currentDoorState = value as number; this.platform.log.info('setCurrentDoorState:', this.accessory.name, 'was set to', this.currentDoorState); - this.platform.shng.setItem(this.accessory.currentDoorState, this.currentDoorState); + this.platform.shng.setItem(this.accessory.currentdoorstate, this.currentDoorState); } getTargetDoorState(): Nullable { + //getTargetDoorState(value: CharacteristicValue) { + // this.targetDoorState = value as number; this.platform.log.info('getTargetDoorState:', this.accessory.name, 'is currently', this.targetDoorState); return this.targetDoorState; } @@ -73,13 +88,26 @@ export class GarageDoor implements AccessoryPlugin { setTargetDoorState(value: CharacteristicValue) { this.targetDoorState = value as number; this.platform.log.info('setTargetDoorState:', this.accessory.name, 'was set to', this.targetDoorState); - this.platform.shng.setItem(this.accessory.targetDoorState, this.targetDoorState); + this.platform.shng.setItem(this.accessory.targetdoorstate, this.targetDoorState); + } + + getObstructionDetected(): Nullable { + this.platform.log.info('getObstructionDetected:', this.accessory.name, 'is currently', this.obstructionDetected); + return this.obstructionDetected; + } + + setObstructionDetected(value: CharacteristicValue) { + this.obstructionDetected = value as boolean; + this.platform.log.info('setObstructionDetected:', this.accessory.name, 'was set to', this.obstructionDetected); + this.platform.shng.setItem(this.accessory.obstructiondetected, this.obstructionDetected); } shngCurrentDoorStateCallback(value: unknown): void { this.platform.log.debug('shngCurrentDoorStateCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); if (typeof value === 'number') { this.currentDoorState = value; + this.deviceService.updateCharacteristic(this.platform.Characteristic.CurrentDoorState, this.currentDoorState); + } else { this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value); } @@ -89,6 +117,17 @@ export class GarageDoor implements AccessoryPlugin { this.platform.log.debug('shngTargetDoorStateCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); if (typeof value === 'number') { this.targetDoorState = value; + this.deviceService.updateCharacteristic(this.platform.Characteristic.TargetDoorState, this.targetDoorState); + } else { + this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value); + } + } + + shngObstructionDetectedCallback(value: unknown): void { + this.platform.log.debug('shngObstructionDetectedCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); + if (typeof value === 'boolean') { + this.obstructionDetected = value; + this.deviceService.updateCharacteristic(this.platform.Characteristic.ObstructionDetected, this.obstructionDetected); } else { this.platform.log.warn('Unknown type ', typeof value, 'received for', this.accessory.name + ':', value); } diff --git a/src/Accessories/HumiditySensor.ts b/src/Accessories/HumiditySensor.ts new file mode 100644 index 0000000..65a45df --- /dev/null +++ b/src/Accessories/HumiditySensor.ts @@ -0,0 +1,59 @@ +import { + AccessoryPlugin, + CharacteristicValue, + Service, + Nullable, +} from 'homebridge'; + +import { SmartHomeNGPlatform } from '../platform'; + +export class HumiditySensor implements AccessoryPlugin { + private readonly deviceService: Service; + private readonly informationService: Service; + + public name: string; + private currentHumidity = 0; + + constructor(private readonly platform: SmartHomeNGPlatform, private readonly accessory) { + this.name = accessory.name; + this.deviceService = new this.platform.Service.HumiditySensor(accessory.name); + + // create handlers for required characteristics + this.deviceService.getCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity) + .onGet(this.getCurrentHumidity.bind(this)); + + this.informationService = + new this.platform.Service.AccessoryInformation() + .setCharacteristic(this.platform.Characteristic.Manufacturer, accessory.manufacturer) + .setCharacteristic(this.platform.Characteristic.Model, accessory.model) + .setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.currenthumidity); + + this.platform.shng.addMonitor(accessory.currenthumidity, this.shngCallback.bind(this)); + this.platform.log.info('HumiditySensor', accessory.name, 'created!'); + } + + identify(): void { + this.platform.log.info('Identify!'); + } + + getServices(): Service[] { + return [this.informationService, this.deviceService]; + } + + getCurrentHumidity(): Nullable { + this.platform.log.debug('getCurrentHumidity:', this.accessory.name, '=', this.currentHumidity); + return this.currentHumidity; + } + + shngCallback(value: unknown): void { + this.platform.log.debug('shngCallback:', this.accessory.name, '=', value, '(' + typeof value + ')'); + if (typeof value === 'number') { + this.currentHumidity = value; + } else { + this.platform.log.warn('Unknown type', typeof value, 'received for', this.accessory.name + ':', value); + } + this.deviceService.updateCharacteristic(this.platform.Characteristic.CurrentRelativeHumidity, this.currentHumidity); + } +} + + diff --git a/src/platform.ts b/src/platform.ts index 43157c7..f0d5d8b 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -22,6 +22,7 @@ import { SecuritySystem } from './Accessories/SecuritySystem'; import { OccupancySensor } from './Accessories/OccupancySensor'; import { MotionSensor } from './Accessories/MotionSensor'; import { GarageDoor } from './Accessories/GarageDoor'; +import { HumiditySensor } from './Accessories/HumiditySensor'; function uncapitalizeKeys(obj): Record { function isObject(o: unknown): boolean { @@ -107,7 +108,7 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin { devices.push(new Doorbell(this, accessory)); break; - // Doorbell + // Security system case 'securitysystem': devices.push(new SecuritySystem(this, accessory)); break; @@ -132,7 +133,7 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin { devices.push(new Fan(this, accessory)); break; - // TemperatureSensor + // Temperature sensor case 'temperaturesensor': devices.push(new TemperatureSensor(this, accessory)); break; @@ -147,11 +148,16 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin { devices.push(new WindowCovering(this, accessory)); break; - // GarageDoor + // Garage door case 'garagedoor': devices.push(new GarageDoor(this, accessory)); break; + // Humidity sensor + case 'humiditysensor': + devices.push(new HumiditySensor(this, accessory)); + break; + // Show error for (yet ?) unsupported device default: this.log.warn('Accessory type', accessory.type, 'for', accessory.name, 'not recognized !');