Update powerwall.sh
This commit is contained in:
31
powerwall.sh
31
powerwall.sh
@@ -60,7 +60,7 @@ CHECKTEMP(){
|
|||||||
|
|
||||||
# echo "HERE: ${SENSOR} (${PW_SENSOR_ID[${SENSOR}]}) - ${vSENSOR// /_}"
|
# echo "HERE: ${SENSOR} (${PW_SENSOR_ID[${SENSOR}]}) - ${vSENSOR// /_}"
|
||||||
|
|
||||||
reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit} ${vSENSOR// /_})
|
reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit} ${vSENSOR// /_} ${1})
|
||||||
c=0; spc=''; spc1=`expr ${cw} - ${#vSENSOR} - 1`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
c=0; spc=''; spc1=`expr ${cw} - ${#vSENSOR} - 1`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
echo -e "${idsCL[LightCyan]} ${vSENSOR}${spc}${idsCL[Default]}: ${reading}"
|
echo -e "${idsCL[LightCyan]} ${vSENSOR}${spc}${idsCL[Default]}: ${reading}"
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ CHECKTEMP(){
|
|||||||
|
|
||||||
else
|
else
|
||||||
echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..."
|
echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..."
|
||||||
reading=$(CHECKTEMPSENSOR ${SENSOR})
|
reading=$(CHECKTEMPSENSOR ${SENSOR} . . . . ${1})
|
||||||
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
echo -e "\r\033[K${idsCL[LightCyan]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}"
|
echo -e "\r\033[K${idsCL[LightCyan]}${idsST[Bold]}${SENSOR}${idsST[Reset]}${spc}${idsCL[Default]}: ${reading}"
|
||||||
fi
|
fi
|
||||||
@@ -95,7 +95,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})
|
[ "${1}" != "noavg" ] && ([ "${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`
|
||||||
@@ -123,17 +123,20 @@ CHECKTEMPSENSOR(){
|
|||||||
#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
|
if [ "${1}" != "noavg" ]; then
|
||||||
# if [ "${average}" == "" ]; then
|
c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
|
||||||
# averagedisp="${idsCL[Green]}"
|
if [ "${average}" == "" ]; then
|
||||||
# elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
|
averagedisp="${idsCL[Green]}"
|
||||||
# averagedisp="${idsCL[Yellow]}${average}'F"
|
elif [ $(bc -l <<< "${average} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${average} < ${temp_crit}") -eq 1 ]; then
|
||||||
# elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
|
averagedisp="${idsCL[Yellow]}${average}'F"
|
||||||
# averagedisp="${idsCL[Red]}${average}'F"
|
elif [ $(bc -l <<< "${average} >= ${temp_crit}") -eq 1 ]; then
|
||||||
# else
|
averagedisp="${idsCL[Red]}${average}'F"
|
||||||
# averagedisp="${idsCL[Green]}${average}'F"
|
else
|
||||||
# fi
|
averagedisp="${idsCL[Green]}${average}'F"
|
||||||
averagedisp=' '
|
fi
|
||||||
|
else
|
||||||
|
averagedisp=' '
|
||||||
|
fi
|
||||||
|
|
||||||
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]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user