浏览代码

add script to extract from the logs some daily data...

Though this extracts consumption, it pulls it before the end of the day
and so will be off by about an hour..  partly because there isn't a
previous day number to pull, which makes getting the EXACT number a
bit hard...  likely can be done w/ math better..
main
John-Mark Gurney 4 年前
父节点
当前提交
874ffe92b0
共有 1 个文件被更改,包括 29 次插入0 次删除
  1. +29
    -0
      getdailyprod.sh

+ 29
- 0
getdailyprod.sh 查看文件

@@ -0,0 +1,29 @@
#!/bin/sh -

startday=$1

export TZ=America/Los_Angeles
getutctime() {
date -j -v 0H -v -1H -v 0M -v 0S -f %F "$1" +%s
}

getwhday() {
grep -h "^production $(echo "$1" | head -c 7)" solar.*.log | sort | head -n 1 | python -c '
import json
import sys
l = sys.stdin.readline()
data = json.loads(l.split(" ", 2)[2])
proddata = data["production"][1]
condata = data["consumption"][0]
print "\t%s\t%s\t%s\t%s\t%.03f\t%.03f" % (proddata["whToday"], proddata["whLastSevenDays"], float(proddata["whLastSevenDays"]) / 7, proddata["whLifetime"], condata["whToday"], condata["whLastSevenDays"])'
}

startepoch=$(getutctime "$startday")
now=$(date +%s)

printf "Date\t\twH\t\tlast 7\t\tavg last 7\tlifetime\tconsum today\tcon last 7\n"
while [ "$startepoch" -le "$now" ]; do
echo -n $(date -r "$startepoch" +%F)
getwhday "$startepoch"
startepoch=$(date -r "$startepoch" -v +1d +%s)
done

正在加载...
取消
保存