I got it working with rrdtool. Here is what I did. First, installed rrdtool from macports ("port install rrtool"), then created the database:
- Code: Select all
rrdtool create /usr/local/share/logtemp.rrd --step 900 DS:Upstairs:GAUGE:2000:32:120 DS:Downstairs:GAUGE:2000:32:120 RRA:AVERAGE:0.5:1:350400 RRA:AVERAGE:0.5:96:3650 RRA:MIN:0.5:96:3650 RRA:MAX:0.5:96:3650
Created this AppleScript in a text file and saved as /usr/local/share/logtemp.scpt
- Code: Select all
tell application "IndigoServer"
set upstairs to temperatures of device "Upstairs Thermostat"
set downstairs to temperatures of device "Downstairs Thermostat"
return (upstairs as string) & ":" & (downstairs as string)
end tell
Created this shell script as /usr/local/bin/logtemp, which grabs the current temps, stores them in the database, then regenerates a graph png image.
- Code: Select all
#!/bin/csh -f
set temps = `/usr/bin/osascript /usr/local/share/logtemp.scpt`
/opt/local/bin/rrdtool update /usr/local/share/logtemp.rrd "N:$temps"
/opt/local/bin/rrdtool graph \
"/Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/images/controls/static/logtemp.png" \
-a PNG --start "-2days" --width=600 \
--title="Temperature History Over Last 48 Hours" \
--vertical-label="Degrees F" \
'DEF:Upstairs=/usr/local/share/logtemp.rrd:Upstairs:AVERAGE' \
'DEF:Downstairs=/usr/local/share/logtemp.rrd:Downstairs:AVERAGE' \
'LINE1:Upstairs#ff0000:Upstairs' \
'LINE1:Downstairs#0000ff:Downstairs'
exit 0
Added this line to the crontab, to run the script every 15 minutes:
- Code: Select all
*/15 * * * * /usr/local/bin/logtemp >/dev/null 2>&1
And added the png graph as a static image on my thermostat control page in Indigo.
When all is done, my thermostat control page looks like this now:
I'm also storing daily averages and min and max in the database, in case I want to create other graphs. I'm storing 10 years worth of 15 minute data, and 10 years of daily average/max/min, just in case I want it later.
-Mike