homebridge-syntex-webhooks
Advanced tools
Comparing version 1.0.5-b30 to 1.0.5-b31
70
index.js
@@ -403,18 +403,9 @@ var request = require('request'); | ||
storage.load('storage', (err, obj) => { | ||
storage.load(this.mac, (err, obj) => { | ||
if(obj && !err) | ||
{ | ||
for(var i = 0; i < obj.devices.length; i++) | ||
{ | ||
if(obj.devices[i].mac === this.mac) | ||
{ | ||
state = obj.devices[i].value; | ||
if(state == 'true' || state == 'false') | ||
{ | ||
state = (state === 'true'); | ||
} | ||
} | ||
} | ||
state = obj.value; | ||
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für '" + this.name + "' ist '" + state + "' ( " + this.mac + " )"); | ||
} | ||
@@ -424,3 +415,3 @@ | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht geladen werden!"); | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", this.mac + ".json konnte nicht geladen werden!"); | ||
} | ||
@@ -434,4 +425,2 @@ | ||
callback(null, state); | ||
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für '" + this.name + "' ist '" + state + "' ( " + this.mac + " )"); | ||
}); | ||
@@ -457,47 +446,8 @@ }; | ||
storage.load('storage', (err, obj) => { | ||
if(obj && !err) | ||
{ | ||
var found = false; | ||
var device = { | ||
mac: this.mac, | ||
value: this.value | ||
}; | ||
for(var i = 0; i < obj.devices.length; i++) | ||
{ | ||
if(obj.devices[i].mac === this.mac) | ||
{ | ||
obj.devices[i].value = powerOn; | ||
found = true; | ||
} | ||
} | ||
if(found == false) | ||
{ | ||
obj.devices[obj.devices.length] = {mac: this.mac, value: powerOn}; | ||
} | ||
storage.add(obj, (err) => { | ||
if(err) | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!"); | ||
} | ||
}); | ||
} | ||
else | ||
{ | ||
var device = { | ||
id: "storage", | ||
devices: [{mac: this.mac, value: powerOn}] | ||
}; | ||
storage.add(device, (err) => { | ||
if(err) | ||
{ | ||
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!"); | ||
} | ||
}); | ||
} | ||
}); | ||
updateDevice(device); | ||
@@ -504,0 +454,0 @@ if(urlToCall != "") |
{ | ||
"name": "homebridge-syntex-webhooks", | ||
"version": "1.0.5-b30", | ||
"version": "1.0.5-b31", | ||
"description": "A webhook plugin for HTTP devices", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
56798
1104