syntex-automation
Advanced tools
Comparing version 1.0.2-b10 to 1.0.2-b11
@@ -10,30 +10,33 @@ let TypeManager = require('./type-manager'); | ||
{ | ||
constructor(log, storagePath, DataManager, isServer, EventManager) | ||
constructor(Logger, storagePath, DataManager, isServer, EventManager) | ||
{ | ||
logger = log; | ||
storage = store(storagePath); | ||
console.log('STORAGE PATH', storagePath); | ||
logger = Logger; | ||
dataManager = DataManager; | ||
eventManager = EventManager; | ||
serverMode = isServer; | ||
dataManager = DataManager; | ||
eventManager = EventManager; | ||
serverMode = isServer; | ||
TypeManager = new TypeManager(logger); | ||
storage.load('automation-lock', (err, obj) => { | ||
if(storagePath != null) | ||
{ | ||
storage = store(storagePath); | ||
if(!obj || err) | ||
{ | ||
logger.log('error', 'bridge', 'Bridge', 'Automation-Lock.json %read_error%! ' + err); | ||
} | ||
else | ||
{ | ||
eventLock = obj.eventLock || []; | ||
positiveFired = obj.positiveFired || []; | ||
negativeFired = obj.negativeFired || []; | ||
} | ||
storage.load('automation-lock', (err, obj) => { | ||
this.loadAutomation(); | ||
}); | ||
if(!obj || err) | ||
{ | ||
logger.log('error', 'bridge', 'Bridge', 'Automation-Lock.json %read_error%! ' + err); | ||
} | ||
else | ||
{ | ||
eventLock = obj.eventLock || []; | ||
positiveFired = obj.positiveFired || []; | ||
negativeFired = obj.negativeFired || []; | ||
} | ||
this.loadAutomation(); | ||
}); | ||
} | ||
console.log('STORAGE PATH', storagePath); | ||
} | ||
@@ -71,38 +74,41 @@ | ||
{ | ||
if(!serverMode) | ||
{ | ||
eventManager.sendToAutomationServer(id, letters, { value : value }); | ||
} | ||
value = value.toString(); | ||
for(var i = 0; i < this.automation.length; i++) | ||
if(ready) | ||
{ | ||
if(eventLock.includes(this.automation[i].id)) | ||
if(!serverMode) | ||
{ | ||
for(var j = 0; j < this.automation[i].trigger.length; j++) | ||
eventManager.sendToAutomationServer(id, letters, { value : value }); | ||
} | ||
value = value.toString(); | ||
for(var i = 0; i < this.automation.length; i++) | ||
{ | ||
if(eventLock.includes(this.automation[i].id)) | ||
{ | ||
if(this.automation[i].trigger[j].id == id && this.automation[i].trigger[j].letters == letters) | ||
for(var j = 0; j < this.automation[i].trigger.length; j++) | ||
{ | ||
var index = eventLock.indexOf(this.automation[i].id); | ||
if(this.automation[i].trigger[j].operation == '>' && parseFloat(value) < parseFloat(this.automation[i].trigger[j].value) && negativeFired.includes(this.automation[i].trigger[j].id)) | ||
if(this.automation[i].trigger[j].id == id && this.automation[i].trigger[j].letters == letters) | ||
{ | ||
eventLock.splice(index, 1); | ||
var index = eventLock.indexOf(this.automation[i].id); | ||
logger.debug('Automation [' + this.automation[i].name + '] Unterschritten ' + this.automation[i].id); | ||
} | ||
if(this.automation[i].trigger[j].operation == '>' && parseFloat(value) < parseFloat(this.automation[i].trigger[j].value) && negativeFired.includes(this.automation[i].trigger[j].id)) | ||
{ | ||
eventLock.splice(index, 1); | ||
if(this.automation[i].trigger[j].operation == '<' && parseFloat(value) > parseFloat(this.automation[i].trigger[j].value) && positiveFired.includes(this.automation[i].trigger[j].id)) | ||
{ | ||
eventLock.splice(index, 1); | ||
logger.debug('Automation [' + this.automation[i].name + '] Unterschritten ' + this.automation[i].id); | ||
} | ||
logger.debug('Automation [' + this.automation[i].name + '] Überschritten ' + this.automation[i].id); | ||
} | ||
if(this.automation[i].trigger[j].operation == '<' && parseFloat(value) > parseFloat(this.automation[i].trigger[j].value) && positiveFired.includes(this.automation[i].trigger[j].id)) | ||
{ | ||
eventLock.splice(index, 1); | ||
if(this.automation[i].trigger[j].operation == '=' && value != this.automation[i].trigger[j].value) | ||
{ | ||
eventLock.splice(index, 1); | ||
logger.debug('Automation [' + this.automation[i].name + '] Überschritten ' + this.automation[i].id); | ||
} | ||
logger.debug('Automation [' + this.automation[i].name + '] Ungleich ' + this.automation[i].id); | ||
if(this.automation[i].trigger[j].operation == '=' && value != this.automation[i].trigger[j].value) | ||
{ | ||
eventLock.splice(index, 1); | ||
logger.debug('Automation [' + this.automation[i].name + '] Ungleich ' + this.automation[i].id); | ||
} | ||
} | ||
@@ -112,17 +118,12 @@ } | ||
} | ||
} | ||
for(var i = 0; i < this.automation.length; i++) | ||
{ | ||
if(this.automation[i].active && !eventLock.includes(this.automation[i].id)) | ||
for(var i = 0; i < this.automation.length; i++) | ||
{ | ||
checkTrigger(this.automation[i], id, letters, value.toString()); | ||
if(this.automation[i].active && !eventLock.includes(this.automation[i].id)) | ||
{ | ||
checkTrigger(this.automation[i], id, letters, value.toString()); | ||
} | ||
} | ||
} | ||
} | ||
isReady() | ||
{ | ||
return ready; | ||
} | ||
}; | ||
@@ -129,0 +130,0 @@ |
{ | ||
"name": "syntex-automation", | ||
"version": "1.0.2-b10", | ||
"version": "1.0.2-b11", | ||
"description": "An automation system for your smart home", | ||
@@ -5,0 +5,0 @@ "main": "main.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
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
13135
350
0