homebridge-syntex-webhooks
Advanced tools
Comparing version 1.0.5-b7 to 1.0.5-b8
79
index.js
@@ -158,3 +158,3 @@ var request = require('request'); | ||
} | ||
else if(obj && err) | ||
else if(err) | ||
{ | ||
@@ -198,3 +198,6 @@ log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht geladen werden!"); | ||
log(obj.devices); | ||
if(obj && obj.devices) | ||
{ | ||
log(obj.devices); | ||
} | ||
}); | ||
@@ -209,3 +212,3 @@ | ||
if(obj) | ||
if(obj && !err) | ||
{ | ||
@@ -249,3 +252,3 @@ var found = false; | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR 3]", "Storage.json konnte nicht geladen werden!"); | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht geladen werden!"); | ||
} | ||
@@ -352,3 +355,2 @@ }); | ||
} | ||
/* | ||
@@ -358,11 +360,8 @@ else if(this.type === "occupancy") | ||
this.service = new Service.OccupancySensor(this.name); | ||
this.changeHandler = (function(newState) { | ||
this.changeHandler = (function(newState) | ||
{ | ||
this.service.getCharacteristic(Characteristic.OccupancyDetected).updateValue(newState ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED, undefined, CONTEXT_FROM_WEBHOOK); | ||
if (this.autoRelease) { | ||
setTimeout(function() { | ||
this.storage.setItemSync("http-webhook-" + this.id, false); | ||
this.service.getCharacteristic(Characteristic.OccupancyDetected).updateValue(Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED, undefined, CONTEXT_FROM_TIMEOUTCALL); | ||
}.bind(this), this.autoReleaseTime); | ||
} | ||
}).bind(this); | ||
this.service.getCharacteristic(Characteristic.OccupancyDetected).on('get', this.getState.bind(this)); | ||
@@ -373,6 +372,9 @@ } | ||
this.service = new Service.SmokeSensor(this.name); | ||
this.changeHandler = (function(newState) { | ||
this.changeHandler = (function(newState) | ||
{ | ||
log("Change HomeKit state for smoke sensor to '%s'.", newState); | ||
this.service.getCharacteristic(Characteristic.SmokeDetected).updateValue(newState ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED, undefined, CONTEXT_FROM_WEBHOOK); | ||
}).bind(this); | ||
this.service.getCharacteristic(Characteristic.SmokeDetected).on('get', this.getState.bind(this)); | ||
@@ -383,6 +385,9 @@ } | ||
this.service = new Service.AirQualitySensor(this.name); | ||
this.changeHandler = (function(newState) { | ||
this.changeHandler = (function(newState) | ||
{ | ||
log("Change HomeKit value for air quality sensor to '%s'.", newState); | ||
this.service.getCharacteristic(Characteristic.AirQuality).updateValue(newState, undefined, CONTEXT_FROM_WEBHOOK); | ||
}).bind(this); | ||
this.service.getCharacteristic(Characteristic.AirQuality).on('get', this.getState.bind(this)); | ||
@@ -399,3 +404,3 @@ } | ||
if(obj) | ||
if(obj && !err) | ||
{ | ||
@@ -449,2 +454,12 @@ for(var i = 0; i < obj.devices.length; i++) | ||
} | ||
/* | ||
else if(this.type === "smoke") | ||
{ | ||
callback(null, state ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED); | ||
} | ||
else if(this.type === "occupancy") | ||
{ | ||
callback(null, state ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED); | ||
} | ||
*/ | ||
else if(this.type === "light") | ||
@@ -461,13 +476,2 @@ { | ||
}); | ||
/* | ||
else if(this.type === "smoke") | ||
{ | ||
callback(null, state ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED); | ||
} | ||
else if(this.type === "occupancy") | ||
{ | ||
callback(null, state ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED); | ||
} | ||
*/ | ||
}; | ||
@@ -516,5 +520,4 @@ | ||
if(obj) | ||
if(obj && !err) | ||
{ | ||
for(var i = 0; i < obj.devices.length; i++) | ||
@@ -558,5 +561,14 @@ { | ||
if(!powerOn) | ||
{ | ||
urlToCall = this.offURL; | ||
urlMethod = this.offMethod; | ||
urlBody = this.offBody; | ||
urlForm = this.offForm; | ||
urlHeaders = this.offHeaders; | ||
} | ||
this.storage.load('storage', (err, obj) => { | ||
if(obj) | ||
if(obj && !err) | ||
{ | ||
@@ -605,11 +617,2 @@ var found = false; | ||
if(!powerOn) | ||
{ | ||
urlToCall = this.offURL; | ||
urlMethod = this.offMethod; | ||
urlBody = this.offBody; | ||
urlForm = this.offForm; | ||
urlHeaders = this.offHeaders; | ||
} | ||
if(urlToCall != "") | ||
@@ -616,0 +619,0 @@ { |
{ | ||
"name": "homebridge-syntex-webhooks", | ||
"version": "1.0.5-b7", | ||
"version": "1.0.5-b8", | ||
"description": "A webhook plugin for HTTP devices", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
30572