Re: How to read power usage from TED5000 into Indigo.
I've been messing with the TED5000 data a little based on this thread. I had started another thread trying to publish some TED data with a graph, haven't made it there yet but thought I would update this thread with some stuff I did in case it helps others. I'm not good with scripting but seeing this thread helped got me started in my data collection efforts, so thank you!
This the previous posts were pulling data out of the LiveData.xml page that TED publishes. I was looking to collect historical, hourly data and this data is published as well. The data that is published by the TED API is covered in this document I found online.
What I wanted to do was to collect the previous 24 hours of data that TED stored on an hourly basis (really just trying to get the hourly kWh information into a file). TED keeps the data for 90 days on an hourly basis, but I figured I'd collect it daily. I have a scheduled job running every 24 hours to write the data to a file which includes the current date in the file name for sorting purposes.
I was originally trying to append the data to the same file over and over, but was having troubles getting the append option to work on the curl command, so I decided to just keep a different file for each day for now. If someone knows how I can just dump this data all into one file, it would probably be better.
I'm hoping to be able to take this hourly data and match it up with my hourly outdoor temp info from my weather station for some graphing of power to temperature. I can do this manually now that I'll have all this data in somewhat of the same location. I guess the ultimate goal will be to have all of that data in one file, I think I'll get there...
For now, all I'm doing with this data in Indigo is to file it (its my cron scheduler). I am using the LiveData retrieval to publish my current power usage on my control page along with the current temp from my weather station. THe only thing I've done different with the LiveData publishing is to date stamp when I collect the data which I show on my control page as well.
In any case, here's my sloppy code to pull the hourly data and dump it into a file:
- Code: Select all
set TheDate to (current date) as string
set ShortMonth to get the (month of (current date)) as string
set ShortDay to get the (day of (current date)) as string
set ShortYear to get the (year of (current date)) as string
set DateCalc to the current date
copy DateCalc to b
set the month of b to January
set monthNum to (1 + (DateCalc - b + 1314864) div 2629728) as string
-- add a leading zero to monthNum
set monthlength to (length of monthNum)
if monthlength < 2 then
set monthNum to "0" & monthNum
-- end leading zero routine
set IntDate to monthNum & ShortDay & ShortYear
set tedURL to "'http://188.8.131.52/history/hourlyhistory.xml?MTU=0&COUNT=24&INDEX=1'"
tell application "IndigoServer"
set value of variable "IntDate" to (IntDate) as string
set value of variable "TheDate" to (current date) as string
do shell script "curl " & tedURL & " -o ~/Desktop/TED-Data/" & (IntDate) & "-HourlyData.xml"