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
then:
climate.control:
id: ntc_climate
- mode: HEAT
target_temperature: 15°C
# Off (15°C) at 11:00 on weekends
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:
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: