From: David Woodhouse Date: Mon, 13 May 2024 09:28:07 +0000 (+0100) Subject: Turn pump on in the morning when roof temp above 20°C X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ce40db5d4c9f5eb1c8a246386b6dd30d2bbf0972;p=users%2Fdwmw2%2Fesp32-pool.git Turn pump on in the morning when roof temp above 20°C Instead of coming on at 7am and using the pool water to warm the roof. Turn on at 10am at the latest, anyway. --- diff --git a/pool.yaml b/pool.yaml index 8ed70be..8a4f8c2 100644 --- 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