syntex-automation
Advanced tools
Comparing version 1.0.3-b4 to 1.0.3-b5
let TypeManager = require('./type-manager'); | ||
const axios = require('axios'), store = require('json-fs-store'); | ||
const axios = require('axios'); | ||
var logger, storage, dataManager, eventManager; | ||
var logger, files, dataManager, eventManager; | ||
var eventLock = [], positiveFired = [], negativeFired = [], ready = false; | ||
@@ -10,5 +10,6 @@ | ||
{ | ||
constructor(Logger, storagePath, DataManager, EventManager) | ||
constructor(Logger, Files, DataManager, EventManager) | ||
{ | ||
logger = Logger; | ||
files = Files; | ||
dataManager = DataManager; | ||
@@ -19,22 +20,17 @@ eventManager = EventManager; | ||
if(storagePath != null) | ||
{ | ||
storage = store(storagePath); | ||
files.readFile('/automation/automation-lock.json').then((data) => { | ||
storage.load('automation-lock', (err, obj) => { | ||
if(data != null) | ||
{ | ||
eventLock = obj.eventLock || []; | ||
positiveFired = obj.positiveFired || []; | ||
negativeFired = obj.negativeFired || []; | ||
} | ||
else | ||
{ | ||
logger.log('error', 'bridge', 'Bridge', 'Automation-Lock.json %read_error%! ' + err); | ||
} | ||
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(); | ||
}); | ||
} | ||
this.loadAutomation(); | ||
}); | ||
} | ||
@@ -46,21 +42,21 @@ | ||
storage.load('automation', (err, obj) => { | ||
files.readFile('/automation/automation.json').then((data) => { | ||
if(!obj || err) | ||
if(data != null) | ||
{ | ||
this.automation = []; | ||
this.automation = data; | ||
resolve(false); | ||
resolve(true); | ||
logger.log('warn', 'bridge', 'Bridge', '%automation_load_error%!'); | ||
this.parseAutomation(); | ||
logger.log('success', 'bridge', 'Bridge', '%automation_load_success%!'); | ||
} | ||
else | ||
{ | ||
this.automation = obj.automation; | ||
this.automation = []; | ||
resolve(true); | ||
resolve(false); | ||
this.parseAutomation(); | ||
logger.log('success', 'bridge', 'Bridge', '%automation_load_success%!'); | ||
logger.log('warn', 'bridge', 'Bridge', '%automation_load_error%!'); | ||
} | ||
@@ -233,5 +229,5 @@ | ||
storage.add({ id : 'automation-lock', eventLock : eventLock, positiveFired : positiveFired, negativeFired : negativeFired }, (err) => { | ||
files.writeFile('/automation/automation-lock.json', { eventLock : eventLock, positiveFired : positiveFired, negativeFired : negativeFired }).then((success) => { | ||
if(err) | ||
if(!success) | ||
{ | ||
@@ -492,5 +488,5 @@ logger.log('error', 'bridge', 'Bridge', 'Automation-Lock.json %update_error%! ' + err); | ||
storage.add({ id : 'automation-lock', eventLock : eventLock, positiveFired : positiveFired, negativeFired : negativeFired }, (err) => { | ||
if(err) | ||
files.writeFile('/automation/automation-lock.json', { eventLock : eventLock, positiveFired : positiveFired, negativeFired : negativeFired }).then((success) => { | ||
if(!success) | ||
{ | ||
@@ -497,0 +493,0 @@ logger.log('error', 'bridge', 'Bridge', 'Automation-Lock.json %update_error%! ' + err); |
@@ -7,3 +7,3 @@ let LogikEngine = require('./automation'), RouteManager = require('./route-manager'); | ||
{ | ||
constructor(logger, storagePath, dataManager, pluginName, configPath) | ||
constructor(logger, files, dataManager, pluginName, configPath) | ||
{ | ||
@@ -18,3 +18,3 @@ super(); | ||
this.RouteManager = new RouteManager(logger, configPath); | ||
this.LogikEngine = new LogikEngine(logger, storagePath, dataManager, this); | ||
this.LogikEngine = new LogikEngine(logger, files, dataManager, this); | ||
} | ||
@@ -21,0 +21,0 @@ |
{ | ||
"name": "syntex-automation", | ||
"version": "1.0.3-b4", | ||
"version": "1.0.3-b5", | ||
"description": "An automation system for your smart home", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
# SynTex Automation System | ||
An automation system for your smart home |
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
22234
556