]> mj.ucw.cz Git - home-hw.git/commitdiff
Auto: Rewritte loft fan logic
authorMartin Mares <mj@ucw.cz>
Wed, 13 Jul 2022 15:42:11 +0000 (17:42 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 13 Jul 2022 15:42:11 +0000 (17:42 +0200)
auto/burrow-auto

index ce81f4a8c88262ac48657b1c37787332ec8d9fc2..d4ac3811829e0748adfbd6cd008cba8e096bf29c 100755 (executable)
@@ -132,26 +132,25 @@ st = State()
 
 def auto_loft_fan():
     global st
-    lt = st.get_sensor("temp/loft")
-    lt_high = st.hysteresis('lt_high', lt, 29, 30)
-    lt_mid = st.hysteresis('lt_mid', lt, 24, 25)
-    if lt_high > 0:
-        fs = 3
-    elif lt_mid > 0:
-        if st.hour in range(10, 20):
-            fs = 3
-        else:
-            fs = 1
-    else:
-        if st.hour in range(8, 22):
-            if st.min % 30 in range(0, 5):
-                fs = 3
-            else:
-                fs = 0
+    lt = st.get_sensor_avg("temp/loft")
+    out = st.get_sensor_avg('air/inside-intake')
+
+    if lt is None or out is None:
+        fs = 0
+    elif st.hysteresis('lf_out_cold', out, 5, 6) < 0:
+        fs = 0
+    elif st.hysteresis('lf_out_cool', out, 6, 15) < 0:
+        if st.min in range(10, 15):
+            fs = 2
         else:
             fs = 0
-    # FIXME: Disabled for now
-    fs = 0
+    elif ac_is_on() > 0:
+        fs = 3
+    elif st.hysteresis('lf_loft_hot', lt, out - 1, out + 1) > 0:
+        fs = 3
+    else:
+        fs = 0
+
     st.set("loft/fan", fs)
 
 
@@ -230,9 +229,10 @@ def auto_aircon():
 
     if not hasattr(st, 'last_ac_change'):
         st.last_ac_change = st.now
+    need_wait = st.last_ac_change + 300 - st.now    # FIXME: Increase
 
-    if st.last_ac_change >= st.now - 300:       # FIXME: Increase
-        action = f"wait({st.now - st.last_ac_change})"
+    if need_wait > 0:
+        action = f"wait({need_wait:.0f})"
     elif ac_on == 0:
         action = "need-data"
     elif ac_on != want_ac: