Google PowerMeter API

GooglePowerMeterExample

A simple Pythonic introduction to the Google PowerMeter API...

... with thanks to 2cheap2meter.blogspot.com for his posts ...

For your (possibly hypothetical) device, decide on values for the variables {MANUFACTURER, MODEL, ID}.

Now point your browser to this webpage: https://www.google.com/powermeter/device/activate?mfg=MANUFACTURER&model=MODEL&did=ID&dvars=1 replacing my dummy variables with your chosen values.

Add your geographic data when prompted, and the click 'Activate This Device'. Keep this authentication page up, we'll refer back to it right at the end. In the meantime, find your 'authInfo' on this page. It should look something like this:

hash=8e8abf8262aeb7bab4e24afc7beeb18c701c04ba,
6c258c9f62fa8a137eba7fa35b5f58802fca2e56,d48ef4db13304c49d36fb81b20cabbe147f8ce34&
token=CNrKqNTIDhCg8O7NBRi8q-C2BA&
path=/user/04640655547383522225/04640655547383522225/variable/MANUFACTURER.MODEL.ID

Notice the PATH and TOKEN variables. Use these to define an XML feed of your data, which should look something like this:


<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:meter="http://schemas.google.com/meter/2008"
      xmlns:batch="http://schemas.google.com/gdata/batch">

  <entry xmlns="http://www.w3.org/2005/Atom"
      xmlns:meter="http://schemas.google.com/meter/2008">
    <category scheme="http://schemas.google.com/g/2005#kind"
        term="http://schemas.google.com/meter/2008#durMeasurement"/>
    <meter:subject>https://www.google.com/powermeter/feeds/<b>PATH</b>.d1</meter:subject>
    <batch:id>B.1</batch:id>
    <meter:startTime meter:uncertainty="1.0">2010-05-05T09:00:00.000Z</meter:starttime>
    <meter:endTime meter:uncertainty="1.0">2010-05-05T09:05:00.000</meter:endtime>
    <meter:quantity meter:uncertainty="0.001" meter:unit="kW h">0.172</meter:quantity>
  </category></entry>
</feed>

Replace the dummy variable PATH with the value given in your 'authInfo' above, append '.d1' to define the actual entity you are updating. The file should obviously begin with < not '& l t ;' (grrrr Drupal....).

Download the Python client library from here: http://code.google.com/p/google-powermeter-api-client/downloads/list and, finally, run:

python post_gdata_batch.py TOKEN FEED_FILENAME.XML --verbose
.

If you're lucky, when prompted, your authentication page should acknowledge that data has been uploaded and your PowerMeter gadget should have a single peak on 2010-05-05. More probably, you'll get some error code. Here's the full list: how many can you collect?

Bon courage....

See also...

Some analytical methods you can run on your home-energy data.