changeset 152:102e6602bb2d

merge
author Matt Johnston <matt@ucc.asn.au>
date Thu, 20 Dec 2012 22:24:52 +0800
parents e114b38c8a55 (diff) 171cdf716473 (current diff)
children 0529f3527626
files
diffstat 2 files changed, 21 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/py/config.py	Tue Dec 18 22:20:47 2012 +0800
+++ b/py/config.py	Thu Dec 20 22:24:52 2012 +0800
@@ -12,3 +12,4 @@
 FRIDGE_GPIO = '/sys/devices/virtual/gpio/gpio17'
 WORT_NAME = '28-0000031abc49'
 FRIDGE_NAME = 'bb'
+INTERNAL_TEMPERATURE = '/sys/class/thermal/thermal_zone0/temp'
--- a/py/sensor_ds18b20.py	Tue Dec 18 22:20:47 2012 +0800
+++ b/py/sensor_ds18b20.py	Thu Dec 20 22:24:52 2012 +0800
@@ -19,6 +19,19 @@
         self.readthread = gevent.threadpool.ThreadPool(1)
         self.master_dir = config.SENSOR_BASE_DIR
 
+    def do(self):
+        vals = {}
+        for n in self.sensor_names():
+                value = self.do_sensor(n)
+                if value is not None:
+                    vals[n] = value
+
+        itemp = self.do_internal()
+        if itemp:
+            vals['internal'] = itemp
+
+        self.server.add_reading(vals)
+
     def _run(self):
         while True:
             self.do()
@@ -52,14 +65,13 @@
             EX("Problem reading sensor '%s': %s" % (s, str(e)))
             return None
 
-    def do(self):
-        vals = {}
-        for n in self.sensor_names():
-                value = self.do_sensor(n)
-                if value is not None:
-                    vals[n] = value
-
-        self.server.add_reading(vals)
+    def do_internal(self):
+        try:
+            return int(open(config.INTERNAL_TEMPERATURE, 'r').read()) / 1000.0
+        except Exception, e:
+            EX("Problem reading internal sensor: %s" % str(e))
+            return None
+        
 
     def sensor_names(self):
         """ Returns a sequence of sensorname """