The Energy Detective (TED) Data Gathering

Now that I am getting data and graphing it from the Enphase Envoy, I want to get data from my The Energy Detective (TED). I can then graphically view usage and compare it to my solar generation. Here 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. It is the same VM I used for the Enphase.

 

ted6000 is the name of my TED. You will see it a couple times in the script. Replace it with your URL

 

# If needed Install rrdtool and lynx (you will need the EPEL repos)

 

sudo yum install rrdtool lynx

 

# Then we create the database. I called mine ted.rrd, you can name your what you want. You will just need to note the name in the script below.

 

sudo rrdtool create ted.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/ted/

 

#I created the below script in /usr/local/bin/ and made it executable.

 

#!/bin/bash

# get the EPOCH date

 

DATE=$(/bin/date +%s)

#lets get in the right directory

 

cd /etc/ted/watts

#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 a variable

 

KW=$(/usr/bin/echo "scale=3; $RAW/1000" | bc -l)

#get data into rrd

 

rrdtool update ted_watts.rrd $DATE:$KW

#create daily graph

 

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

#create weekly graph

 

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

#create monthly graph

 

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

#create yearly graph

 

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

 

 

##Here is the final Product:

 

Daily

 

ted watts day

 

Weekly:

 

ted watts week

 

Month:

 

ted watts month

##Here it the no mark-up version:

 

#!/bin/bash

# get the EPOCH date
DATE=$(/bin/date +%s)

#lets get in the right directory
cd /etc/ted/watts

#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 |sed ‘s/^/, /’ | sed -e “s/^/$(date) /” >> TED_DATA.csv

#make it a variable
KW=$(/usr/bin/echo “scale=3; $RAW/1000” | bc -l)

#get data into rrd
rrdtool update ted_watts.rrd $DATE:$KW

#create daily graph
rrdtool graph /var/www/html/ted/ted_watts_day.png -s -1day DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create weekly graph
rrdtool graph /var/www/html/ted/ted_watts_week.png -s -1week DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create monthly graph
rrdtool graph /var/www/html/ted/ted_watts_month.png -s -1month DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

#create yearly graph
rrdtool graph /var/www/html/ted/ted_watts_year.png -s -1year DEF:ted_watts=ted_watts.rrd:temp:AVERAGE LINE1:ted_watts#FF9900 -h 400 -w 600 -y1:2 –color GRID#dddddd –color MGRID#aaaaaa

Facebooktwittergoogle_plusredditpinterestlinkedinmailby feather