ソースを参照

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
コミット
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

読み込み中…
キャンセル
保存