From: David Woodhouse Date: Wed, 8 May 2024 11:39:34 +0000 (+0100) Subject: Force bypass valve open before turning pump on in the morning X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7002b7afc3678c70c818e045c437187a87674786;p=users%2Fdwmw2%2Fesp32-pool.git Force bypass valve open before turning pump on in the morning --- diff --git a/pool.yaml b/pool.yaml index 71b1aa8..badd278 100644 --- a/pool.yaml +++ b/pool.yaml @@ -101,15 +101,15 @@ script: return; } - static time_t last_change = 0; time_t now = ::time(NULL); - if (now < last_change + 300) { - ESP_LOGD("control_valve", "Too soon to turn %s (%d seconds)", want_state ? "ON" : "OFF", now - last_change); + 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)); return; } - last_change = now; + id(control_valve_last_change) = now; id(valve_output).toggle(); # As soon as we know what the time is (and at 7am and 7pm), decide if the pump should be on. @@ -170,6 +170,11 @@ globals: restore_value: no initial_value: '1' + - id: control_valve_last_change + type: time_t + restore_value: no + initial_value: '0' + time: - platform: sntp id: sntp_time @@ -214,6 +219,27 @@ time: script.execute: id: pump_default force: true + + # Before turning the pump on in the morning, both 'solar in' + # both 'solar in' and 'solar out' sensors will be reading the + # ambient temperature, as no water is flowing. So open the + # bypass valve (pump directly back to pool) and set the + # control_valve_last_change time so that the temperature logic + # in the control_valve script won't close it again for at + # least five minutes. By which time the 'solar in' sensor + # should be giving *water* temperature, so we won't close the + # valve until the roof genuinely is warmer than the + # water. This means we don't use the pool water to heat up the + # rubber and plastic sitting on the roof; let the *sun* do + # that first! + - seconds: 0 + minutes: 59 + hours: 6 + then: + lambda: |- + id(control_valve_last_change) = ::time(NULL); + id(valve_output).turn_off(); + on_time_sync: then: script.execute: