diff --git a/shroom_controller.py b/shroom_controller.py index b661aef..441188b 100644 --- a/shroom_controller.py +++ b/shroom_controller.py @@ -136,10 +136,11 @@ class Humidifier: # the wiring's a little different so the thresholds for detecting on/off are inverted but hopefully a lot more reliable than the original class HumidifierV2: - def __init__(self): + def __init__(self, toggle_cmd=b"i"): self.on_threshold = 1.5 self.off_threshold = 2.5 self.toggle_cooldown = 7 + self.toggle_command = toggle_cmd self._on = False self.history = np.zeros(10) @@ -179,7 +180,7 @@ class HumidifierV2: def toggle(self, s): if time.time() > self.switch_timeout: - s.write(b"i") + s.write(self.toggle_command) s.flush() self.switch_timeout = time.time() + self.toggle_cooldown @@ -223,6 +224,7 @@ class Controller: if self.manual_mode and time.time() > self.manual_timeout: self.manual_mode = False + # TODO add in support for manual control of second humidifier if self.manual_mode: if humidifier.off and self.manual_on: humidifier.toggle(s) @@ -240,7 +242,7 @@ class Controller: if humidifier2.on: humidifier2.toggle(s) -humidifier = Humidifier() +humidifier = HumidifierV2(b"n") humidifier2 = HumidifierV2() controller = Controller()