From 6a219ef3505a0f5507e702be9638f58a3d149676 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 9 May 2024 21:01:54 -0500 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 1a79b0d5..4c714471 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -218,22 +218,27 @@ CHECKTEMP(){ 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")) - if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f[1]}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[White]}" - elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[LightRed]}" - lico="\u25B2" - elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then - lclr="${idsCL[Magenta]}" - lico="\u25B2" - elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then - lclr="${idsCL[LightGreen]}" - lico="\u25BC" - elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -eq 1 ]; then - lclr="${idsCL[LightCyan]}" - lico="\u25BC" + if [ "${OLD_temp_f[1]}" != "" ]; then + if [ $(bc -l <<< "${temp_f} < $(echo "scale=2; ${OLD_temp_f[1]}+${PW_TEMPIND_DIFF}" | bc)") -eq 1 ] && [ $(bc -l <<< "$(echo "scale=2; ${OLD_temp_f[1]}-${PW_TEMPIND_DIFF}" | bc) < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[White]}" + elif [ $(bc -l <<< "$(bc <<< "scale=2; ${OLD_temp_f[1]}+(${PW_TEMPIND_DIFF}*2)") < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[LightRed]}" + lico="\u25B2" + elif [ $(bc -l <<< "${OLD_temp_f[1]} < ${temp_f}") -eq 1 ]; then + lclr="${idsCL[Magenta]}" + lico="\u25B2" + elif [ $(bc -l <<< "${temp_f} < $(bc <<< "scale=2; ${OLD_temp_f[1]}-(${PW_TEMPIND_DIFF}*2)")") -eq 1 ]; then + lclr="${idsCL[LightGreen]}" + lico="\u25BC" + elif [ $(bc -l <<< "${temp_f} < ${OLD_temp_f[1]}") -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 " " [ ${#M} -eq 2 ] && echo -n " "