A module for interacting w/ the Enphase Enjoy solar controller. It currently has a simple program for logging data, such as production and per panel data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
879 B

  1. #!/bin/sh -
  2. startday=$1
  3. export TZ=America/Los_Angeles
  4. getutctime() {
  5. date -j -v 0H -v -1H -v 0M -v 0S -f %F "$1" +%s
  6. }
  7. getwhday() {
  8. grep -h "^production $(echo "$1" | head -c 7)" solar.*.log | sort | head -n 1 | python -c '
  9. import json
  10. import sys
  11. l = sys.stdin.readline()
  12. data = json.loads(l.split(" ", 2)[2])
  13. proddata = data["production"][1]
  14. condata = data["consumption"][0]
  15. 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"])'
  16. }
  17. startepoch=$(getutctime "$startday")
  18. now=$(date +%s)
  19. printf "Date\t\twH\t\tlast 7\t\tavg last 7\tlifetime\tconsum today\tcon last 7\n"
  20. while [ "$startepoch" -le "$now" ]; do
  21. echo -n $(date -r "$startepoch" +%F)
  22. getwhday "$startepoch"
  23. startepoch=$(date -r "$startepoch" -v +1d +%s)
  24. done