Getting TED and Enphase into MariaDB

I want to get my TED and Envoy data into MariaDB. dont know how or what I am going to use it for yet, but I know I will use it. Just need to learn more.
I used PHPMyAdmin to create a database, I called it House, I then created 2 tables one called TED and one called ENPHASE and gave a new user call house full access to it.
I then created a shell script for TED to get data into it:
#!/bin/bash

#lets get in the right directory

cd /etc/ted/

#remove old csv

rm TED.csv

#Now we get the data we need and get it into a number

RAW=$(lynx -dump http://ted6000/stats.htm | grep '(W)' | sed -r 's/s+//g'| cut -d":" -f2)

#make it kW and put it in a file I can use for other things

/usr/bin/echo "scale=3; $RAW/1000" | bc -l >> TED.csv

#Import data the csv file name has to be the same name and case as the table you are importing to.

mysqlimport --local -u house --password=password House --columns=KW TED.csv

##And the one for the Envoy:
#!/bin/bash

cd /etc/enphase

#remove old stuff

rm ENPHASE.csv
rm kw2.txt
rm kw.txt

#Get the data ready for a csv for MariaDB

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' >> 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 >> ENPHASE.csv

#Import data file name has to be the same name and case as the table you are importing to.

mysqlimport --local -u house --password=password House --columns=KW ENPHASE.csv

I now have my MariaDB populating with date from my TED and Enphase Envoy

TED, Meet Enphase..

Now that we are getting graphs from both TED and Envoy I wanted to combine them to get a graphical representation of production vs. Usage. The heavy lifting is done, just need to stuff it into a graph and cron it:
#!/bin/bash#Create the combined daily graph

rrdtool graph /var/www/html/solar/combine_day.png -s -1day DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#Create the combined weekly graph

rrdtool graph /var/www/html/solar/combine_week.png -s -1week DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#Create the combined monthly graph

rrdtool graph /var/www/html/solar/combine_month.png -s -1month DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

#Create the combined yearly graph

rrdtool graph /var/www/html/solar/combine_year.png -s -1year DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 --color GRID#dddddd --color MGRID#aaaaaa

# All the rrd sctipts we created need to go into roots crontab. I have everything run a 5 minute intervals

*/5 * * * * /usr/local/bin/ted_watts.sh > /dev/null 2>&1
*/5 * * * * /usr/local/bin/enphase.sh > /dev/null 2>&1; /usr/local/bin/combined_solar.sh > /dev/null 2>&1

##Here is the final daily product. TED is Orange, Enphase is Red.

Daily:

Weekly:

Month:

# Here it is with no mark-up
#!/bin/bash#Create the combined daily graph
rrdtool graph /var/www/html/solar/combine_day.png -s -1day DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#Create the combined weekly graph
rrdtool graph /var/www/html/solar/combine_week.png -s -1week DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#Create the combined monthly graph
rrdtool graph /var/www/html/solar/combine_month.png -s -1month DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#Create the combined yearly graph
rrdtool graph /var/www/html/solar/combine_year.png -s -1year DEF:ted_watts=/etc/ted/watts/ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa DEF:enphase=/etc/enphase/enphase.rrd:temp:AVERAGE LINE1:enphase#FF0000 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa