From fc8b9379d99c4148c6ba7d86ac6d529a05692afe Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 8 Dec 2024 16:13:11 +0000 Subject: [PATCH] Turn on at estimated time instead of actually ramping up This should cause fewer switches on the relay. --- bathroomfloor.yaml | 13 +++++-------- ufh.yaml | 34 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/bathroomfloor.yaml b/bathroomfloor.yaml index cc03b2a..f8cde1d 100644 --- a/bathroomfloor.yaml +++ b/bathroomfloor.yaml @@ -73,14 +73,14 @@ time: on_time: # Ramp up to 21°C by 06:30 - seconds: 0 - minutes: /5 + minutes: /1 hours: 4,5,6 then: script.execute: id: ramp_up target_temp: 21.0 heat_rate: 0.08 - target_time: 385 # 06:30 - 5 minutes + target_time: 390 # 06:30 # Off (15°C) at 09:30 on weekdays - seconds: 0 @@ -90,7 +90,6 @@ time: then: climate.control: id: ntc_climate - mode: HEAT target_temperature: 15°C # Off (15°C) at 11:00 on weekends @@ -101,28 +100,26 @@ time: then: climate.control: id: ntc_climate - mode: HEAT target_temperature: 15°C # Ramp up to 21°C by 8pm - seconds: 0 - minutes: /5 + minutes: /1 hours: 18,19 then: script.execute: id: ramp_up target_temp: 21.0 heat_rate: 0.08 - target_time: 1195 # 20:00 - 5 minutes + target_time: 1200 # 20:00 - # Off (15°C) at pm. + # Off (15°C) at 9pm. - seconds: 0 minutes: 0 hours: 21 then: climate.control: id: ntc_climate - mode: HEAT target_temperature: 15°C sensor: diff --git a/ufh.yaml b/ufh.yaml index ed60188..9f456d5 100644 --- a/ufh.yaml +++ b/ufh.yaml @@ -46,26 +46,32 @@ script: heat_rate: float # °C/min then: lambda: |- + if (id(ntc_climate).target_temperature == target_temp) + return; + auto t = id(sntp_time).now(); if (!t.is_valid()) return; int now_mins = (t.hour * 60) + t.minute; - int mins_till_target = target_time - now_mins; - - // Set the target for the *end* of the five-min adjustment window - mins_till_target -= 5; - - if (mins_till_target < -4) - return; // Already got there. - - float temp = target_temp - (heat_rate * mins_till_target); - if (temp < 15) - return; - + int time_left = target_time - now_mins; + // Should we turn on early? + if (time_left > 0) { + float current_temp = id(ntc_temperature).state; + if (isnan(current_temp)) + return; + + float temp_delta = target_temp - current_temp; + int time_needed = temp_delta / heat_rate; + ESP_LOGD("ufh", "Need %d minutes to get to target, have %d", + time_needed, time_left); + if (time_needed < time_left) + return; + } + + // The time has come to turn the the UFH on. auto call = id(ntc_climate).make_call(); - call.set_mode("HEAT"); - call.set_target_temperature(temp); + call.set_target_temperature(target_temp); call.perform(); mqtt: -- 2.50.1