use jq instead of sed

This commit is contained in:
Tim Connors 2023-10-16 13:28:09 +11:00
parent 14a744fc5c
commit 693509563c
1 changed files with 2 additions and 2 deletions

View File

@ -109,7 +109,7 @@ powerfactor() {
exit 0
else
res=$( curl -fsS --data-urlencode "cmnd=Status 8" http://$SWITCH/cm )
powerfactor=$( echo "$res" | sed 's/.*"Factor":\([0-9.]*\)[^0-9.]*.*/\1/' )
powerfactor=$( echo "$res" | jq -c '.StatusSNS.ENERGY.Factor' )
echo PowerFactor.value $powerfactor
fi
}
@ -128,7 +128,7 @@ energy() {
exit 0
else
res=$( curl -fsS --data-urlencode "cmnd=Status 8" http://$SWITCH/cm )
energy=$( echo "$res" | sed 's/.*"Total":\([0-9.]*\)[^0-9.]*.*/\1/' )
energy=$( echo "$res" | jq -c '.StatusSNS.ENERGY.Total' )
echo Energy.value $energy
fi
}