Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

syntex-automation

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syntex-automation - npm Package Compare versions

Comparing version 1.0.2-b12 to 1.0.2-b13

route-manager.js

52

automation.js

@@ -5,3 +5,3 @@ let TypeManager = require('./type-manager');

var logger, storage, dataManager, eventManager, serverMode = false;
var logger, storage, dataManager, eventManager;
var eventLock = [], positiveFired = [], negativeFired = [], ready = false;

@@ -11,3 +11,3 @@

{
constructor(Logger, storagePath, DataManager, isServer, EventManager)
constructor(Logger, storagePath, DataManager, EventManager)
{

@@ -17,3 +17,2 @@ logger = Logger;

eventManager = EventManager;
serverMode = isServer;

@@ -42,4 +41,2 @@ TypeManager = new TypeManager(logger);

}
console.log('STORAGE PATH', storagePath);
}

@@ -79,7 +76,2 @@

{
if(!serverMode)
{
eventManager.sendToAutomationServer(id, letters, { value : value });
}
value = value.toString();

@@ -243,3 +235,16 @@

eventManager.setOutputStream('SynTexAutomation', { id : automation.result[i].id, letters : automation.result[i].letters }, { value : JSON.parse(automation.result[i].value) });
if(eventManager.pluginName != automation.result[i].plugin && automation.result[i].plugin != null && eventManager.RouteManager.getPort(automation.result[i].plugin) != null)
{
var theRequest = {
method : 'GET',
url : 'http://' + (automation.result[i].bridge || '127.0.0.1') + ':' + eventManager.RouteManager.getPort(automation.result[i].plugin) + '/devices?id=' + automation.result[i].id + '&type=' + TypeManager.letterToType(automation.result[i].letters[0]) + '&counter=' + automation.result[i].letters[1] + '&value=' + automation.result[i].value,
timeout : 10000
};
fetchRequest(theRequest, automation.name);
}
else
{
eventManager.setOutputStream('SynTexAutomation', { id : automation.result[i].id, letters : automation.result[i].letters }, { value : JSON.parse(automation.result[i].value) });
}
}

@@ -260,12 +265,3 @@ else

request(theRequest, function(err, response, body)
{
var statusCode = response && response.statusCode ? response.statusCode : -1;
if(err || statusCode != 200)
{
logger.log('error', 'bridge', 'Bridge', '[' + this.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + statusCode + '] %request_result[2]%: [' + (body || '') + '] ' + (err ? err : ''));
}
}.bind({ url : theRequest.url, name : automation.name }));
fetchRequest(theRequest, automation[i].name);
}

@@ -317,2 +313,16 @@

logger.log('success', trigger.id, trigger.letters, '[' + trigger.name + '] %automation_executed[0]% [' + automation.name + '] %automation_executed[1]%!');
}
function fetchRequest(theRequest, name)
{
request(theRequest, (err, response, body) => {
var statusCode = response && response.statusCode ? response.statusCode : -1;
if(err || statusCode != 200)
{
logger.log('error', 'bridge', 'Bridge', '[' + name + '] %request_result[0]% [' + theRequest.url + '] %request_result[1]% [' + statusCode + '] %request_result[2]%: [' + (body || '') + '] ' + (err ? err : ''));
}
});
}

@@ -1,8 +0,8 @@

let LogikEngine = require('./automation');
let LogikEngine = require('./automation'), RouteManager = require('./route-manager');
const EventEmitter = require('events'), request = require('request');
const EventEmitter = require('events');
module.exports = class AutomationSystem extends EventEmitter
{
constructor(logger, storagePath, dataManager, pluginName, isServer)
constructor(logger, storagePath, dataManager, pluginName, configPath)
{

@@ -16,3 +16,4 @@ super();

this.LogikEngine = new LogikEngine(logger, storagePath, dataManager, isServer, this);
this.RouteManager = new RouteManager(logger, configPath);
this.LogikEngine = new LogikEngine(logger, storagePath, dataManager, this);
}

@@ -32,24 +33,6 @@

{
super.emit(stream, reciever, values);
this.logger.debug('>>> ' + stream + ' ' + JSON.stringify(reciever) + ' ' + JSON.stringify(values));
}
sendToAutomationServer(id, letters, values)
{
var url = 'http://localhost:1777/update-automation?id=' + id + '&letters=' + letters + '&plugin=' + this.pluginName;
for(const value of Object.keys(values))
{
url += '&' + value + '=' + values[value];
}
var theRequest = {
method : 'GET',
url : url,
timeout : 10000
};
request(theRequest, () => {});
super.emit(stream, reciever, values);
}
}
{
"name": "syntex-automation",
"version": "1.0.2-b12",
"version": "1.0.2-b13",
"description": "An automation system for your smart home",

@@ -5,0 +5,0 @@ "main": "main.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc