Hello,
I have been running a voltage monitoring script with great success for a while now.
I am now trying to run this same script on the latest firmware (7.10.2) and it is not running at all.
Where I have problem?
Here is my script:
#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 255
:global highvoltalarm 260
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:global lastvoltage
: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 . " !!!_POWER is UP_!!! - current voltage is: " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
:local emessage1 ($thisbox . " !!!_POWER is DOWN_!!! - SYSTEM RUNS ON THE BACKUP - current voltage is: " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}
# set your Telegram ID in the next line
# Configure Telegram
:local CHID "-XXXXXXXXXX";
:local BotID "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
:if ($voltage <= $highvoltalarm) do={/tool fetch "https://api.telegram.org/bot$BotID/send ... $emessage1" keep-result=no;}
: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)}
:set $lastvoltage $voltage