diff --git a/powerwall.sh b/powerwall.sh index 58c744de..b8886d7b 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -136,15 +136,28 @@ CHECKACV_SERVICE(){ if [ $voltstatus -lt 3 ]; then echo -e "($datetime) Power off or low voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "POWER ALERT - LOW POWER!!" $email_alert [ $VERBOSE = true ] && echo "($datetime) alert sent" + last_battvolt=$BATTVOLT fi voltstatus=3 BATTVOLT=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs ..battV') - [ $VERBOSE = true ] && echo "($datetime) Battery Voltage: ${BATTVOLT}V" - if [ ${BATTVOLT%.*} -lt ${min_acvolt} ]; then + if [ ${BATTVOLT%.*} -lt ${min_battvolt} ] && [ ${BATTVOLT%.*} -gt ${min_battvolt_sys} ]; then [ $VERBOSE = true ] && echo "($datetime) LOW BATTERY voltage: ${BATTVOLT}V" - [ $VERBOSE = true ] && echo "($datetime) Shutting down server..." + [ $VERBOSE = true ] && echo "($datetime) Shutting down main servers..." - + + elif [ ${BATTVOLT%.*} -le ${min_battvolt_sys} ]; then + [ $VERBOSE = true ] && echo "($datetime) SYSTEM LOW BATTERY voltage: ${BATTVOLT}V" + [ $VERBOSE = true ] && echo "($datetime) Shutting down all remaining servers..." + + else + [ $VERBOSE = true ] && echo "($datetime) Battery Voltage Nominal: ${BATTVOLT}V" + + fi + volt_diff=$((${last_battvolt%.*} - ${BATTVOLT%.*})) + [ $volt_diff -lt 0 ] && temp_diff=$(($volt_diff * -1)) + if [ $volt_diff -gt 0 ]; then + echo -e "($datetime) Battery Voltage: ${BATTVOLT}V" | mail -s "BATTERY VOLTAGE CHANGE" $email_alert + last_battvolt=$BATTVOLT fi fi sleep 10