From 742d5427c1d182d8ffecbd127b163236b76ab05b Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 14 May 2023 21:04:24 -0500 Subject: [PATCH] update --- defaults.inc | 5 +++++ powerwall.sh | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/defaults.inc b/defaults.inc index 112fde9f..f70cb3d0 100755 --- a/defaults.inc +++ b/defaults.inc @@ -22,8 +22,13 @@ declare -A TEMP_THRESHOLDS TEMP_THRESHOLDS['ServerRoomTH']="83,88,95" +declare -A SENSOR_TYPE +SENSOR_TYPE['ServerRoomTH']='mqtt' +SENSOR_TYPE['RaspberryPI-CPU']='system' + declare -A SENSOR_ID SENSOR_ID['ServerRoomTH']='2' +SENSOR_ID['RaspberryPI-CPU']='6' declare -A POWERWALL_SERVICES POWERWALL_SERVICES['ServerRoomTH']='monitor-serverroomth' diff --git a/powerwall.sh b/powerwall.sh index 1cd2cf79..76e254c0 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -41,16 +41,23 @@ CHECKTEMP(){ echo } CHECKTEMPSENSOR(){ - mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` - echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c + echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn + echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit + + if [ "${SENSOR_TYPE[${1}]}" == "mqtt" ]; then + mqtt_message=`${mqtt_conn} -t tele/${1}/SENSOR -C 1` + echo $mqtt_message | cut -d':' -f 6 | cut -d',' -f 1 | read temp_c + + elif [ "${SENSOR_TYPE[${1}]}" == "system" ]; then + temp_c=$(vcgencmd measure_temp) + temp_c=${test%\'*}; temp_c=${test#*=} + + fi if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then temp_f=`echo "scale=2; $temp_c*1.8 + 32" | bc` #echo "$temp_c -> $temp_f" - echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 1 | read temp_warn - echo ${TEMP_THRESHOLDS[${1}]} | cut -d',' -f 2 | read temp_crit - if [ $(bc -l <<< "$temp_f >= $temp_warn") -eq 1 ] && [ $(bc -l <<< "$temp_f < $temp_crit") -eq 1 ]; then echo -en "${idsCL[LightMagenta]}WARNING - $temp_f°F${idsCL[Default]}" elif [ $(bc -l <<< "$temp_f >= $temp_crit") -eq 1 ]; then