Saturday 25 February 2012

apcupsd via Python to Pachube

In python, the 'default' URL accessing toolkit (urllib2) doesn't support PUT, however I've discovered requests which a) does and b) is in Fedora. So one apt-get install python-requests.noarch and you're off.

So - one trivial script (reusing much of the code for my MQTT variant) you get https://gist.github.com/1903259. The only minor niggle was working out how to prepend the minimum extra json content (version and datastreams) as I'd not used the json libs before. (Hmm yet another github toy - embeddable gists with syntax highlighting. Nice) Update now I have 24h worth of data - plot attached

1 comment:

radez said...

You could also use httplib2. We do Puts in the audrey agent (github.com/aeolusproject/audrey/). It uses the oauth library which uses httplib2 as the underlying http lib.

Feeling Pumped!

Having just had a day without power, and then going round the site to check everything came back online correctly (including services such a...