From 4e654120122c1f36a0ebd1ced7a5db56a460db56 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 10 Jan 2017 01:01:02 +0300 Subject: [PATCH 1/2] fix once "action" bug (#2) Bug: If used msg.payload, "action" variable not cleared in (assigned once). --- mikrotik.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mikrotik.js b/mikrotik.js index bc088c5..a911585 100644 --- a/mikrotik.js +++ b/mikrotik.js @@ -37,11 +37,12 @@ module.exports = function(RED) { var connection = null; this.on('input', function(msg) { - if (action == '') action = msg.payload; - if(action == '') return false; + var cmd = action; + if (cmd == '') cmd = msg.payload; + if (cmd == '') return false; connection = mikrotik.getConnection(ip, login, pass, {closeOnDone : true}); connection.getConnectPromise().then(function(conn) { - conn.getCommandPromise(action).then(function resolved(values) { + conn.getCommandPromise(cmd).then(function resolved(values) { var parsed = mikrotik.parseItems(values); var pl = []; parsed.forEach(function(item) { From b8d880bb601f66b227fb214c7b6250589ea0af4a Mon Sep 17 00:00:00 2001 From: bladerunner2020 Date: Tue, 10 Jan 2017 01:03:27 +0300 Subject: [PATCH 2/2] fixed the error message after the last merge --- mikrotik.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mikrotik.js b/mikrotik.js index a911585..6356cdd 100644 --- a/mikrotik.js +++ b/mikrotik.js @@ -51,7 +51,7 @@ module.exports = function(RED) { msg.payload = values; node.send(msg); }, function rejected(reason) { - node.error('Error executing cmd['+action+']: ' + JSON.stringify(reason)); + node.error('Error executing cmd['+cmd+']: ' + JSON.stringify(reason)); }); }, function(err) {