From 595320be14c2400d7ee6129f55c437569d03e468 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 14 Dec 2023 22:07:28 -0600 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index 436aac10..b9d8cc17 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -107,13 +107,10 @@ CHECKTEMPSENSOR(){ echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then - # INFO=$(/bin/python3 ${PW_INCFOLDER}/getInfo.lacrosse.py "${PW_LACROSSE_ID[${1}]}" | sed -e "s/\[{'//g" | sed -e "s/}\]//g" | sed -e "s/', '/~/g" | sed -e "s/': '/:/g" | sed -e "s/': /:/g") - # IFS=$'~'; read -rd '' -a INFO <<<"${INFO}"; unset IFS; declare -A DEVICE_INFO - # for DINFOtmp in "${INFO[@]}"; do key=${DINFOtmp%%:*}; val=${DINFOtmp##*:}; val=${val//[$'\t\r\n ']}; DEVICE_INFO[${key}]=${val}; done - # temp_c=${DEVICE_INFO['probe_temp']} INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${1}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq) - temp_c=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') - + temp_c=$(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') + temp_probe=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') + elif [ "${PW_SENSOR_TYPE[${1}]}" == "system" ]; then temp_c=$(vcgencmd measure_temp) temp_c=${temp_c%\'*}; temp_c=${temp_c#*=} @@ -174,6 +171,24 @@ CHECKTEMPSENSOR(){ [ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' ' [ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' ' echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]" + + if [ "${1}" == "ServerRoomLA" ]; then + if [ $(bc -l <<< "${temp_probe} >= ${temp_warn}") -eq 1 ] && [ $(bc -l <<< "${temp_probe} < ${temp_crit}") -eq 1 ]; then + echo -en "${idsCL[Yellow]}WARNING ${spct}${temp_probe}${GAUGESH}${idsCL[Default]}" + elif [ $(bc -l <<< "${temp_probe} >= ${temp_crit}") -eq 1 ]; then + echo -en "${idsCL[LightRed]}CRITICAL${spct}${temp_probe}${GAUGESH}${idsCL[Default]}" + else + echo -en "${idsCL[Green]}Normal ${spct}${temp_probe}${GAUGESH}${idsCL[Default]}" + fi + + tmp="${spct}${temp_probe}" + c=0; spc=''; spc1=`expr 10 - ${#tmp}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done + [ ${#temp_warn} == 2 ] && spcw=' ' || spcw=' ' + [ ${#temp_crit} == 2 ] && spcc=' ' || spcc=' ' + echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR}-Probe${idsST[Reset]}${spc}${idsCL[Default]}: " + echo -e "${spc}[${spcw}${idsCL[Yellow]}${temp_warn}${GAUGESH}${idsCL[Default]} /${spcc}${idsCL[LightRed]}${temp_crit}${GAUGESH}=>${idsCL[Default]} ]" + fi + fi } AVERAGETEMP(){ @@ -254,6 +269,13 @@ CHECKTEMP_SERVICE(){ echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c elif [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "lacrosse" ]; then + INFO=$(curl -s --get -d "deviceid=${PW_LACROSSE_ID[${1}]}" -d "limit=1" -d "metric=1" -d "timezone=2" https://decent-destiny-704.appspot.com/laxservices/device_info.php | jq) + temp_c=$(echo ${INFO} | jq -r '.device0 .obs[].ambient_temp') + temp_probe=$(echo ${INFO} | jq -r '.device0 .obs[].probe_temp') + temp_h=$(echo ${INFO} | jq -r '.device0 .obs[].humidity') + + + INFO=$(/bin/python3 ${PW_INCFOLDER}/getInfo.lacrosse.py "${PW_LACROSSE_ID[${SENSOR}]}" | sed -e "s/\[{'//g" | sed -e "s/}\]//g" | sed -e "s/', '/~/g" | sed -e "s/': '/:/g" | sed -e "s/': /:/g") IFS=$'~'; read -rd '' -a INFO <<<"${INFO}"; unset IFS; declare -A DEVICE_INFO for DINFOtmp in "${INFO[@]}"; do key=${DINFOtmp%%:*}; val=${DINFOtmp##*:}; val=${val//[$'\t\r\n ']}; DEVICE_INFO[${key}]=${val}; done