From: David Woodhouse Date: Tue, 30 Jul 2024 20:36:08 +0000 (+0100) Subject: Stop turning the damn pump off! X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0eea28e94019406dfafe88c89d03b3f020c22b1f;p=users%2Fdwmw2%2Fesp32-pool.git Stop turning the damn pump off! --- diff --git a/pool.yaml b/pool.yaml index 81802dd..2349733 100644 --- a/pool.yaml +++ b/pool.yaml @@ -172,15 +172,17 @@ script: 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 && + // Turn pump off if we no longer need heat (for 10 mins) between 5pm and 7pm. + if (t.hour >= 17 && t.hour < 19 && !want_state && id(pool_pump).state && + now > id(pump_last_manual_change) + 600 && 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) { + // Turn pump on if it's warm enough, between 7:30am and 10am (when it comes on anyway). + if (((t.hour == 7 && t.minute >= 30) || t.hour > 8) && + t.hour < 10 && outtemp >= 20.0 && !id(pool_pump).state) { ESP_LOGD("control_value", "Roof temperature over 20°C. Turning pump ON and valve OFF."); id(pool_pump).turn_on(); id(valve_output).turn_off(); @@ -198,7 +200,7 @@ script: 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. + # As soon as we know what the time is (and at 10am and 7pm), decide if the pump should be on. - id: pump_default parameters: force: bool # Set it again even if it was already set since boot @@ -264,6 +266,11 @@ globals: restore_value: no initial_value: '0' + - id: pump_last_manual_change + type: time_t + restore_value: no + initial_value: '0' + time: - platform: sntp id: sntp_time @@ -408,6 +415,7 @@ mqtt: break; case 518: /* Pool pump switch */ + id(pump_last_manual_change) = ::time(NULL); if (nvalue) id(pool_pump).turn_on(); else @@ -643,7 +651,7 @@ sensor: #### Template sensor as their values are publish from a lambda or the BL on_value: then: lambda: |- - id(tell_domo_svalue)->execute(509, std::to_string(x)); + id(tell_domo_nvalue)->execute(509, (int)(x + 0.5)); - platform: ble_client type: rssi