The most interesting app on my phone at the moment is called PowerNow. Here’s the display:
1090
Thursday April 14 12:14
At 12:14AM today, when I took this snapshot, my house was using 1090 watts. The data comes from the TED5000 smartmeter I recently installed. It reports all kinds of data but that single number matters most. When you can monitor your power use in realtime, you can regulate it far more intelligently than you can if your only instrument is a monthly bill.
The other day, for example, I finally got around to swapping out a bunch of incandescent bulbs for compact fluorescents. I took a baseline measurement with PowerNow, and then swapped out a total of 17 bulbs in six batches. After each batch I took another measurement. You can see all the data here. Step by step the wattage drops, by a total of 900. And step by step the hourly cost drops, by a total of $0.15/hr. Of course I won’t really save $0.15/hr because I took the baseline with everything turned on, which isn’t normally the case. But it’s wonderfully motivating to be able to measure the effect directly.
The TED5000 comes with a wireless display that I could have used to take those snapshots, but its ZigBee controller isn’t working well and I’m awaiting a replacement. So I turned to Google PowerMeter, which can receive data posted from the TED. But PowerMeter only reports cumulative use, not realtime use. When I put up my own experimental service to receive TED data, I found out why: cumulative data is all that the TED sends.
There are actually two TED APIs, though. The one used by PowerMeter, and by other services like the one I wrote, requires an activation protocol and then accepts data packets sent from the TED gateway. In other words: TED pushes to the service.
There’s also another API that enables a service to pull data from TED. It’s just this:
http://ted5000/api/LiveData.xml
This URL refers to a TED gateway that’s hooked into a home network which resolves the name ted5000 to some private address like 192.168.2.100. There are variant URLS for fetching historical data but this URL just brings back the realtime data which is all I want for now.
One way to view that data from anywhere would be to open up an inbound port on the router. But I’d rather not, so instead I’m running a scheduled process on one of my networked PCs. It polls the TED, extracts the one number I want, and posts it to a web page along with the date and time.
If I were in marketing, here’s how I’d describe this “cool app”:
Monitors realtime power use in your home!
Works anywhere, anytime!
Compatible with all smartphones, including iPhone, Android, BlackBerry, and Windows Phone!
And that’s all true. But of course it isn’t really an app, it’s just a web page backed by a suite of cooperating services: the TED’s software, my data extractor, and the website that hosts the page.
Or is it, in fact, an app? For me the word connotes not just software that runs on your phone, but rather software that runs in various places including your phone, and ties together various services.
Apps defined that way can be ridiculously easy to write. I tweeted that PowerNow is just 6 lines of Python. I went back and checked and, well, it’s a bit more, but not much more:
import urllib2, re, ftplib, datetime from ftplib import FTP from datetime import datetime url = 'http://ted5000/api/LiveData.xml' s = urllib2.urlopen(url).read() power = re.findall('<PowerNow>(\d+)</PowerNow>', s)[0] html = """<html> <head><title>PowerNow</title></head> <body> <p style="font-size:x-large;text-align:center">%s</p> <p style="text-align:center">%s</p> </body> </html>""" % (power, datetime.now().strftime('%A %B %d %H:%M')) fname = '/users/jon/dev/PowerNow.html' f = open(fname, 'w') f.write(html) f.close() ftp = FTP('_______.net') ftp.login('_______','________') f = open(fname) ftp.storbinary('STOR PowerNow.html', f) f.close() ftp.quit()
That’s the script that polls the TED, extracts the current power use in watts, packages it in HTML, and posts it to a webserver. To run it, I scheduled a once-per-minute process using the Windows 7 Task Scheduler. I hadn’t used Task Scheduler in a while, and I noticed something non-obvious about it. When you specify repetition, it looks like you only have these choices:
What’s non-obvious is that you can edit the values in the list, like so:
I also chose the One time setting:
That’s how you set up a task to repeat with arbitrary frequency. Then you tell it what to do. In my case:
I avoid home automation projects that require soldering, it just isn’t my thing. But stitching web componentry together? I can do that in my sleep. I’m really looking forward to the coming wave of appliances that will enable me to do that.
You are making it very difficult for me to avoid buying one of these TED devices, Jon. It tickles all my brain’s nerd pleasure centers.
You should get one then. Although, fair warning, it will be a love/hate relationship. I have just found that once-per-minute polling is beyond the capability of the gateway’s embedded server. I’ve backed off to once-every-three minutes, we’ll see if it can deal with that.
This is a product that raises your expectations very high, fails to live up to a lot of them, but still manages to deliver a profound benefit.
Jon,
Would love to reprint some of your articles in “The e-Buffet”
Pat McCormick
thank you for the python and other instructions.. this has been on my to-do list since moving into a new house that I think is an electricity hog (same appliances as in the old smaller house). However now I actually look at the handy DOE data,
http://www.eia.doe.gov/cneaf/electricity/esr/table5_a.xls
I see its consumption is not out of line with the CO average. That spreadsheet is interesting reading, for statistician/geek values of ‘interesting’. At first glance there appears to be a strong price/usage correlation as well as climate/usage, which price sensitivity I didn’t expect.