Prima versione customizzata

This commit is contained in:
2020-11-04 11:19:03 +01:00
parent e5b19cccff
commit 0ea1a8e10f
2 changed files with 12 additions and 16 deletions

View File

@@ -47,15 +47,13 @@ module.exports = function(RED) {
} }
var connection = null; var connection = null;
connection = mikrotik.getConnection(host, username, password, {closeOnDone : false, port: port});
this.on('input', function(msg) { this.on('input', function(msg) {
if (command == '') command = msg.payload; if (command == '') command = msg.payload;
if (command == '') return false; if (command == '') return false;
connection = mikrotik.getConnection(host, username, password, {closeOnDone : true, port: port}); connection.getConnectPromise().then(function resolve(conn) {
connection.getConnectPromise().then(function(conn) {
conn.getCommandPromise(command).then(function resolved(values) { conn.getCommandPromise(command).then(function resolved(values) {
var parsed = mikrotik.parseItems(values); var parsed = mikrotik.parseItems(values);
var pl = []; var pl = [];
parsed.forEach(function(item) { parsed.forEach(function(item) {

View File

@@ -1,16 +1,15 @@
{ {
"name": "node-red-contrib-mikrotik2", "name": "node-red-contrib-mikrotik3",
"version": "0.1.1", "version": "0.1.2",
"description": "Node based on node-red-contrib-mikrotik to work with Mikrotik devices which fixes device configuration problem", "description": "Node based on nodered-contrib-mikrotik to work with Mikrotik devices",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "Alexander Pivovarov <pivovarov@gmail.com>", "author": "Alexander Pivovarov <pivovarov@gmail.com>",
"contributors": [ "contributors": [
{ {
"name": "Ahmed Al Hafoudh", "name": "Emanuele Trabattoni",
"email": "alhafoudh@freevision.sk", "email": "ema.trabattoni@gmail.com"
"url": "https://www.freevision.sk"
} }
], ],
"node-red": { "node-red": {
@@ -21,7 +20,7 @@
"keywords": [ "keywords": [
"node-red" "node-red"
], ],
"license": "ISC", "license": "MIT",
"dependencies": { "dependencies": {
"mikronode-ng": "^1.0.5" "mikronode-ng": "^1.0.5"
}, },
@@ -29,10 +28,9 @@
"devDependencies": {}, "devDependencies": {},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/alhafoudh/node-red-contrib-mikrotik2.git" "url": "git+https://git.etss.it/ETSS/nodered-contrib-mikrotik.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/alhafoudh/node-red-contrib-mikrotik2/issues" "url": "https://git.etss.it/ETSS/nodered-contrib-mikrotik.git/issues"
}, }
"homepage": "https://github.com/alhafoudh/node-red-contrib-mikrotik2#readme"
} }