From 739c3274c894a93ae9a8319934a5d7333276fc3f Mon Sep 17 00:00:00 2001 From: Foxi352 Date: Fri, 9 Sep 2016 12:41:12 +0200 Subject: [PATCH] Added thermostat --- index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.js b/index.js index 5f73bb9..6c84b00 100755 --- a/index.js +++ b/index.js @@ -153,6 +153,7 @@ SmartHomeNGAccessory.prototype = { break; case 'thermostat': + myServices.push(this.getThermostatService(this.config)); break; case 'lightbulb': @@ -393,6 +394,25 @@ SmartHomeNGAccessory.prototype = { } return myService; }, + + // Create Thermostat service + getThermostatService: function(config) { + var myService = new Service.Thermostat(config.name,config.name); + // Current temperature + if (config.currenttemperature) { + this.log("["+ this.name +"] TemperatureSensor CurrentTemperature characteristic enabled"); + this.bindCharacteristic(myService, Characteristic.CurrentTemperature, "Float", config.currenttemperature, false); + } + // Target temperature + if (config.targettemperature) { + this.log("["+ this.name +"] TemperatureSensor TargetTemperature characteristic enabled"); + this.bindCharacteristic(myService, Characteristic.TargetTemperature, "Float", config.targettemperature, false); + } + + this.bindCharacteristic(myService, Characteristic.TemperatureDisplayUnits, "Int", Characteristic.TemperatureDisplayUnits.CELSUIS, false); + + return myService; + }, // Create Fan service getFanService: function(config) {