Hello,
I have a remote, solar-powered site with a RB5009(POE version). The 5009 is fully powered from the 5.5mm DC jack, from a DC-DC 24-56V converter. My battery system voltage is 24V, and I’m also feeding that battery voltage into the 2-pin connector of the 5009 as a voltage reference for running my script.
So far, I have built several working scripts, used to turn ON POE when the batteries are getting a good charge from solar, and turn OFF when the battery voltage drops off at night (I don’t need to run my camera and AP at night). By simply adjusting the turn on/off voltage, I can prioritize which devices turn on, given the state of battery charge.
The scripts seem to be working ok, but this is my first attempt at a script, and I was wondering if you could take a look at my script to see if there are any blatant errors or no-nos. Could you please have a look, and tell me if I need to make any corrections? Again, I have one of these scripts set up for each POE port device, and they are driven by a scheduler that runs them every 5 to 10 minutes, staggered, so they don’t all run at the same time.
Thank you in advance!
Here’s the script:
Name the Device Connected to Port
:local portdevice “Mast Camera”
Define which port to control
:local ethport LAN5
Define what battery voltage device will turn on at
:local cutinvolts 28.2
Define what battery voltage POE will be disabled at
:local shutoffvolts 25.4
Define the earliest hour POE will be turned on
:local ontimeearliest 6
Define the latest hour POE will be turned on
:local ontimelatest 12
#Gather System Information
:local voltmeter [/system/health get [find name=2pin-voltage] value]
:local poestatus;
/interface ethernet poe monitor $ethport once do={:set poestatus $“poe-out-status”;}
:local thistime [/system clock get time]
:local thishour [:pick $thistime 0 2]
#Argument to turn POE OFF
:if ($voltmeter <= $shutoffvolts && $poestatus = “powered-on”) do={
/interface ethernet poe set poe-out=off $ethport;
:log info message=(“$portdevice POE Disabled, Voltage = $voltmeter”)}
#Argument to turn POE ON
:if (($voltmeter >= $cutinvolts) && ($poestatus = “disabled”) && ($thishour >= $ontimeearliest) && ($thishour <= $ontimelatest)) do={
/interface ethernet poe set poe-out=forced-on $ethport;
:log info message=(“$portdevice POE Enabled, Voltage = $voltmeter”)}
Useless power dispersion… often cameras go also @24V…
28.2 ?
25.4 ?
RouterOS do not support floating numbers…
This are IPs…
> :put 28.2
28.0.0.2
> :put 25.4
25.0.0.4
When you pick the hours, if are “06”, is a string, must be converted to a number.
I do not have any RB5009UPr+S+IN to check how the system healt is get from script.
#!!! ROS v7.4+ only
:local portdevice “Mast Camera” ; # Name the Device Connected to Port
:local ethport “LAN5” ; # Define which port to control
:local cutinvolts “28.2” ; # Define what battery voltage device will turn on at
:local shutoffvolts “25.4” ; # Define what battery voltage POE will be disabled at
:local ontimeearliest 6 ; # Define the earliest hour POE will be turned on
:local ontimelatest 12 ; # Define the latest hour POE will be turned on
/system
:local thishour [:tonum [:pick [clock get time] 0 2]]
must be tested if return a string or not…
:local voltmeter [health get [find where name=“2pin-voltage”] value]
/interface ethernet poe
:local poestatus ([monitor $ethport once as-value]->“poe-out-status”)
Argument to turn POE OFF
:if (($voltmeter <= $shutoffvolts) and ($poestatus = “powered-on”)) do={
set $ethport poe-out=“off”
:log info “$portdevice POE Disabled, Voltage = $voltmeter”
}
Argument to turn POE ON
:if (($voltmeter >= $cutinvolts) and ($poestatus = “disabled”) and ($thishour >= $ontimeearliest) and ($thishour <= $ontimelatest)) do={
set $ethport poe-out=“forced-on”
:log info “$portdevice POE Enabled, Voltage = $voltmeter”
}
Why you check 2pin-voltage instead of jack-voltage???
Too much contraddiction…
“normalization” of the voltage.
for example “24.3”
contain a dot “.”?
if not add “0” at the end
if yes pick before and after the dot with find and join the values
convert to number what you obtain,
now you have dV and 243 are comparable with 235 dV
iis only “24”? the added 0 at the end converted all to number give 240 dV
Your script seems to works (well runs, I don’t have PoE used things RN). Yeah it’s jack-voltage. But confusing, that’s doesn’t 5.5/2.1 doesn’t have “2-pins”. And then you run into the no floats problem…
And, yeah, I’d forgot the [find where name…] trick myself and saw your updated your post since yeah “get” just returns an array