From: David Woodhouse Date: Sun, 8 Dec 2024 16:46:39 +0000 (+0000) Subject: Turn off UFH when no valid temperature readings to avoid overheating X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=44fb2ed57775e3a3c6d9fcb2cc2743d5e4e906ad;p=users%2Fdwmw2%2Fesp32-pool.git Turn off UFH when no valid temperature readings to avoid overheating And bump the minimum to 8°C because the kitchen unit seems to be reporting 6.95°C even while the NTC isn't connected yet. --- diff --git a/ufh.yaml b/ufh.yaml index 9f456d5..035d3ea 100644 --- a/ufh.yaml +++ b/ufh.yaml @@ -19,6 +19,15 @@ # turn on GPIO25, trigger *three* readings a second apart, and turn GPIO25 off # again. The ADC sensor has a filter to average the three readings. +esphome: + includes: + - chrono.h + +globals: + - id: last_valid_temp + type: long long + restore_value: no + script: - id: mqtt_connect_domo then: @@ -74,6 +83,27 @@ script: call.set_target_temperature(target_temp); call.perform(); +time: + - platform: sntp + on_time: + - seconds: 0 + minutes: /1 + then: + lambda: |- + long long now = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); + if (!id(last_valid_temp)) { + id(last_valid_temp) = now; + return; + } + // No valid readings for ten minutes? Turn heat off! + if (now > id(last_valid_temp) + 600) { + ESP_LOGI("ufh", "No valid temperature readings! Turning heating off"); + auto call = id(ntc_climate).make_call(); + call.set_mode("OFF"); + call.perform(); + id(ufh_relay).turn_off(); + } + mqtt: on_connect: then: @@ -141,14 +171,16 @@ sensor: send_every: 1 send_first_at: 1 - clamp: - min_value: 5 + min_value: 8 max_value: 35 ignore_out_of_range: true on_value: then: lambda: |- - if (!isnan(x)) + if (!isnan(x)) { id(tell_domo_svalue)->execute(${domo_temp}, std::to_string(x)); + id(last_valid_temp) = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); + } - platform: resistance id: ntc_resistance