Update powerwall.sh
This commit is contained in:
@@ -75,10 +75,11 @@ CHECKTEMP(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHECKTEMPSENSOR(){
|
CHECKTEMPSENSOR(){
|
||||||
|
echo -en 1
|
||||||
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=''
|
[ "${PW_SENSOR_TYPE[${1}]}" != "esxi" ] && average=$(AVERAGETEMP ${PW_SENSOR_ID[${1}]} 3) || average=''
|
||||||
|
echo -en 2
|
||||||
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`
|
||||||
echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c
|
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")
|
temp_crit=$(bc <<< "scale=2; ${4}*1.8+32")
|
||||||
|
|
||||||
fi
|
fi
|
||||||
echo -en 1
|
echo -en 3
|
||||||
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`
|
temp_f=`echo "scale=2; ${temp_c}*1.8 + 32" | bc`
|
||||||
#echo "$temp_c -> $temp_f"
|
#echo "$temp_c -> $temp_f"
|
||||||
@@ -116,7 +117,7 @@ CHECKTEMPSENSOR(){
|
|||||||
else
|
else
|
||||||
averagedisp="${idsCL[Green]}${average}'F"
|
averagedisp="${idsCL[Green]}${average}'F"
|
||||||
fi
|
fi
|
||||||
echo -en 2
|
|
||||||
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]}"
|
||||||
elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then
|
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
|
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_warn} == 2 ] && spcw=' ' || spcw=' '
|
||||||
[ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' '
|
[ ${#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 -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
|
fi
|
||||||
}
|
}
|
||||||
AVERAGETEMP(){
|
AVERAGETEMP(){
|
||||||
|
|||||||
Reference in New Issue
Block a user