The new Energy Detective makes it really easy to get power usage data into Indigo. The Gateway periodically stores its data in an XML file which can be downloaded and parsed via AppleScript. Here is a quick and dirty example of how to track KWh usage in an Indigo variable.
To grab the data from the gateway;
- Code: Select all
set gatewayAddress to "http://192.168.7.100"
set thePort to "8172"
set output_path to "~/Desktop/LiveData.xml"
set fileURL to gatewayAddress & ":" & thePort & "/api/LiveData.xml"
do shell script "curl " & fileURL & " -o " & output_path
obviously you'll want to change gatewayAddress, thePort, and output_path as appropriate for your setup.
Now to parse the data, you can do something like this;
- Code: Select all
set XMLfile to "~/Desktop/LiveData.xml"
tell application "System Events"
set xml_data to contents of XML file XMLfile
tell xml_data to set live_data to XML element "LiveData"
tell xml_data to set power to XML element "Power" of live_data
tell xml_data to set total to XML element "Total" of power
tell xml_data to set power_now to XML element "PowerNow" of total
set power to value of power_now
tell application "IndigoServer"
set value of variable "current_power" to power as integer
end tell
end tell
add additional variables as desired. As you examine the downloaded xml file, you'll be able to determine which data is important to you.
I wrap the whole thing in a 1 minute timer and can then set triggers on the variables, as desired. Next, I think I'll set up a control page so I can view Power usage on the iPhone. I'd be interested in hearing of other ideas as to how this data can be used.
Regards
Bob E.