esphome:
name: pool
+ on_boot:
+ then:
+ - script.execute:
+ id: pump_default
+ force: false
esp32:
board: esp32-gateway
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.
+ - id: pump_default
+ parameters:
+ force: bool # Set it again even if it was already set since boot
+ then:
+ lambda: |-
+ static bool done = false;
+ if (force || !done) {
+ 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)
+ id(pool_pump).turn_on();
+ else
+ id(pool_pump).turn_off();
+ }
+ done = true;
+ }
+
globals:
- id: solar_in_fails # Number of minutes without a reading.
type: int
# Turn pool pump on at 7am and off at 7pm
- seconds: 0
minutes: 0
- hours: 7
+ hours: 7,19
then:
- - switch.turn_on: pool_pump
- - seconds: 0
- minutes: 0
- hours: 19
- then:
- - switch.turn_off: pool_pump
-
+ script.execute:
+ id: pump_default
+ force: true
+ on_time_sync:
+ then:
+ script.execute:
+ id: pump_default
+ force: false
ethernet:
type: LAN8720