I am very limited in my script knowledge sorry, so can someone help me with this:
I have had this script running (adapted from: http://wiki.mikrotik.com/wiki/Monitor_input_voltage_on_RB333/433AH) to log my solar voltages.
It doesn’t give any errors, but no email turns up if i set the lowvoltalarm below current voltage.
Can anyone see any problems or changes that i need now, with the new upgrade?
#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 118
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:local thisbox [/system identity get name]
:global voltage [/system health get voltage]
:local thistime [/system clock get time]
:local thisdate [/system clock get date]
:local thishour [:pick $thistime 0 2]
:local emessage ($thisbox . " voltage is " . [:pick $voltage 0 2] . “.” . [:pick $voltage 2 3])
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}
set your email address in the next line
:if ($voltage <= $lowvoltalarm) do={/tool e-mail send to=“myemail@gmail.com” subject=“$thisbox low voltage” body=$emessage from=RB750UP tls=yes}
:if ($voltage > $highvolt) do={:set highvolt $voltage; :set hivolttime ($thistime . " " . $thisdate)}
:if ($voltage < $lowvolt) do={:set lowvolt $voltage; :set lovolttime ($thistime . " " . $thisdate)}
:if ([:len $vh] > 0) do={:set vh ([:toarray $voltage] + $vh)} else={:set vh [:toarray $voltage]}
:if ([:len $starttime] < 1) do={:set starttime ($thistime . " " . $thisdate)}
:if ($thishour = “23”) do={:execute voltreport}
also any issues here:
:global highvolt
:global lowvolt
:global hivolttime
:global lovolttime
:global starttime
:global vh
:local tvolt
:local thisbox [/system identity get name]
:local thisdate [/system clock get date]
:local thishour
:local emessage “Voltage report for $thisbox on $thisdate\n\n”
:if ([:len $vh] > 0) do={
:for x from=0 to=([:len $vh]-1) step=1 do={
:set tvolt [:tostr [:pick $vh $x]]
:set thishour [:tostr (23 - $x)]
:while ([:len $thishour] < 2) do={:set thishour (“0” . $thishour)}
:set emessage ($emessage . $thishour . ":00 = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . “\n”)
}
:set emessage ($emessage . "\nSince voltmonitor started on " . $starttime . “\n”)
:set tvolt [:tostr $highvolt]
:set emessage ($emessage . "Maximum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $hivolttime . “\n”)
:set tvolt [:tostr $lowvolt]
:set emessage ($emessage . "Minimum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $lovolttime . “\n”)
set email address in next line
/tool e-mail send to=“myemail@gmail.com” subject=“$thisbox Voltage Report” body=$emessage from=myemail@gmail.com tls=yes
}
remark out the next line for testing to avoid resetting the voltage array
:set vh
First script now doesn’t seem to call the second at 23 o’clock! This all used to work … ![]()