]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Turn pump on in the morning when roof temp above 20°C
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 13 May 2024 09:28:07 +0000 (10:28 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 13 May 2024 09:28:07 +0000 (10:28 +0100)
Instead of coming on at 7am and using the pool water to warm the
roof. Turn on at 10am at the latest, anyway.

pool.yaml

index 8ed70be757b49a856fb00d2424dfec8e1246020c..8a4f8c2c36753c7a36b754000ea0ce6f94f41142 100644 (file)
--- a/pool.yaml
+++ b/pool.yaml
@@ -114,12 +114,21 @@ script:
 
         if (cur_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) + 600) {
-                    auto t = id(sntp_time).now();
-                    if (t.is_valid() && t.hour >= 17) {
-                            ESP_LOGD("control_value", "Cold for ten minutes. Turning pump off for the night");
-                            id(pool_pump).turn_off();
-                    }
+            auto t = id(sntp_time).now();
+            if (!t.is_valid())
+                    return;
+
+            // Turn pump off if we no longer need heat (for 10 mins) after 5pm.
+            if (t.hour >= 17 && !want_state && id(pool_pump).state &&
+                now > id(control_valve_last_change) + 600) {
+                    ESP_LOGD("control_value", "Cold for ten minutes. Turning pump off for the night");
+                    id(pool_pump).turn_off();
+            }
+
+            // Turn pump off if it's warm enough, between 7am and 10am (when it comes on anyway).
+            if (t.hour > 7 && t.hour < 10 && outtemp >= 20.0 && !id(pool_pump).state) {
+                    ESP_LOGD("control_value", "Roof temperature over 20°C. Turning pump on.");
+                    id(pool_pump).turn_on();
             }
             return;
         }
@@ -146,7 +155,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 >= 10 && t.hour < 17)
                 id(pool_pump).turn_on();
               else
                 id(pool_pump).turn_off();
@@ -239,7 +248,7 @@ time:
         # Turn pool pump on at 7am and off at 7pm
       - seconds: 0
         minutes: 0
-        hours: 7,19
+        hours: 10,19
         then:
           script.execute:
             id: pump_default