Update power.inc.sh

This commit is contained in:
2024-01-13 10:18:23 -06:00
parent 9aa81123bb
commit 4548138d12

View File

@@ -6,7 +6,7 @@ AVERAGEPOWER(){
total_amp=0
total_watt=0
while IFS=$'\t' read date amp watt ;do
if [ "${amp}" != "" ] && [ "${watt}" != "" ]; then
if [[ "${amp}" =~ ^[0-9]+$ ]] && [[ "${watt}" =~ ^[0-9]+$ ]]; then
total_amp=$(bc <<< "scale=2; ${total_amp}+${amp}")
total_watt=$(bc <<< "scale=2; ${total_watt}+${watt}")
((logsfound++))
@@ -24,7 +24,7 @@ AVERAGEPOWER(){
total=0
[ "${3}" != "" ] && ptype=${3} || ptype=watt
while IFS=$'\t' read date ${ptype} ;do
if [ "${!ptype}" != "" ]; then
if [[[ "${!ptype}" =~ ^[0-9]+$ ]]; then
total=$(bc <<< "scale=2; ${total}+${!ptype}")
((logsfound++))
fi