diff py/fridge.py @ 476:06de0f2ffa26

workaround for invalid wort time
author Matt Johnston <matt@ucc.asn.au>
date Thu, 25 Jul 2013 08:05:40 +0800
parents de4abcbe8f46
children 77c2a9caca3d
line wrap: on
line diff
--- a/py/fridge.py	Thu Jul 25 08:03:55 2013 +0800
+++ b/py/fridge.py	Thu Jul 25 08:05:40 2013 +0800
@@ -68,6 +68,9 @@
 
         off_time = self.server.now() - self.fridge_off_clock
 
+        if wort is not None:
+            self.wort_valid_clock = self.server.now()
+
         if off_time < config.FRIDGE_DELAY:
             L("fridge skipping, too early")
             return
@@ -79,9 +82,8 @@
             return
 
         # handle broken wort sensor
-        if wort is not None:
+        if wort is None:
             self.wort_valid_clock = self.server.now()
-        else:
             W("Invalid wort sensor")
             invalid_time = self.server.now() - self.wort_valid_clock
             if invalid_time < config.FRIDGE_WORT_INVALID_TIME:
@@ -109,6 +111,8 @@
                     turn_off = True
             elif fridge is not None and fridge < fridge_min:
                     W("fridge off fallback, fridge %(fridge)f, min %(fridge_min)f" % locals())
+                    if wort is None:
+                        W("wort has been invalid for %d" % (self.server.now() - self.wort_valid_clock))
                     turn_off = True
 
             if turn_off: