Update powerwall.sh

This commit is contained in:
2022-09-11 15:25:26 -05:00
parent 7af11f15a6
commit e39a8fb557

View File

@@ -111,28 +111,26 @@ CHECKTEMP_SERVICE(){
}
CHECKACV_SERVICE(){
last_volt=0
voltstatus=0
while true
do
INPUTACV=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .inV')
datetime=`date +'%Y-%m-%d %H:%M:%S'`
volt_diff=$((${last_volt%.*} - ${INPUTACV%.*}))
[ $volt_diff -lt 0 ] && volt_diff=$(($volt_diff * -1))
if [ ${INPUTACV%.*} -ge ${min_volt} ]; then
if [ ${INPUTACV} -ge ${min_volt} ]; then
echo "($datetime) normal voltage: ${INPUTACV}V"
if [ $last_volt -lt ${min_volt} ]; then
if [ $voltstatus -eq 3 ]; then
echo -e "($datetime) Normal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "POWER NOMINAL AGAIN" $email_alert
elif [ "$last_volt" = "0" ]; then
elif [ $voltstatus -eq 0 ]; then
echo -e "($datetime) Normal voltage detected\nVOLTAGE: ${INPUTACV}V" | mail -s "Power Nominal" $email_alert
fi
last_volt=1
else
last_volt=${INPUTACV}
echo "($datetime) LOW voltage: ${INPUTACV}V"
if [ $volt_diff -gt 1 ] || [ "$last_volt" = "1" ]; then
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
fi
voltstatus=3
fi
sleep 30
done # &