homebridge-delay-switch
Advanced tools
Comparing version 3.0.4 to 3.1.0
@@ -48,2 +48,9 @@ { | ||
"required": false | ||
}, | ||
"debug": { | ||
"title": "Enable Debug Logs", | ||
"description": "When checked, the plugin will produce extra logs for debugging purposes", | ||
"type": "boolean", | ||
"default": false, | ||
"required": false | ||
} | ||
@@ -50,0 +57,0 @@ } |
25
index.js
@@ -18,2 +18,3 @@ | ||
this.delay = config['delay']; | ||
this.debug = config.debug || false | ||
this.sensorType = config['sensorType']; | ||
@@ -29,2 +30,14 @@ if (typeof this.sensorType === 'undefined') | ||
this.uuid = UUIDGen.generate(this.name) | ||
// define debug method to output debug logs when enabled in the config | ||
this.log.easyDebug = (...content) => { | ||
if (this.debug) { | ||
this.log(content.reduce((previous, current) => { | ||
return previous + ' ' + current | ||
})) | ||
} else | ||
this.log.debug(content.reduce((previous, current) => { | ||
return previous + ' ' + current | ||
})) | ||
} | ||
@@ -74,2 +87,6 @@ this.getSensorState = () => { | ||
break; | ||
case 'leak': | ||
this.sensorService = new Service.LeakSensor(this.name + ' Trigger'); | ||
this.sensorCharacteristic = Characteristic.LeakDetected | ||
break; | ||
default: | ||
@@ -98,3 +115,3 @@ this.sensorService = new Service.MotionSensor(this.name + ' Trigger'); | ||
if (!on) { | ||
this.log('Stopping the Timer'); | ||
this.log.easyDebug('Stopping the Timer'); | ||
@@ -108,3 +125,3 @@ this.switchOn = false; | ||
} else { | ||
this.log('Starting the Timer'); | ||
this.log.easyDebug('Starting the Timer'); | ||
this.switchOn = true; | ||
@@ -114,3 +131,3 @@ | ||
this.timer = setTimeout(function() { | ||
this.log('Time is Up!'); | ||
this.log.easyDebug('Time is Up!'); | ||
this.switchService.getCharacteristic(Characteristic.On).updateValue(false); | ||
@@ -122,3 +139,3 @@ this.switchOn = false; | ||
this.sensorService.getCharacteristic(this.sensorCharacteristic).updateValue(this.getSensorState()); | ||
this.log('Triggering Sensor'); | ||
this.log.easyDebug('Triggering Sensor'); | ||
setTimeout(function() { | ||
@@ -125,0 +142,0 @@ this.sensorTriggered = 0; |
{ | ||
"name": "homebridge-delay-switch", | ||
"version": "3.0.4", | ||
"version": "3.1.0", | ||
"description": "Delay switches for Homebridge", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
96877
173