I wanted to see if I could pull data from my Enphase and stuff it in a graph for my own use. Turns out using the power of open source anything can be done. This is what I did:
I am setting this up on a CentOS 7 VM. I am already running Apache on it, I am not going to go over how to get that going.
Solar is the name of my Enphase Envoy. You will see it a couple times in the script. Replace it with your URL
# Install rrdtool and lynx (you will need the EPEL repos)
sudo yum install rrdtool lynx
#Then we create the database. I called mine enphase.rrd, you can name your what you want. You will just need to note the name in the script below.
sudo rrdtool create enphase.rrd -s 300 DS:temp:GAUGE:900:-55:125 RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:672 RRA:AVERAGE:0.5:24:732 RRA:AVERAGE:0.5:144:1460
#Now create the web directory.
sudo mkdir /var/www/html/enphase/
#I created the below script in /usr/local/bin/ and made it executable.
#!/bin/bash
# get the EPOCH date
DATE=$(/bin/date +%s)
# get to the right directory
cd /etc/enphase
# remove old files
rm ENPHASE.csv
rm kw2.txt
# Get the data and dump it into a CSV file
lynx -dump http://solar.hohenfels.com/production?locale=en | grep ly > kw.txt
# The Enphase Envoy uses Kilowatts (kW) and Watts (W). So a little creativity is required: If I find kW, clean it up, add the date and dump it in the CSV. If I dont find kW then clean it up and put it in a text file called kw2.txt. If it is not kW then it has to be W. when not producing it shows 0W
if grep -q 'kW' "kw.txt"; then
cat kw.txt | sed 's/[A-Za-z%]*//g' | sed -r 's/\s+//g' | sed 's/^/, /' | sed -e "s/^/$(date) /" >> ENPHASE.csv
else
cat kw.txt | sed 's/[A-Za-z%]*//g' | sed -r 's/\s+//g' > kw2.txt
fi
# Make the kw2.txt file a variable
KW2=$(cat kw2.txt)
# Do some math and get our variable into kW and dump it in the CSV.
/usr/bin/echo "scale=3; $KW2/1000" | bc -l |sed 's/^/, /' | sed -e "s/^/$(date) /" >> ENPHASE.csv
# Get the data into a variable we can use for RRD
KW=$(cat ENPHASE.csv | sed 's/[A-Za-z ]*//g' | cut -d"," -f2)
# I wanted to make sure things worked up to this point:
echo $KW >> debug.log
echo $DATE >> debug.log
# Finally get data into rrd
rrdtool update enphase.rrd $DATE:$KW
# create daily graph
rrdtool graph /var/www/html/enphase/enphase_day.png -s -1day DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa
# create weekly graph
rrdtool graph /var/www/html/enphase/enphase_week.png -s -1week DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa
# create monthly graph
rrdtool graph /var/www/html/enphase/enphase_month.png -s -1month DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa
# create yearly graph
rrdtool graph /var/www/html/enphase/enphase_year.png -s -1year DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa
##Here is the final daily product:

##Weekly

#Month

# Here it is with no mark-up:
#!/bin/bash
# get the EPOCH date
DATE=$(/bin/date +%s)
#get to the right directory
cd /etc/enphase
#remove old files
rm ENPHASE.csv
rm kw2.txt
#Get the data ready for a csv for MariaDB
lynx -dump http://solar.hohenfels.com/production?locale=en | grep ly > kw.txt
if grep -q ‘kW’ “kw.txt”; then
cat kw.txt | sed ‘s/[A-Za-z%]*//g’ | sed -r ‘s/\s+//g’ | sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> ENPHASE.csv
else
cat kw.txt | sed ‘s/[A-Za-z%]*//g’ | sed -r ‘s/\s+//g’ > kw2.txt
fi
KW2=$(cat kw2.txt)
/usr/bin/echo “scale=3; $KW2/1000” | bc -l |sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> ENPHASE.csv
#Get the data into a variable
KW=$(cat ENPHASE.csv | sed ‘s/[A-Za-z ]*//g’ | cut -d”,” -f2)
##DEBUG
echo $KW >> debug.log
echo $DATE >> debug.log
#get data into rrd
rrdtool update enphase.rrd $DATE:$KW
#create daily graph
rrdtool graph /var/www/html/enphase/enphase_day.png -s -1day DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa
#create weekly graph
rrdtool graph /var/www/html/enphase/enphase_week.png -s -1week DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa
#create monthly graph
rrdtool graph /var/www/html/enphase/enphase_month.png -s -1month DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa
#create yearly graph
rrdtool graph /var/www/html/enphase/enphase_year.png -s -1year DEF:enphase=enphase.rrd:temp:AVERAGE LINE1:enphase#00CC00 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa