diff --git a/powerwall.sh b/powerwall.sh index 4a1d5ef2..596408a7 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -92,10 +92,17 @@ CHECKTEMP(){ } CHECKTEMPSENSOR(){ - echo "HERE: ${6}" echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit - [ "${6}" != "noavg" ] && ([ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ] && average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) || average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3 ${5})) + if [ "${6}" != "noavg" ]; then + if [ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ]; then + average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) + else + average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3 ${5}) + fi + else + average='' + fi if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` @@ -123,7 +130,7 @@ CHECKTEMPSENSOR(){ #echo "$temp_c -> $temp_f" c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done - if [ "${6}" != "noavg" ]; then + if [ "${average}" != "" ]; then c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done if [ "${average}" == "" ]; then averagedisp="${idsCL[Green]}"