]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Turn pump off when it gets cold after 5pm
authorDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 9 May 2024 09:27:09 +0000 (10:27 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 9 May 2024 09:27:09 +0000 (10:27 +0100)
There's still some water flow through the roof even when the bypass valve
is open. So stop pumping completely if it stays cold for more than half
an hour. But *only* after 5pm, because the pump *does* need to run for
enough hours each day to actually clean the water, and because this way
I don't need to bother with a trigger for actually turning it back on
again — if it's already cold after 5pm, it's unlikely to warm up again.

Bump the timed switch off to 8pm, because this should now be the primary
way the pump is turned off.

pool.yaml

index 64807eaa60366f502b09b65371eb9698e4a46a27..865658ece7af4a39e311f4330dc0328c83d83490 100644 (file)
--- a/pool.yaml
+++ b/pool.yaml
@@ -100,14 +100,21 @@ script:
         if (outtemp == intemp)
           return;
 
+        time_t now = ::time(NULL);
         boolean want_state = outtemp > intemp;
+
         if (id(valve_output).state == want_state) {
             ESP_LOGD("control_valve", "Leaving valve %s", want_state ? "ON" : "OFF");
+            if (!want_state && id(pool_pump).state && now > id(control_valve_last_change) + 1800) {
+                    auto t = id(sntp_time).now();
+                    if (t.is_valid() && t.hour >= 17) {
+                            ESP_LOGD("control_value", "Cold for half an hour. Turning pump off for the night");
+                            id(pool_pump).turn_off();
+                    }
+            }
             return;
         }
 
-        time_t now = ::time(NULL);
-
         if (now < id(control_valve_last_change) + 300) {
             ESP_LOGD("control_valve", "Too soon to turn %s (%d seconds)", want_state ? "ON" : "OFF",
                      now - id(control_valve_last_change));
@@ -129,7 +136,7 @@ script:
            auto t = id(sntp_time).now();
            if (t.is_valid()) {
               ESP_LOGD("pump_default", "Setting pump switch at %dh", t.hour);
-              if (t.hour >= 7 && t.hour < 19)
+              if (t.hour >= 7 && t.hour < 20)
                 id(pool_pump).turn_on();
               else
                 id(pool_pump).turn_off();