From 91f6ccb2d4ea2d21902e0a144c8046ba77880f45 Mon Sep 17 00:00:00 2001 From: Snowdd1 Date: Fri, 18 Sep 2015 13:18:27 +0200 Subject: [PATCH] Added LightSensor Service --- accessories/knxdevice.js | 27 ++++++++++++++++++++++++--- platforms/KNX.md | 6 ++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/accessories/knxdevice.js b/accessories/knxdevice.js index b554b9a..db93fd4 100644 --- a/accessories/knxdevice.js +++ b/accessories/knxdevice.js @@ -526,6 +526,25 @@ KNXDevice.prototype = { //iterate(myService); return myService; }, + getLightSensorService: function(config) { + + // some sanity checks + if (config.type !== "LightSensor") { + this.log("[ERROR] LightSensor Service for non 'LightSensor' service called"); + return undefined; + } + if (!config.name) { + this.log("[ERROR] LightSensor Service without 'name' property called"); + return undefined; + } + var myService = new Service.LightSensor(config.name,config.name); + // CurrentTemperature) + if (config.CurrentAmbientLightLevel) { + this.log("LightSensor CurrentAmbientLightLevel characteristic enabled"); + this.bindCharacteristic(myService, Characteristic.CurrentAmbientLightLevel, "Float", config.CurrentAmbientLightLevel); + } + return myService; + }, getLockMechanismService: function(config) { /** //this.config = config; @@ -756,10 +775,9 @@ KNXDevice.prototype = { }, + - /* assemble the device ***************************************************************************************************/ - - +/* assemble the device ***************************************************************************************************/ getServices: function() { // you can OPTIONALLY create an information service if you wish to override @@ -799,6 +817,9 @@ KNXDevice.prototype = { case "Lightbulb": accessoryServices.push(this.getLightbulbService(configService)); break; + case "LightSensor": + accessoryServices.push(this.getLightSensorService(configService)); + break; case "LockMechanism": accessoryServices.push(this.getLockMechanismService(configService)); break; diff --git a/platforms/KNX.md b/platforms/KNX.md index 6512835..937af45 100644 --- a/platforms/KNX.md +++ b/platforms/KNX.md @@ -78,15 +78,17 @@ Two kinds of addresses are supported: `"Set":"1/2/3"` is a writable group addres - StatusFault: DPT 1, 1 as true - StatusTampered: DPT 1, 1 as true - StatusLowBattery: DPT 1, 1 as true + ## Lightbulb - On: DPT 1, 1 as on, 0 as off - Brightness: DPT5 percentage, 100% (=255) the brightest - + +## LightSensor +- CurrentAmbientLightLevel: DPT 9, 0 to 100000 Lux ## LockMechanism - LockCurrentState: DPT 1, 1 as secured **OR (but not both:)** - LockCurrentStateSecured0: DPT 1, 0 as secured - - LockTargetState: DPT 1, 1 as secured **OR** - LockTargetStateSecured0: DPT 1, 0 as secured