diff --git a/powerwall.sh b/powerwall.sh index 3af31a09..8fc16fc0 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -37,11 +37,12 @@ CHECKTEMP(){ echo -en "\r\033[K" if [ ${#vHOSTDATA[@]} > 1 ]; then for sensordata in "${vHOSTDATA[@]}"; do + echo -en 1 vSENSOR=$(echo ${sensordata} | cut -d'T' -f1 | xargs) temp_c=$(echo ${sensordata} | cut -d'p' -f2 | awk '/ / {print $2}' | sed -e 's/C//g'); temp_c=${temp_c/ /} temp_warn=$(echo ${sensordata} | cut -d'p' -f2 | awk '/ / {print $7}' | sed -e 's/C//g'); temp_warn=${temp_warn/ /} temp_crit=$(echo ${sensordata} | cut -d'p' -f2 | awk '/ / {print $4}' | sed -e 's/C//g'); temp_crit=${temp_crit/ /} - + echo -en 2 reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit}) 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}" @@ -75,11 +76,10 @@ 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 @@ -101,7 +101,7 @@ CHECKTEMPSENSOR(){ temp_crit=$(bc <<< "scale=2; ${4}*1.8+32") fi - 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"