From: David Woodhouse Date: Thu, 9 May 2024 09:27:09 +0000 (+0100) Subject: Turn pump off when it gets cold after 5pm X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=df5838affc11d4c4734e7d2cfac0bfbd450b5f18;p=users%2Fdwmw2%2Fesp32-pool.git Turn pump off when it gets cold after 5pm 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. --- diff --git a/pool.yaml b/pool.yaml index 64807ea..865658e 100644 --- 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();