From 9de38a0c62ee236910e68a80289f0a10bb2a7884 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 14 Dec 2023 18:52:30 -0600 Subject: [PATCH] Update temp.inc.sh --- inc/temp.inc.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index f6294fed..9d3d1263 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -252,8 +252,12 @@ CHECKTEMP_SERVICE(){ echo ${mqtt_message} | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c elif [ "${PW_SENSOR_TYPE[${1}]}" == "lacrosse" ]; then - temp_c=$(GET_LACROSSE_INFO "${1}" "probe_temp") - temp_h=$(GET_LACROSSE_INFO "${1}" "humidity") + INFO=$(/bin/python3 ${PW_INCFOLDER}/getInfo.lacrosse.py "${PW_LACROSSE_ID['ServerRoomLA']}" | 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']} + temp_h=${DEVICE_INFO['humidity']} elif [ "${PW_SENSOR_TYPE[${SENSORa}]}" == "system" ]; then temp_c=$(vcgencmd measure_temp) @@ -302,8 +306,15 @@ CHECKTEMP_SERVICE(){ fi - [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ] && temp_f=$(echo "scale=2; $temp_c/1" | bc -l) || temp_f=$(echo "scale=2; ${temp_c}*1.8 + 32" | bc) - [ "${SENSOR}" == "ServerRoomTH" ] && temp_f=`echo "scale=2; ${temp_f}+${PW_ServerRoomTH_Dev}" | bc` + if [ "${SENSOR}" == "ServerRoomTH" ]; then + temp_f=`echo "scale=1; $(bc <<< "scale=1; ${temp_c}*1.8+32")+${PW_ServerRoomTH_Dev}" | bc` + elif [ "${SENSOR}" == "ServerRoomLA" ]; then + temp_f=${temp_c} + else + [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "cpu" ] && temp_f=$(echo "scale=2; $temp_c/1" | bc -l) || temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32") + (( $(bc <<<"${temp_f} < 1") )) && [[ "${temp_f}" = *"."* ]] && temp_f="0${temp_f}" + fi + # echo "HERE: [${SENSOR//-/}] - ${last_temp[${SENSOR//-/}]} - ${temp_c} - ${temp_f} - ${temp_warn} - ${temp_crit} - ${temp_crit_sys}" # [ ! "${temp_c}" ] || [ ! "${temp_f}" ] || [ ! "${temp_warn}" ] || [ ! "${temp_crit}" ] || [ ! "${temp_crit_sys}" ] && echo "VALUE NOT FOUND" @@ -531,13 +542,8 @@ GET_LACROSSE_INFO(){ 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 + echo ${DEVICE_INFO['probe_temp']}" } -INFO=$(/bin/python3 ${PW_INCFOLDER}/getInfo.lacrosse.py "${PW_LACROSSE_ID['ServerRoomLA']}" | 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 -echo "HERE: ${DEVICE_INFO['probe_temp']}" - -