homebridge-syntex-webhooks
Advanced tools
Comparing version 1.0.5-b23 to 1.0.5-b24
99
index.js
@@ -45,3 +45,3 @@ var request = require('request'); | ||
{ | ||
var Sensor = new SynTexWebHookSensorAccessory(this.sensors[i], storage); | ||
var Sensor = new SynTexWebHookSensorAccessory(this.sensors[i]); | ||
accessories.push(Sensor); | ||
@@ -52,3 +52,3 @@ } | ||
{ | ||
var Switch = new SynTexWebHookSwitchAccessory(this.switches[i], storage); | ||
var Switch = new SynTexWebHookSwitchAccessory(this.switches[i]); | ||
accessories.push(Switch); | ||
@@ -104,3 +104,38 @@ } | ||
updateDevice(device); | ||
updateDevice(device).then(function(res) { | ||
for(var i = 0; i < accessories.length; i++) | ||
{ | ||
var accessory = accessories[i]; | ||
if(accessory.mac === urlParams.mac) | ||
{ | ||
if(urlParams.type) | ||
{ | ||
if(accessory.type === urlParams.type) | ||
{ | ||
if(urlParams.value == 'true' || urlParams.value == 'false') | ||
{ | ||
accessory.changeHandler((urlParams.value === 'true')); | ||
} | ||
else | ||
{ | ||
accessory.changeHandler(urlParams.value); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
if(urlParams.value == 'true' || urlParams.value == 'false') | ||
{ | ||
accessory.changeHandler((urlParams.value === 'true')); | ||
} | ||
else | ||
{ | ||
accessory.changeHandler(urlParams.value); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
@@ -174,3 +209,3 @@ response.write("Success"); | ||
function SynTexWebHookSensorAccessory(sensorConfig, storage) | ||
function SynTexWebHookSensorAccessory(sensorConfig) | ||
{ | ||
@@ -181,3 +216,2 @@ this.mac = sensorConfig["mac"]; | ||
this.type = sensorConfig["type"]; | ||
storage = storage; | ||
@@ -354,3 +388,3 @@ if(this.type === "contact") | ||
function SynTexWebHookSwitchAccessory(switchConfig, storage) | ||
function SynTexWebHookSwitchAccessory(switchConfig) | ||
{ | ||
@@ -371,3 +405,2 @@ this.mac = switchConfig["mac"]; | ||
this.offHeaders = switchConfig["off_headers"] || "{}"; | ||
storage = storage; | ||
@@ -535,27 +568,35 @@ this.service = new Service.Switch(this.name); | ||
function updateDevice(obj) | ||
async function updateDevice(obj) | ||
{ | ||
if(obj.type) | ||
{ | ||
var device = { | ||
id: obj.mac, | ||
value: obj.value, | ||
type: obj.type | ||
}; | ||
} | ||
else | ||
{ | ||
var device = { | ||
id: obj.mac, | ||
value: obj.value | ||
}; | ||
} | ||
return new Promise(resolve => { | ||
if(obj.type) | ||
{ | ||
var device = { | ||
id: obj.mac, | ||
value: obj.value, | ||
type: obj.type | ||
}; | ||
} | ||
else | ||
{ | ||
var device = { | ||
id: obj.mac, | ||
value: obj.value | ||
}; | ||
} | ||
storage.add(device, (err) => { | ||
storage.add(device, (err) => { | ||
if(err) | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!"); | ||
} | ||
}); | ||
if(err) | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!"); | ||
resolve(false); | ||
} | ||
else | ||
{ | ||
resolve(true); | ||
} | ||
}); | ||
}); | ||
} |
{ | ||
"name": "homebridge-syntex-webhooks", | ||
"version": "1.0.5-b23", | ||
"version": "1.0.5-b24", | ||
"description": "A webhook plugin for HTTP devices", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58763
1140