From 7a3854a0e6020083db3d9b50ee7878faa1f5cc28 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 9 May 2024 22:46:03 -0500 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 78 +++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 2ca5fa76..2cad1613 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -157,43 +157,7 @@ CHECKTEMP(){ echo -en "${spca}" fi - if [ ${DETAILS} -eq 1 ]; then - DIVIDER . white ${PRI_WIDTH} - for M in 15 30 60 120; do - lico=" " - OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL ${M} MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${M} - 7) MINUTE) ORDER BY date ASC LIMIT 1")) - OLD_temp_f=${OLD_temp_f[1]} - if [ "${OLD_temp_f}" != "" ]; then - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[White]}" - lico="\u23F9" - elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[LightRed]}" - lico="\u25B2" - elif [ $(bc -l <<< "${OLD_temp_f} < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[Magenta]}" - lico="\u25B2" - elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then - lclr="${idsCL[LightGreen]}" - lico="\u25BC" - elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f}") -eq 1 ]; then - lclr="${idsCL[LightCyan]}" - lico="\u25BC" - else - lclr="${idsCL[Default]}" - fi - else - lclr="${idsCL[Default]}" - lico="\u22C5" - fi - ([ "${temp_h}" != "" ] && [ "${temp_h}" != "0" ]) && echo -en "${idsCL[White]}| " || echo -n " " - echo -en "${idsCL[Default]} " - [ ${#M} -eq 2 ] && echo -n " " - c=0; spc=''; spc1=`expr 7 - ${#OLD_temp_f}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done - echo -e "${lclr}~${M}m ago - ${lclr}${lico}${spc}${OLD_temp_f}${GAUGESH}" - done - - fi + else temp_f_disp=" " @@ -253,6 +217,44 @@ CHECKTEMP(){ echo -e "${idsCL[Default]}" fi + if [ ${DETAILS} -eq 1 ] && [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ] && [ "${temp_f}" != "timeout" ] && [ "${temp_f}" != "offline" ]; then + DIVIDER . white ${PRI_WIDTH} + for M in 15 30 60 120; do + lico=" " + OLD_temp_f=($(${mysql_conn} -e "SELECT temp FROM servermonitor.sensor_data WHERE sensorid='${PW_SENSOR_ID[${SENSOR}]}' AND date >= DATE_SUB(NOW(), INTERVAL ${M} MINUTE) AND date <= DATE_SUB(NOW(), INTERVAL $(expr ${M} - 7) MINUTE) ORDER BY date ASC LIMIT 1")) + OLD_temp_f=${OLD_temp_f[1]} + if [ "${OLD_temp_f}" != "" ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[White]}" + lico="\u23F9" + elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[LightRed]}" + lico="\u25B2" + elif [ $(bc -l <<< "${OLD_temp_f} < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[Magenta]}" + lico="\u25B2" + elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then + lclr="${idsCL[LightGreen]}" + lico="\u25BC" + elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f}") -eq 1 ]; then + lclr="${idsCL[LightCyan]}" + lico="\u25BC" + else + lclr="${idsCL[Default]}" + fi + else + lclr="${idsCL[Default]}" + lico="\u22C5" + fi + ([ "${temp_h}" != "" ] && [ "${temp_h}" != "0" ]) && echo -en "${idsCL[White]}| " || echo -n " " + echo -en "${idsCL[Default]} " + [ ${#M} -eq 2 ] && echo -n " " + c=0; spc=''; spc1=`expr 7 - ${#OLD_temp_f}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; ((c++)); done + echo -e "${lclr}~${M}m ago - ${lclr}${lico}${spc}${OLD_temp_f}${GAUGESH}" + done + + fi + if [ "${temp_h}" != "" ] && [ "${temp_h}" != "0" ]; then echo -en "${idsCL[White]}|-- ${idsCL[Cyan]}Humidity ${idsCL[LightCyan]}$(ROUND_NUMBER ${temp_h} 2)%" if [ "${avgdays}" != "noavg" ]; then @@ -262,7 +264,7 @@ CHECKTEMP(){ fi echo -e "${idsCL[Default]}" - if [ ${DETAILS} -eq 1 ]; then + if [ ${DETAILS} -eq 1 ] && [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then DIVIDER . lightCyan ${PRI_WIDTH} for M in 15 30 60 120; do lico=" "