Update powerwall.sh

This commit is contained in:
2023-07-06 18:36:33 -05:00
parent f3b5df2910
commit 24a78ab324

View File

@@ -231,31 +231,31 @@ NORMAL TEMP: ${temp_f}'F"
DAILYTEMP(){
cw=20;
echo
# echo -e "${idsCL[Yellow]}Sensor Temperature(s) ${idsCL[Green]}normal${idsCL[Default]} /${idsCL[Yellow]}warning${idsCL[Default]}/ ${idsCL[Red]}critical${idsCL[Default]}"
echo -e "${idsCL[Cyan]}Sensor Temperature(s) Current / 3DayAVG ${idsCL[Green]}normal${idsCL[Default]} /${idsCL[Yellow]}warning${idsCL[Default]}/ ${idsCL[Red]}critical${idsCL[Default]}"
echo -e "Sensor Temperature(s) Current / 1DayAVG / 7DayAVG"
DIVIDER . yellow 85
if [ "${1}" != "" ]; then
# reading=$(CHECKTEMPSENSOR ${1})
# c=0; spc=''; spc1=`expr ${cw} - ${#1}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
# echo -e "${idsCL[LightCyan]}${1}${spc}${idsCL[Default]}: ${reading}"
for SENSOR in ${!SENSOR_ID[@]}; do
average1=$(AVERAGETEMP ${SENSOR} 1)
average7=$(AVERAGETEMP ${SENSOR} 7)
if [ "${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
elif [ "${SENSOR_TYPE[${1}]}" == "system" ]; then
temp_c=$(vcgencmd measure_temp)
temp_c=${temp_c%\'*}; temp_c=${temp_c#*=}
fi
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc`
for SENSOR in ${!SENSOR_ID[@]}; do
if [[ "${SENSOR}" = *"${1}"* ]]; then
echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..."
reading=$(CHECKTEMPSENSOR ${SENSOR})
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]}${SENSOR}${spc}${idsCL[Default]}: ${reading}"
fi
done
else
for SENSOR in ${!SENSOR_ID[@]}; do
echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..."
reading=$(CHECKTEMPSENSOR ${SENSOR})
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]}${SENSOR}${spc}${idsCL[Default]}: ${reading}"
done
fi
echo -e "${SENSOR}${spc}: ${temp_f} / ${average1} / ${average7}"
fi
done
[ "${action}" != "" ] && echo
}