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.2.0-b28 to 1.2.0-b29

2

package.json
{
"name": "syntex-automation",
"version": "1.2.0-b28",
"version": "1.2.0-b29",
"description": "An automation system for your smart home",

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

@@ -367,3 +367,4 @@ const axios = require('axios');

{
var success = false;
var promiseArray = [], firstSuccess = false,
locked = this.stateLock[automation.id] != null && this.stateLock[automation.id].result == true;

@@ -377,55 +378,86 @@ for(const block of automation.result)

if(block.url != null)
if((block.options != null && block.options.stateLock == false) || !locked)
{
let theRequest = {
url : block.url,
timeout : 10000
};
if(block.url != null)
{
promiseArray.push(new Promise((resolve) => {
this.fetchRequest(theRequest, automation.name, block);
var theRequest = {
url : block.url,
timeout : 10000
};
this.fetchRequest(theRequest, automation.name, block).then((data) => {
success = true;
}
if(!firstSuccess)
{
firstSuccess = true;
if(block.id != null && block.letters != null && block.state != null && block.name != null)
{
if((block.options != null && block.options.stateLock == false)
|| this.stateLock[automation.id] == null
|| this.stateLock[automation.id].result != true)
this._automationLock(automation, block);
}
resolve(data != null);
});
}));
}
if(block.id != null && block.letters != null && block.state != null && block.name != null)
{
var state = { ...block.state };
promiseArray.push(new Promise((resolve) => {
var state = { ...block.state };
if((state = this.TypeManager.validateUpdate(block.id, block.letters, state)) != null)
{
if(this.TypeManager.letterToType(block.letters[0]) == 'statelessswitch')
if((state = this.TypeManager.validateUpdate(block.id, block.letters, state)) != null)
{
state.event = state.value;
state.value = 0;
}
if(this.TypeManager.letterToType(block.letters[0]) == 'statelessswitch')
{
state.event = state.value;
state.value = 0;
}
if(block.bridge != null && block.port != null)
{
let theRequest = {
url : 'http://' + block.bridge + ':' + block.port + '/devices?id=' + block.id + '&type=' + this.TypeManager.letterToType(block.letters[0]) + '&counter=' + block.letters[1],
timeout : 10000
};
if(block.bridge != null && block.port != null)
{
var theRequest = {
url : 'http://' + block.bridge + ':' + block.port + '/devices?id=' + block.id + '&type=' + this.TypeManager.letterToType(block.letters[0]) + '&counter=' + block.letters[1],
timeout : 10000
};
for(const x in state)
for(const x in state)
{
theRequest.url += '&' + x + '=' + state[x];
}
this.fetchRequest(theRequest, automation.name, block).then((data) => {
if(!firstSuccess)
{
firstSuccess = true;
this._automationLock(automation, block);
}
resolve(data != null);
});
}
else
{
theRequest.url += '&' + x + '=' + state[x];
this.EventManager.setOutputStream('changeHandler', { receiver : { id : block.id, letters : block.letters } }, state);
if(!firstSuccess)
{
firstSuccess = true;
this._automationLock(automation, block);
}
resolve(true);
}
this.fetchRequest(theRequest, automation.name, block);
}
else
{
this.EventManager.setOutputStream('changeHandler', { receiver : { id : block.id, letters : block.letters } }, state);
this.logger.log('error', block.id, block.letters, '[' + block.name + '] %update_error%! ( ' + block.id + ' )');
resolve(false);
}
success = true;
}
else
{
this.logger.log('error', block.id, block.letters, '[' + block.name + '] %update_error%! ( ' + block.id + ' )');
}
}));
}

@@ -435,6 +467,13 @@ }

if(success)
{
this._automationSuccess(automation, trigger);
}
Promise.all(promiseArray).then((success) => {
if(success.includes(true))
{
this._automationLock(automation);
this.ContextManager.updateAutomation(trigger.id, trigger.letters, automation);
this.logger.log('success', trigger.id, trigger.letters, '[' + trigger.name + '] %automation_executed[0]% [' + automation.name + '] %automation_executed[1]%!');
}
});
}

@@ -455,35 +494,21 @@

_automationSuccess(automation, trigger)
_automationLock(automation, block)
{
var changed = false;
this.ContextManager.updateAutomation(trigger.id, trigger.letters, automation);
if(automation.options != null && automation.options.timeLock != null)
if(block != null)
{
this.timeLock[automation.id] = new Date().getTime() + automation.options.timeLock;
changed = true;
}
for(const i in automation.trigger.groups)
{
for(const j in automation.trigger.groups[i].blocks)
if(block.options == null || block.options.stateLock != false)
{
if(automation.trigger.groups[i].blocks[j].options != null && automation.trigger.groups[i].blocks[j].options.stateLock == true)
if(this.stateLock[automation.id] == null)
{
if(this.stateLock[automation.id] == null)
{
this.stateLock[automation.id] = {};
}
this.stateLock[automation.id] = {};
}
if(this.stateLock[automation.id].trigger == null)
{
this.stateLock[automation.id].trigger = {};
}
if(this.stateLock[automation.id].result != true)
{
this.stateLock[automation.id].result = true;
this.stateLock[automation.id].trigger[i + '' + j] = true;
this._updateSockets(true, automation.id);
this._updateSockets(true, automation.id, i + '' + j);
changed = true;

@@ -493,25 +518,35 @@ }

}
var hasLock = false;
for(const block of automation.result)
else
{
if(block.options == null || block.options.stateLock != false)
if(automation.options != null && automation.options.timeLock != null)
{
hasLock = true;
this.timeLock[automation.id] = new Date().getTime() + automation.options.timeLock;
changed = true;
}
}
if(hasLock)
{
if(this.stateLock[automation.id] == null)
for(const i in automation.trigger.groups)
{
this.stateLock[automation.id] = {};
}
for(const j in automation.trigger.groups[i].blocks)
{
if(automation.trigger.groups[i].blocks[j].options != null && automation.trigger.groups[i].blocks[j].options.stateLock == true)
{
if(this.stateLock[automation.id] == null)
{
this.stateLock[automation.id] = {};
}
this.stateLock[automation.id].result = true;
if(this.stateLock[automation.id].trigger == null)
{
this.stateLock[automation.id].trigger = {};
}
this._updateSockets(true, automation.id);
this.stateLock[automation.id].trigger[i + '' + j] = true;
changed = true;
this._updateSockets(true, automation.id, i + '' + j);
changed = true;
}
}
}
}

@@ -523,6 +558,4 @@

}
}
this.logger.log('success', trigger.id, trigger.letters, '[' + trigger.name + '] %automation_executed[0]% [' + automation.name + '] %automation_executed[1]%!');
}
async _getState(automation, block)

@@ -529,0 +562,0 @@ {

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