From ce40db5d4c9f5eb1c8a246386b6dd30d2bbf0972 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 13 May 2024 10:28:07 +0100 Subject: [PATCH] =?utf8?q?Turn=20pump=20on=20in=20the=20morning=20when=20r?= =?utf8?q?oof=20temp=20above=2020=C2=B0C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) 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 -- 2.49.0