From 250c1d63532e191a0b8c8ec95cf700f6718f3682 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 14 Aug 2023 19:33:17 -0500 Subject: [PATCH] Update powerwall.sh --- powerwall.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/powerwall.sh b/powerwall.sh index dba4141d..f871cfee 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -76,7 +76,7 @@ CHECKTEMP(){ CHECKTEMPSENSOR(){ echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit - [ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ] && average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) || average=${2} + [ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ] && average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) || average=0 if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` @@ -100,15 +100,17 @@ CHECKTEMPSENSOR(){ fi - if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then + if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc` #echo "$temp_c -> $temp_f" - c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr $c + 1`; done - c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr $c + 1`; done + c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done + c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done - if [ $(bc -l <<< "$average >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$average < $temp_crit") -eq 1 ]; then + if [ ${average} -eq 0 ]; then + averagedisp=' ' + elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then averagedisp="${idsCL[Yellow]}${average}'F" - elif [ $(bc -l <<< "$average >= $temp_crit") -eq 1 ]; then + elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then averagedisp="${idsCL[Red]}${average}'F" else averagedisp="${idsCL[Green]}${average}'F"