Compare commits
No commits in common. "b4003246a8521085b9eb4a8e25b274e378961f9e" and "f69ae9eed263c0542aafc693263a4e74392e0871" have entirely different histories.
b4003246a8
...
f69ae9eed2
|
@ -18,7 +18,6 @@ try:
|
|||
except KeyError:
|
||||
is_mock = False
|
||||
|
||||
print("controller start")
|
||||
process = None
|
||||
def start_process():
|
||||
global process
|
||||
|
@ -137,11 +136,10 @@ 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, toggle_cmd=b"i"):
|
||||
def __init__(self):
|
||||
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)
|
||||
|
@ -181,7 +179,7 @@ class HumidifierV2:
|
|||
|
||||
def toggle(self, s):
|
||||
if time.time() > self.switch_timeout:
|
||||
s.write(self.toggle_command)
|
||||
s.write(b"i")
|
||||
s.flush()
|
||||
self.switch_timeout = time.time() + self.toggle_cooldown
|
||||
|
||||
|
@ -191,7 +189,6 @@ class Controller:
|
|||
self.target_lower = 85
|
||||
self.target_upper = 90
|
||||
self.feedforward_coeff = 50
|
||||
self.last_toggle = 0
|
||||
|
||||
self._manual_mode = False
|
||||
self.manual_on = False
|
||||
|
@ -210,11 +207,6 @@ class Controller:
|
|||
self._manual_mode = on
|
||||
send_update({"status": {"manual_mode": on}})
|
||||
|
||||
def toggle_checked(self, humidifier, s):
|
||||
if time.time() - self.last_toggle > 0.8:
|
||||
humidifier.toggle(s)
|
||||
self.last_toggle = time.time()
|
||||
|
||||
def update(self, humidifier, humidifier2, humidity):
|
||||
if self.first_sample:
|
||||
self.humidifier_history[:] = humidity
|
||||
|
@ -231,29 +223,24 @@ 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:
|
||||
self.toggle_checked(humidifier, s)
|
||||
humidifier.toggle(s)
|
||||
elif humidifier.on and not self.manual_on:
|
||||
self.toggle_checked(humidifier, s)
|
||||
if humidifier2.off and self.manual_on:
|
||||
self.toggle_checked(humidifier2, s)
|
||||
elif humidifier2.on and not self.manual_on:
|
||||
self.toggle_checked(humidifier2, s)
|
||||
humidifier.toggle(s)
|
||||
else:
|
||||
if comp_humidity < self.target_lower:
|
||||
if humidifier.off:
|
||||
self.toggle_checked(humidifier, s)
|
||||
humidifier.toggle(s)
|
||||
if humidifier2.off:
|
||||
self.toggle_checked(humidifier2, s)
|
||||
humidifier2.toggle(s)
|
||||
elif comp_humidity > self.target_upper:
|
||||
if humidifier.on:
|
||||
self.toggle_checked(humidifier, s)
|
||||
humidifier.toggle(s)
|
||||
if humidifier2.on:
|
||||
self.toggle_checked(humidifier2, s)
|
||||
humidifier2.toggle(s)
|
||||
|
||||
humidifier = HumidifierV2(b"n")
|
||||
humidifier = Humidifier()
|
||||
humidifier2 = HumidifierV2()
|
||||
controller = Controller()
|
||||
|
||||
|
|
Loading…
Reference in New Issue