Update powerwall.sh

This commit is contained in:
2023-08-14 19:52:12 -05:00
parent 495fc82329
commit ecff631711

View File

@@ -75,10 +75,11 @@ CHECKTEMP(){
}
CHECKTEMPSENSOR(){
echo -en 1
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=''
echo -en 2
if [ "${PW_SENSOR_TYPE[${1}]}" == "mqtt" ]; then
mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1`
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
@@ -100,7 +101,7 @@ CHECKTEMPSENSOR(){
temp_crit=$(bc <<< "scale=2; ${4}*1.8+32")
fi
echo -en 1
echo -en 3
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
temp_f=`echo "scale=2; ${temp_c}*1.8 + 32" | bc`
#echo "$temp_c -> $temp_f"
@@ -116,7 +117,7 @@ CHECKTEMPSENSOR(){
else
averagedisp="${idsCL[Green]}${average}'F"
fi
echo -en 2
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]}"
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then
@@ -128,9 +129,7 @@ CHECKTEMPSENSOR(){
c=0; spc=''; spc1=`expr 10 - ${#tmp} - 2`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
[ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' '
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
echo -en 3
echo -e "${spc}[${spcw}${idsCL[Green]}<=$(expr ${temp_warn} - 1)'F${idsCL[Default]} /${spcw}${idsCL[Yellow]}${temp_warn}'F${idsCL[Default]} /${spcc}${idsCL[Red]}${temp_crit}'F=>${idsCL[Default]} ]"
echo -en 4
fi
}
AVERAGETEMP(){