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