From f94f8cd5994e02d86a111e84ac67fe27b7228316 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 3 Sep 2022 12:05:52 -0500 Subject: [PATCH] Update powerwall.sh --- powerwall.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/powerwall.sh b/powerwall.sh index bfa2aff8..a59843d0 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -16,6 +16,26 @@ shopt -s lastpipe #ssh root@10.5.10.35 '/vmfs/volumes/NFS_ESXi-Vault/esxi-shutdown.sh > /dev/null 2>&1' & > /dev/null 2>&1 CHECKTEMP(){ + mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` + echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c + if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then + temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc` + #echo "$temp_c -> $temp_f" + + echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn + echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit + + if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then + echo "WARNING: $temp_f°F" + elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then + echo "CRITICAL: $temp_f°F" + else + echo "normal: $temp_f°F" + fi + fi +} + +CHECKTEMP_SERVICE(){ mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then @@ -39,7 +59,6 @@ CHECKTEMP(){ - if [ ${action-x} ]; then case $action in checktemp) CHECKTEMP ${2};;