Simpler and more predictable heater shutoff

This commit is contained in:
2024-05-07 15:53:34 +02:00
parent b5811ab059
commit e7d6943c09
+10 -19
View File
@@ -8,22 +8,13 @@ esphome:
packages: packages:
device_base: !include templates/mystrom.yaml device_base: !include templates/mystrom.yaml
globals: sensor:
- id: heater_was_on_previous_interval - platform: duty_time
type: bool id: row_heating_time
restore_value: no name: Row heating time
initial_value: "false" lambda: "return id(mystrom_relay).state;"
on_value_range:
interval: above: 18000 # 5h
- interval: 3hours then:
then: - switch.turn_off: mystrom_relay
# Turn off the heater if it's on for 3-6 hours in a row. - sensor.duty_time.reset: row_heating_time
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;
}