Update powerwall.sh

This commit is contained in:
2023-08-14 22:39:40 -05:00
parent 517072499a
commit 74687e04ee

View File

@@ -94,16 +94,13 @@ CHECKTEMPSENSOR(){
fi fi
elif [ "${PW_SENSOR_TYPE[${1}]}" == "esxi" ]; then elif [ "${PW_SENSOR_TYPE[${1}]}" == "esxi" ]; then
temp_c=${2} temp_c=${2}
temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32")
# temp_warn=$(bc <<< "scale=2; (${3}*1.8+32)/1")
temp_warn=`echo $(bc <<< "scale=2; (${3}*1.8+32)/1") | awk '{print int($1+0.5)}'` temp_warn=`echo $(bc <<< "scale=2; (${3}*1.8+32)/1") | awk '{print int($1+0.5)}'`
# temp_crit=$(bc <<< "scale=2; (${4}*1.8+32)/1")
temp_crit=`echo $(bc <<< "scale=2; (${4}*1.8+32)/1") | awk '{print int($1+0.5)}'` temp_crit=`echo $(bc <<< "scale=2; (${4}*1.8+32)/1") | awk '{print int($1+0.5)}'`
fi fi
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
temp_f=`echo "scale=1; ${temp_c}*1.8 + 32" | bc` temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32")
#echo "$temp_c -> $temp_f" #echo "$temp_c -> $temp_f"
c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ $c = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done
c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done c=0; spca=''; spc1=`expr 6 - ${#average}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr ${c} + 1`; done
@@ -154,10 +151,9 @@ CHECKTEMP_SERVICE(){
for SENSOR in ${!PW_SENSOR_ID[@]}; do for SENSOR in ${!PW_SENSOR_ID[@]}; do
logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR} logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR}
[ ! -f ${logtemp} ] && touch ${logtemp} [ ! -f ${logtemp} ] && touch ${logtemp}
errtime=$(expr `date +%s` - $(stat -c %Y ${logtemp})) logtime=$(expr `date +%s` - $(stat -c %Y ${logtemp}))
[ $errtime -ge 3600 ] && relog=1 || relog=0 [ ${logtime} -ge 3600 ] && relog=1 || relog=0
if [ "${PW_SENSOR_TYPE[${SENSOR}]}" != "esxi" ]; then
if [ "${PW_REMOTE_SENSORS[${SENSOR}]}" == "" ] || ([ "${PW_REMOTE_SENSORS[${SENSOR}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSOR}]})" != "false" ]); then if [ "${PW_REMOTE_SENSORS[${SENSOR}]}" == "" ] || ([ "${PW_REMOTE_SENSORS[${SENSOR}]}" != "" ] && [ "$(CHECK_HOST ${PW_REMOTE_SENSORS[${SENSOR}]})" != "false" ]); then
if [ -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then if [ -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then
SENDNOTICE "${SENSOR} Online" "${SENSOR} Sensor is back online" SENDNOTICE "${SENSOR} Online" "${SENSOR} Sensor is back online"
@@ -182,8 +178,10 @@ CHECKTEMP_SERVICE(){
temp_h='' temp_h=''
fi fi
datetime=`date +'%Y-%m-%d %H:%M:%S'`
datetime=`date +'%Y-%m-%d %H:%M:%S'`
logtemp=${PW_LOGFOLDER}/log-temp-${SENSOR}
if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then if [ "$temp_c" != "null" ] && [ "$temp_c" != "" ]; then
if [ -f ${PW_TMPFOLDER}/${SENSOR}-error.reading ]; then if [ -f ${PW_TMPFOLDER}/${SENSOR}-error.reading ]; then
SENDNOTICE "${SENSOR} Data" "${SENSOR} is reporting data again" SENDNOTICE "${SENSOR} Data" "${SENSOR} is reporting data again"
@@ -197,6 +195,8 @@ CHECKTEMP_SERVICE(){
echo ${PW_TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 2 | read temp_crit echo ${PW_TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 2 | read temp_crit
echo ${PW_TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 3 | read temp_crit_sys echo ${PW_TEMP_THRESHOLDS[${SENSOR}]} | cut -d',' -f 3 | read temp_crit_sys
echo "HERE: ${SENSOR} - ${temp_f} - ${temp_warn} - ${temnp_crit}"
if [ "${last_temp[${SENSOR}]}" != "" ]; then if [ "${last_temp[${SENSOR}]}" != "" ]; then
temp_diff=`expr ${last_temp[${SENSOR}]%.*} - ${temp_f%.*}` temp_diff=`expr ${last_temp[${SENSOR}]%.*} - ${temp_f%.*}`
[ $temp_diff -lt 0 ] && temp_diff=$(($temp_diff * -1)) [ $temp_diff -lt 0 ] && temp_diff=$(($temp_diff * -1))
@@ -300,8 +300,6 @@ CHECKTEMP_SERVICE(){
fi fi
fi
done done
sleep 10 sleep 10