changeset 266:20c89630be6c

emergency change sensor config add --nowait. make only look for 28- devices (ds18b20)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 05 Jul 2015 00:44:05 +0800
parents 78c542f03030
children 08c3cf3d0ded
files py/config.py py/fridge.py py/sensor_ds18b20.py py/tempserver.py
diffstat 4 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/py/config.py	Sat Jun 13 22:49:14 2015 +0800
+++ b/py/config.py	Sun Jul 05 00:44:05 2015 +0800
@@ -14,9 +14,12 @@
 
 SENSOR_BASE_DIR = '/sys/devices/w1_bus_master1'
 FRIDGE_GPIO_PIN = 17
-WORT_NAME = '28-0000042cf4dd'
-FRIDGE_NAME = '28-0000042cccc4'
-AMBIENT_NAME = '28-0000042c6dbb'
+#WORT_NAME = '28-0000042cf4dd'
+#FRIDGE_NAME = '28-0000042cccc4'
+#AMBIENT_NAME = '28-0000042c6dbb'
+AMBIENT_NAME = 'missingambient'
+FRIDGE_NAME = 'missingfridge'
+WORT_NAME = '28-0000042cccc4' # was fridge
 INTERNAL_TEMPERATURE = '/sys/class/thermal/thermal_zone0/temp'
 
 HMAC_KEY = "a key"
--- a/py/fridge.py	Sat Jun 13 22:49:14 2015 +0800
+++ b/py/fridge.py	Sun Jul 05 00:44:05 2015 +0800
@@ -10,12 +10,14 @@
 
     OVERSHOOT_MAX_DIV = 1800.0 # 30 mins
 
-    def __init__(self, server):
+    def __init__(self, server, nowait = False):
         self.server = server
         self.gpio = gpio.Gpio(config.FRIDGE_GPIO_PIN, "fridge")
         self.wort_valid_clock = 0
         self.fridge_on_clock = 0
         self.off()
+        if nowait:
+            self.fridge_off_clock = 0
 
     def turn(self, value):
         self.gpio.turn(value)
--- a/py/sensor_ds18b20.py	Sat Jun 13 22:49:14 2015 +0800
+++ b/py/sensor_ds18b20.py	Sun Jul 05 00:44:05 2015 +0800
@@ -88,6 +88,8 @@
             E("No W1 sensors found")
             return []
         names = contents.split()
+        # only ds18b20
+        names = [n for n in names if n.startswith('28-')]
         return names
 
     def wort_name(self):
--- a/py/tempserver.py	Sat Jun 13 22:49:14 2015 +0800
+++ b/py/tempserver.py	Sun Jul 05 00:44:05 2015 +0800
@@ -22,16 +22,17 @@
 
 
 class Tempserver(object):
-    def __init__(self, test_mode):
+    def __init__(self, test_mode, nowait):
         self.readings = []
         self.current = (None, None)
         self.fridge = None
         self._wakeup = asyncio.Event()
         self._test_mode = test_mode
+        self._nowait = nowait
 
     def __enter__(self):
         self.params = params.Params()
-        self.fridge = fridge.Fridge(self)
+        self.fridge = fridge.Fridge(self, self._nowait)
         self.uploader = uploader.Uploader(self)
         self.configwaiter = configwaiter.ConfigWaiter(self)
         self.params.load()
@@ -134,8 +135,8 @@
             level=level)
     #logging.getLogger("asyncio").setLevel(logging.DEBUG)
 
-def start(test_mode):
-    with Tempserver(test_mode) as server:
+def start(test_mode, nowait):
+    with Tempserver(test_mode, nowait) as server:
         server.run()
 
 def main():
@@ -145,6 +146,7 @@
     parser.add_argument('-D', '--daemon', action='store_true')
     parser.add_argument('-d', '--debug', action='store_true')
     parser.add_argument('-t', '--test', action='store_true')
+    parser.add_argument('--nowait', action='store_true')
     args = parser.parse_args()
 
     setup_logging(args.debug)
@@ -205,10 +207,10 @@
         logpath = os.path.join(os.path.dirname(__file__), 'tempserver.log')
         logf = open(logpath, 'a+')
         with daemon.DaemonContext(pidfile=pidf, stdout=logf, stderr = logf):
-            start(args.test)
+            start(args.test, args.nowait)
     else:
         with pidf:
-            start(args.test)
+            start(args.test, args.nowait)
 
 if __name__ == '__main__':
     main()