Mercurial > templog
diff py/fridge.py @ 305:6087c692d381
turn the fridge off if both sensors are broken
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 24 Jul 2019 23:24:51 +0800 |
parents | 6848907f85be |
children |
line wrap: on
line diff
--- a/py/fridge.py Wed Jul 24 23:21:33 2019 +0800 +++ b/py/fridge.py Wed Jul 24 23:24:51 2019 +0800 @@ -16,6 +16,7 @@ self.gpio = gpio.Gpio(config.FRIDGE_GPIO_PIN, "fridge") self.integrator = utils.StepIntegrator(self.server.now, self.server.params.overshoot_delay) self.wort_valid_clock = 0 + self.fridge_valid_clock = 0 self.fridge_on_clock = 0 self.off() if nowait: @@ -63,6 +64,9 @@ if wort is not None: self.wort_valid_clock = self.server.now() + if fridge is not None: + self.fridge_valid_clock = self.server.now() + self.integrator.set_limit(params.overshoot_delay) # Safety to avoid bad things happening to the fridge motor (?) @@ -110,6 +114,13 @@ W("wort has been invalid for %d" % (self.server.now() - self.wort_valid_clock)) turn_off = True + if wort is None and fridge is None: + invalid_time = self.server.now() - max(self.wort_valid_clock, self.fridge_valid_clock) + D("both sensors broken, invalid_time %(invalid_time)f" % locals()) + if invalid_time > config.ALL_INVALID_TIME: + L("Both sensors broken for %(invalid_time)f seconds" % locals()) + turn_off = True + if turn_off: L("Turning fridge off") self.off()