Hi,
even I am not doing shutdown, I am using following script for monitoring/logging health values:
ros code
# Define global variables
:global TempLast
:global VoltLast
# Define and fill actual values
:local TempAct [/system health get temperature]
:local VoltRAW [/system health get voltage]
# Divide voltage by 10 as it is 10 times multiplicated
:local VoltAct [ ($VoltRAW / 10) ]
# Calculate differences between last and actual values
:local TempDiff [ ($TempAct - $TempLast) ]
:local VoltDiff [ ($VoltAct - $VoltLast) ]
:tonum TempDiff
:tonum VoltDiff
# Calculate absolute values of differences
:if ( $TempDiff < 0 ) do={ :set TempDiff [ ( 0 - $TempDiff ) ] }
:if ( $VoltDiff < 0 ) do={ :set VoltDiff [ ( 0 - $VoltDiff ) ] }
# Do the reporting
:if ( $TempDiff >= 1 ) do={ :log info ("Environment: Last Temperature was $TempLast C. Actual Temperature is $TempAct C.") }
:if ( $VoltDiff >= 1 ) do={ :log info ("Environment: Last Voltage was $VoltLast V. Actual Voltage is $VoltAct V.") }
:if ( $TempDiff >= 1 ) do={ :set TempLast $TempAct }
:if ( $VoltDiff >= 1 ) do={ :set VoltLast $VoltAct }
# Debugging info below....
#:log info $TempAct
#:log info $VoltAct
#:log info $TempDiff
#:log info $VoltDiff
#:log info ("Environment: Actual Temperature is $TempAct C. Voltage is $VoltAct V.")
You can get ispired and add conditional system shutdown.
Remember, that you need somehow to start the system, as after shutdown the device needs power recycle to start up, otherwise it stays swithed off...
Hi all ...
I want to ask, could we create a script to monitor the voltage and send alarms to the Telegram?
Namely:
Enter the VoltAlarmMAX and VoltAlarmMIN script variables
to find out the current voltage
The script will sense the voltage at 10 intervals when it detects a drop below VoltAlarmMIN sends a message, then begins monitoring and each time it drops by 0.5Volt, it sends a message with current voltage, (example: WARNING, power failure - current voltage is xyVolt), and It will send it until the power comes on, ie If the voltage level is bigger to or equal to VoltAlarmMAX, then it sends a message (example: Power restored - current voltage is xyVolt), no more messages are sent, only if the voltage drops below VoltAlarmMIN, and the cycle repeats ...