syntex-automation
Advanced tools
Comparing version 1.2.0-b11 to 1.2.0-b12
{ | ||
"name": "syntex-automation", | ||
"version": "1.2.0-b11", | ||
"version": "1.2.0-b12", | ||
"description": "An automation system for your smart home", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -14,2 +14,4 @@ const axios = require('axios'); | ||
this.sockets = {}; | ||
this.platform = platform; | ||
@@ -35,3 +37,5 @@ | ||
{ | ||
this.timeInterval = setInterval(() => this.loadLock().then(() => { | ||
this.initNetwork(); | ||
this.timeInterval = setInterval(() => { | ||
@@ -62,2 +66,4 @@ var changed = false; | ||
this.stateLock[this.automation[i].id].trigger[blocks[j].blockID] = false; | ||
this._updateSockets(false, this.automation[i].id, blocks[j].blockID); | ||
@@ -78,3 +84,3 @@ this.logger.debug('Automation [' + this.automation[i].name + '] %automation_different% ' + this.automation[i].id + ' ' + blocks[j].blockID); | ||
}), 60000); | ||
}, 60000); | ||
@@ -129,2 +135,31 @@ this.ready = true; | ||
initNetwork() | ||
{ | ||
if(this.platform.WebServer != null) | ||
{ | ||
this.platform.WebServer.addSocket('/automation', 'setLock', (ws, params) => { | ||
if(params.id != null && params.lock != null) | ||
{ | ||
if(params.blockID != null) | ||
{ | ||
this.stateLock[params.id].trigger[params.blockID] = params.lock; | ||
} | ||
else | ||
{ | ||
this.stateLock[params.id].result = params.lock; | ||
} | ||
} | ||
}); | ||
} | ||
for(const i in this.manager.RouteManager.plugins) | ||
{ | ||
if(this.manager.RouteManager.plugins[i].port != this.platform.port) | ||
{ | ||
this.sockets[this.manager.RouteManager.plugins[i].port] = this.platform.WebServer.connectSocket('ws://localhost:' + this.manager.RouteManager.plugins[i].port + '/automation', () => {}); | ||
} | ||
} | ||
} | ||
parseAutomation() | ||
@@ -249,2 +284,4 @@ { | ||
this._updateSockets(false, this.automation[i].id, blocks[j].blockID); | ||
if(blocks[j].operation == '<') | ||
@@ -378,2 +415,4 @@ { | ||
this._updateSockets(false, automation.id); | ||
this.logger.debug('Automation [' + automation.name + '] %automation_different% ' + automation.id); | ||
@@ -568,2 +607,4 @@ } | ||
this._updateSockets(true, automation.id, i + '' + j); | ||
changed = true; | ||
@@ -583,2 +624,4 @@ } | ||
this._updateSockets(true, automation.id); | ||
changed = true; | ||
@@ -732,2 +775,17 @@ } | ||
} | ||
_updateSockets(lock, id, blockID) | ||
{ | ||
var params = { id, lock }; | ||
if(blockID != null) | ||
{ | ||
params.blockID = blockID; | ||
} | ||
for(const i in this.sockets) | ||
{ | ||
this.sockets[i].send(JSON.stringify({ line : 'setLock', params })) | ||
} | ||
} | ||
} |
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
27625
719