From 583c0e1fabe8331454efff646f98992031c6a815 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 9 May 2024 22:42:57 -0500 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 7ec4b48a..2604ca9b 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -157,6 +157,44 @@ 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=" " lclr="${idsCL[Yellow]}" @@ -215,44 +253,6 @@ CHECKTEMP(){ echo -e "${idsCL[Default]}" 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 - 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