Sfoglia il codice sorgente

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 anni fa
parent
commit
874ffe92b0
1 ha cambiato i file con 29 aggiunte e 0 eliminazioni
  1. +29
    -0
      getdailyprod.sh

+ 29
- 0
getdailyprod.sh Vedi File

@@ -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

Caricamento…
Annulla
Salva