Community discussions

MikroTik App
 
msatter
Forum Guru
Forum Guru
Topic Author
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

[ API ] NodeRed (Javascript)

Fri May 20, 2022 2:55 pm

I am using NodeRed for the solar panels and it is very flexible. I connect to the solar panels inverter with a CAP lite and sometimes the WiFi connection fail. To restore the connection I use NodeRed.

There is NodeRed node for Mikrotik devices and using it was a difficult start because of the spare information how to use it.

To restart a connection I need first to need the know the .id of the wlan1, this because you can only address a specifik connection by the .id or numbers
contribution removed

Now I have the .id of wlan1 and can use it in a second function node:
contribution removed

Node Red is mainly graphical orientated so this how it looks and on the right you can see the debug output showing the second command.

contribution removed

The Mikrotik Node is available in palette in Node Red and the direct link is: https://flows.nodered.org/node/node-red ... b-mikrotik

Update: the command "=.proplist=.id" does not seem to do anything. Luckily NodeRed can address the values swiftly like msg.payload[0].disabled get false or true if a interface is active or not.

Update: proplist works and I have added it again to the code example
Last edited by msatter on Sat Jun 11, 2022 1:57 pm, edited 13 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: [ API ] NodeRed (Javascript)

Fri May 20, 2022 3:12 pm

CAn you simply send a command like:

"/interface/wireless/disable [find]"

"/interface/wireless/enable [find]"

???

The CAP lite have only one unique wlan
 
msatter
Forum Guru
Forum Guru
Topic Author
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: [ API ] NodeRed (Javascript)

Sun May 22, 2022 2:16 pm

Some more ready to use NodeJS can be found here: https://github.com/aluisiora

It is not specific written for NodeRed but nice examples and it is looking for someone who continue the development.
 
Adams
just joined
Posts: 1
Joined: Mon Apr 15, 2024 4:08 pm

[ API ] NodeRed (Javascript)

Mon Apr 15, 2024 4:23 pm

Hello everyone,
I have a question regarding the use of the node-red-contrib-mikrotik package in node-red. I managed to install it and everything works. But concerning the use of user-manager, I can display the list of users with "/user-manager/user/print", I can also delete users with the command "/user-manager/user/remove" + the user id. But a problem occurs when I try to add a new user, I get an error and I think it's linked to my syntax. Does anyone have any idea how to do this? Here's my add command at the bottom

msg.payload = {
"command": [
"/user-manager/user/add",
"=customer=admin",
"=username=toto",
"=password=toto",
"=disabled=no"
]
};

Who is online

Users browsing this forum: clorichel, eldoncito2019, Google [Bot] and 19 guests