comparison py/fridge.py @ 177:a0ea542256ba

workaround for invalid wort time
author Matt Johnston <matt@ucc.asn.au>
date Thu, 25 Jul 2013 08:05:40 +0800
parents 78255c49bf9a
children 77c2a9caca3d
comparison
equal deleted inserted replaced
176:ccebadce4619 177:a0ea542256ba
66 wort_min = params.fridge_setpoint 66 wort_min = params.fridge_setpoint
67 wort_max = params.fridge_setpoint + params.fridge_difference 67 wort_max = params.fridge_setpoint + params.fridge_difference
68 68
69 off_time = self.server.now() - self.fridge_off_clock 69 off_time = self.server.now() - self.fridge_off_clock
70 70
71 if wort is not None:
72 self.wort_valid_clock = self.server.now()
73
71 if off_time < config.FRIDGE_DELAY: 74 if off_time < config.FRIDGE_DELAY:
72 L("fridge skipping, too early") 75 L("fridge skipping, too early")
73 return 76 return
74 77
75 if params.disabled: 78 if params.disabled:
77 L("Disabled, turning fridge off") 80 L("Disabled, turning fridge off")
78 self.off() 81 self.off()
79 return 82 return
80 83
81 # handle broken wort sensor 84 # handle broken wort sensor
82 if wort is not None: 85 if wort is None:
83 self.wort_valid_clock = self.server.now() 86 self.wort_valid_clock = self.server.now()
84 else:
85 W("Invalid wort sensor") 87 W("Invalid wort sensor")
86 invalid_time = self.server.now() - self.wort_valid_clock 88 invalid_time = self.server.now() - self.wort_valid_clock
87 if invalid_time < config.FRIDGE_WORT_INVALID_TIME: 89 if invalid_time < config.FRIDGE_WORT_INVALID_TIME:
88 W("Has only been invalid for %d, waiting" % invalid_time) 90 W("Has only been invalid for %d, waiting" % invalid_time)
89 return 91 return
107 and (wort - overshoot) < params.fridge_setpoint: 109 and (wort - overshoot) < params.fridge_setpoint:
108 L("wort has cooled enough, %(wort)f" % locals() ) 110 L("wort has cooled enough, %(wort)f" % locals() )
109 turn_off = True 111 turn_off = True
110 elif fridge is not None and fridge < fridge_min: 112 elif fridge is not None and fridge < fridge_min:
111 W("fridge off fallback, fridge %(fridge)f, min %(fridge_min)f" % locals()) 113 W("fridge off fallback, fridge %(fridge)f, min %(fridge_min)f" % locals())
114 if wort is None:
115 W("wort has been invalid for %d" % (self.server.now() - self.wort_valid_clock))
112 turn_off = True 116 turn_off = True
113 117
114 if turn_off: 118 if turn_off:
115 L("Turning fridge off") 119 L("Turning fridge off")
116 self.off() 120 self.off()