# HG changeset patch # User Matt Johnston # Date 1356013492 -28800 # Node ID c81d99739d9f9920dbe0224f4ad3f8c8f33fc5d1 # Parent e99559bf188f2764986f87555b180774680771eb# Parent cea8ec101c6bf98a58ae9de0626c91b574c2dbf4 merge diff -r cea8ec101c6b -r c81d99739d9f py/config.py --- 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' diff -r cea8ec101c6b -r c81d99739d9f py/sensor_ds18b20.py --- 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 """