Community discussions

MikroTik App
 
aszodi
just joined
Topic Author
Posts: 10
Joined: Fri Nov 16, 2018 2:45 pm

User-LED script to monitor a specific route

Thu Oct 19, 2023 2:55 pm

Hi All,

First of all I'm not a script-guru, so tried my best to achieve the goal to turn on USER-LED on specific case, when the route (called: test) is active. Otherwise, turn USER-LED off. Of course, the specific Route entry is commented with "test" correctly, so that is double checked.

I'm trying hard with this:

{
/system leds add leds=user-led type=off;

:local status [/ip route get value-name=active [find comment="test"]];
:if ($status = true) do={
/system leds set [find where leds="user-led"] type=on
} else={
/system leds set [find where leds="user-led"] type=off;
}
}

I'm not sure if all setting is done properly, plus the System / LED setting in the WEB GUI is mandatory or not for the user led (or indifferent)
If anyone can guide me where the problem exists, then would be fine.

Prior thanks to your recoemmendations.
Pal
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12021
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: User-LED script to monitor a specific route  [SOLVED]

Thu Oct 19, 2023 5:16 pm

You can't add everytime the led, or the 2nd run throw an error.

Creating "led" and the "route" must one preparatory part than must be done before...

Write the code on more clear way...

working code

/system leds
:if ([/ip route get [find where comment="LED"] active]) do={
    set [find where leds="user-led"] type=on
} else={
    set [find where leds="user-led"] type=off
}
 
aszodi
just joined
Topic Author
Posts: 10
Joined: Fri Nov 16, 2018 2:45 pm

Re: User-LED script to monitor a specific route

Thu Oct 19, 2023 7:20 pm

Hello,
thank you for the tip, but this also does not work in System >Script section.
If I run the script with the "Run Script" button(or a created scheduler task reaches the 60 seconds) LED not changing to on.
Steady off.
I have RB750Gr3 with latest OS 7.11.2.
If I set the LED from the System/LEDs menu (GUI) to set on or off, then it's ok. Seems that the script is not controlling the LED this way.
Any other tought?

Prior thanks.
You do not have the required permissions to view the files attached to this post.
 
aszodi
just joined
Topic Author
Posts: 10
Joined: Fri Nov 16, 2018 2:45 pm

Re: User-LED script to monitor a specific route

Thu Oct 19, 2023 7:43 pm

Hi,
I would correct my self.
The script works well. :D
Precondition is to Enable and configure an Off state to the user LED.
After the setting, script runs immediately and LED follows the condition.

Thank you the help.

Who is online

Users browsing this forum: No registered users and 4 guests