Update powerwall.sh

This commit is contained in:
2023-10-11 22:22:43 -05:00
parent 4ed1d83c69
commit b5baf01420

View File

@@ -76,7 +76,7 @@ CHECKTEMP(){
CHECKTEMPSENSOR(){ CHECKTEMPSENSOR(){
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn
echo ${PW_TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit 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=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3 ${5}) # [ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ] && average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) || average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3 ${5})
if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
@@ -103,17 +103,18 @@ CHECKTEMPSENSOR(){
temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32") temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32")
#echo "$temp_c -> $temp_f" #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; 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; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
#
if [ "${average}" == "" ]; then # if [ "${average}" == "" ]; then
averagedisp="${idsCL[Green]}" # averagedisp="${idsCL[Green]}"
elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then # elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
averagedisp="${idsCL[Yellow]}${average}'F" # 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" # averagedisp="${idsCL[Red]}${average}'F"
else # else
averagedisp="${idsCL[Green]}${average}'F" # averagedisp="${idsCL[Green]}${average}'F"
fi # fi
averagedisp=''
if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then
echo -en "${idsCL[Yellow]}WARNING (${spct}${temp_f}'F / ${spca}${averagedisp}${idsCL[Yellow]})${idsCL[Default]}" echo -en "${idsCL[Yellow]}WARNING (${spct}${temp_f}'F / ${spca}${averagedisp}${idsCL[Yellow]})${idsCL[Default]}"