diff --git a/powerwall.sh b/powerwall.sh index 14905a39..b5ee221c 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -202,14 +202,15 @@ POWERLOGGER_SERVICE(){ while true do datetime=`date +'%Y-%m-%d %H:%M:%S'` - outV=$(curl -s "http://10.10.0.61/stats.json" | jq '.outputs .outV') - outA=$(curl -s "http://10.10.0.61/stats.json" | jq '.outputs .outA') - inV=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .inV') - inA=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .inA') - battV=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .battV') - battA=$(curl -s "http://10.10.0.61/stats.json" | jq '.inputs .xfA') + JSONSTATS=$(curl -s "http://10.10.0.61/stats.json") - + inV=`echo ${JSONSTATS} | jq '.inputs .inV'` + inA=`echo ${JSONSTATS} | jq '.inputs .inA'` + outV=`echo ${JSONSTATS} | jq '.outputs .outV'` + outA=`echo ${JSONSTATS} | jq '.outputs .outA'` + battV=`echo ${JSONSTATS} | jq '.inputs .battV'` + xfA=`echo ${JSONSTATS} | jq '.inputs .xfA'` + QRY="USE servermonitor; INSERT INTO power_data (\`sensorid\`, \`date\`, \`volt\`, \`amp\`) VALUES ('2','${datetime}','${inV}','${inA}')" QRY="${QRY}; INSERT INTO power_data (\`sensorid\`, \`date\`, \`volt\`, \`amp\`) VALUES ('3','${datetime}','${outV}','${outA}')" QRY="${QRY}; INSERT INTO power_data (\`sensorid\`, \`date\`, \`volt\`, \`amp\`) VALUES ('4','${datetime}','${battV}','${battA}')"