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
1.0 KiB

  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%14.03f\t%14.03f\t%14.03f\t%14.03f\t%14.03f\t%14.03f\t%14.03f" % (float(proddata["whToday"]), float(proddata["whLastSevenDays"]), float(proddata["whLastSevenDays"]) / 7, float(proddata["whLifetime"]), float(condata["whToday"]), float(condata["whLastSevenDays"]), float(condata["whLastSevenDays"]) / 7)'
  16. }
  17. startepoch=$(getutctime "$startday")
  18. now=$(date +%s)
  19. printf "Date\t\t%14s\t%14s\t%14s\t%14s\t%14s\t%14s\t%14s\n" wH "last 7" "avg last 7" "lifetime" "consum today" "con last 7" "con last 7 avg"
  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