From 0155a5557ec377e76cd55d6ce1cb7c6eaec58d39 Mon Sep 17 00:00:00 2001 From: Foxi352 Date: Tue, 30 May 2017 20:20:21 +0200 Subject: [PATCH] Added Outlet --- README.md | 10 ++++++++-- index.js | 20 ++++++++++++++++++++ package.json | 2 +- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2a36985..4535b68 100755 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ You have to create a config.json in .homebridge directory. You'll find that dire "platform": "SmartHomeNG", "name": "SmartHomeNG", - "host": "srvsmarthome.xxx.lu", + "host": "srvsmarthome.ha.swa.lu", "accessories": [ { "name": "Temperatur Stube", @@ -89,8 +89,13 @@ You have to create a config.json in .homebridge directory. You'll find that dire "onoff": "OG.Bad.Ventilator" }, { - "name": "Schaltsteckdose", + "name": "Schalter", "type": "Switch", + "onoff": "EG.Esszimmer.Schalter" + }, + { + "name": "Schaltsteckdose", + "type": "Outlet", "onoff": "EG.Esszimmer.Steckdose" }, { @@ -147,3 +152,4 @@ You have to create a config.json in .homebridge directory. You'll find that dire "description": "This is my development config file." } + diff --git a/index.js b/index.js index 15e0aee..461e858 100755 --- a/index.js +++ b/index.js @@ -171,6 +171,10 @@ SmartHomeNGAccessory.prototype = { myServices.push(this.getSwitchService(this.config)); break; + case 'outlet': + myServices.push(this.getOutletService(this.config)); + break; + case 'windowcovering': myServices.push(this.getWindowCoveringService(this.config)); break; @@ -629,4 +633,20 @@ SmartHomeNGAccessory.prototype = { return myService; }, + // Create Outlet service + getOutletService: function(config) { + var myService = new Service.Outlet(config.name,config.name); + var inverted = false; + if (config.inverted) { + inverted = true; + } + // On (and Off) + if (config.onoff) { + this.log("["+ this.name +"] Outlet on/off characteristic enabled"); + this.bindCharacteristic(myService, Characteristic.On, "Bool", config.onoff, inverted); + } + myService.getCharacteristic(Characteristic.OutletInUse).setValue(true); + return myService; + }, + } diff --git a/package.json b/package.json index 8082e30..15472f0 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-smarthomeng", - "version": "1.3.6", + "version": "1.3.7", "description": "Platform plugin for SmartHomeNG: https://github.com/smarthomeNG/smarthome", "license": "GPL", "keywords": [