Created
January 27, 2012 09:51
-
-
Save jpmens/1688025 to your computer and use it in GitHub Desktop.
Obtain Celsius temperature reading from Entropy Key and submit to Pachube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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