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) {