Update powerwall.sh

This commit is contained in:
2023-12-03 17:28:14 -06:00
parent 720200affc
commit 5e4564b278

View File

@@ -144,17 +144,15 @@ CHECKTEMPSENSOR(){
elif [ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ]; then
if [ "${1}" == "Powerwall-CPU-Usage" ]; then
echo "WOW1"
temp_c=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g')
else
echo "WOW2"
temp_c=$(ssh -q -o ConnectTimeout=1 -o ConnectionAttempts=1 root@${PW_REMOTE_SENSORS[${1}]} "/opt/idssys/defaults/get-data.sh cpu-usage")
fi
fi
if [ "${temp_c}" != "null" ] && [ "${temp_c}" != "" ]; then
[ "${PW_SENSOR_TYPE[${1}]}" == "cpu" ] && temp_f=$(echo "scale=2; $temp_c/1" | bc -l) || temp_f=$(bc <<< "scale=1; ${temp_c}*1.8+32")
echo "HERE: '${temp_c}' -> '${temp_f}'"
# echo "HERE: '${temp_c}' -> '${temp_f}'"
# echo -en ""
c=0; spct=''; spc1=`expr 6 - ${#temp_f}`; until [ ${c} = ${spc1} ]; do spct="${spct} "; c=`expr ${c} + 1`; done