Skip to content

Instantly share code, notes, and snippets.

@jpmens
Created January 27, 2012 09:51
Show Gist options
  • Save jpmens/1688025 to your computer and use it in GitHub Desktop.
Save jpmens/1688025 to your computer and use it in GitHub Desktop.
Obtain Celsius temperature reading from Entropy Key and submit to Pachube
#!/usr/bin/env python
#(@)etemp.py by Jan-Piet Mens (C)2012
# Obtain Celsius temperature reading from Entropy Key and submit to Pachube
import eeml # git://github.com/petervizi/python-eeml.git
import subprocess
keyslot = "1"
API_KEY = 'TXHh........QXQ0AfEnZp'
API_URL = '/v2/feeds/45891.xml'
temp = ''
proc = subprocess.Popen(['ekeydctl', 'stats', keyslot], stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
if line != '':
[key, val] = line.rstrip().split('=')
if key == 'KeyTemperatureC':
temp = val
break
else:
break
if not temp is "":
print "Submit to Pachube with temp == %s" % (temp)
pac = eeml.Pachube(API_URL, API_KEY)
pac.update([eeml.Data(0, temp)])
pac.put()
else:
print "No temp available"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment