From e7d6943c094e5cb3faf39fdf83f06c3e08e96fc3 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Tue, 7 May 2024 15:53:34 +0200 Subject: [PATCH] Simpler and more predictable heater shutoff --- storage-heater.yaml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/storage-heater.yaml b/storage-heater.yaml index b789f3a..0b817b1 100644 --- a/storage-heater.yaml +++ b/storage-heater.yaml @@ -8,22 +8,13 @@ esphome: packages: device_base: !include templates/mystrom.yaml -globals: -- id: heater_was_on_previous_interval - type: bool - restore_value: no - initial_value: "false" - -interval: -- interval: 3hours - then: - # Turn off the heater if it's on for 3-6 hours in a row. - lambda: |- - if (id(mystrom_relay).state) { - if (id(heater_was_on_previous_interval)) { - id(mystrom_relay).turn_off(); - } - id(heater_was_on_previous_interval) = true; - } else { - id(heater_was_on_previous_interval) = false; - } +sensor: +- platform: duty_time + id: row_heating_time + name: Row heating time + lambda: "return id(mystrom_relay).state;" + on_value_range: + above: 18000 # 5h + then: + - switch.turn_off: mystrom_relay + - sensor.duty_time.reset: row_heating_time