refactor: impoved freeze protection

This commit is contained in:
Yurii
2026-02-12 23:33:22 +03:00
parent 3a6bb03456
commit 40fe40eb8a
8 changed files with 48 additions and 16 deletions

View File

@@ -243,7 +243,7 @@ protected:
void heating() { void heating() {
// freeze protection // freeze protection
if (!settings.heating.enabled) { {
float lowTemp = 255.0f; float lowTemp = 255.0f;
uint8_t availableSensors = 0; uint8_t availableSensors = 0;
@@ -275,14 +275,19 @@ protected:
} }
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) { if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
if (!vars.master.heating.freezing) {
if (!this->freezeDetected) { if (!this->freezeDetected) {
this->freezeDetected = true; this->freezeDetected = true;
this->freezeDetectedTime = millis(); this->freezeDetectedTime = millis();
} else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) { } else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) {
this->freezeDetected = false; this->freezeDetected = false;
vars.master.heating.freezing = true;
if (!settings.heating.enabled) {
settings.heating.enabled = true; settings.heating.enabled = true;
fsSettings.update(); fsSettings.update();
}
Log.sinfoln( Log.sinfoln(
FPSTR(L_MAIN), FPSTR(L_MAIN),
@@ -290,13 +295,23 @@ protected:
lowTemp, settings.heating.freezeProtection.lowTemp lowTemp, settings.heating.freezeProtection.lowTemp
); );
} }
}
} else if (this->freezeDetected) { } else {
if (this->freezeDetected) {
this->freezeDetected = false; this->freezeDetected = false;
} }
} else if (this->freezeDetected) { if (vars.master.heating.freezing) {
this->freezeDetected = false; vars.master.heating.freezing = false;
Log.sinfoln(
FPSTR(L_MAIN),
F("No freezing detected, current low temp: %.2f, threshold: %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp
);
}
}
} }
} }

View File

@@ -170,8 +170,7 @@ protected:
// Heating settings // Heating settings
vars.master.heating.enabled = this->isReady() vars.master.heating.enabled = this->isReady()
&& settings.heating.enabled && settings.heating.enabled
&& vars.cascadeControl.input && (vars.master.heating.freezing || (vars.cascadeControl.input && !vars.master.heating.blocking))
&& !vars.master.heating.blocking
&& !vars.master.heating.overheat; && !vars.master.heating.overheat;
// DHW settings // DHW settings

View File

@@ -240,6 +240,11 @@ protected:
) * settings.heating.turboFactor; ) * settings.heating.turboFactor;
} }
// If freezing, set temperature to no lower than low temp provided by freeze protection
if (vars.master.heating.freezing && fabsf(settings.heating.freezeProtection.lowTemp - newTemp) < 0.0001f) {
newTemp = settings.heating.freezeProtection.lowTemp;
}
return newTemp; return newTemp;
} }
}; };

View File

@@ -304,6 +304,7 @@ struct Variables {
bool enabled = false; bool enabled = false;
bool indoorTempControl = false; bool indoorTempControl = false;
bool overheat = false; bool overheat = false;
bool freezing = false;
float setpointTemp = 0.0f; float setpointTemp = 0.0f;
float targetTemp = 0.0f; float targetTemp = 0.0f;
float currentTemp = 0.0f; float currentTemp = 0.0f;

View File

@@ -87,6 +87,7 @@ const char S_EXTERNAL_PUMP[] PROGMEM = "externalPump";
const char S_FACTOR[] PROGMEM = "factor"; const char S_FACTOR[] PROGMEM = "factor";
const char S_FAULT[] PROGMEM = "fault"; const char S_FAULT[] PROGMEM = "fault";
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection"; const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
const char S_FREEZING[] PROGMEM = "freezing";
const char S_FILTERING[] PROGMEM = "filtering"; const char S_FILTERING[] PROGMEM = "filtering";
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor"; const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
const char S_FLAGS[] PROGMEM = "flags"; const char S_FLAGS[] PROGMEM = "flags";

View File

@@ -2170,6 +2170,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking; mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl; mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat; mHeating[FPSTR(S_OVERHEAT)] = src.master.heating.overheat;
mHeating[FPSTR(S_FREEZING)] = src.master.heating.freezing;
mHeating[FPSTR(S_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2); mHeating[FPSTR(S_SETPOINT_TEMP)] = roundf(src.master.heating.setpointTemp, 2);
mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2); mHeating[FPSTR(S_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2); mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);

View File

@@ -119,6 +119,7 @@
"mHeatEnabled": "Heating enabled", "mHeatEnabled": "Heating enabled",
"mHeatBlocking": "Heating blocked", "mHeatBlocking": "Heating blocked",
"mHeatOverheat": "Heating overheat", "mHeatOverheat": "Heating overheat",
"mHeatFreezing": "Heating freezing",
"sHeatActive": "Heating active", "sHeatActive": "Heating active",
"mHeatSetpointTemp": "Heating setpoint temp", "mHeatSetpointTemp": "Heating setpoint temp",
"mHeatTargetTemp": "Heating target temp", "mHeatTargetTemp": "Heating target temp",

View File

@@ -195,6 +195,10 @@
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th> <th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
<td><i class="mHeatOverheat"></i></td> <td><i class="mHeatOverheat"></i></td>
</tr> </tr>
<tr>
<th scope="row" data-i18n>dashboard.states.mHeatFreezing</th>
<td><i class="mHeatFreezing"></i></td>
</tr>
<tr> <tr>
<th scope="row" data-i18n>dashboard.states.sHeatActive</th> <th scope="row" data-i18n>dashboard.states.sHeatActive</th>
<td><i class="sHeatActive"></i></td> <td><i class="sHeatActive"></i></td>
@@ -633,6 +637,11 @@
result.master.heating.overheat ? "success" : "error", result.master.heating.overheat ? "success" : "error",
result.master.heating.overheat ? "red" : "green" result.master.heating.overheat ? "red" : "green"
); );
setStatus(
'.mHeatFreezing',
result.master.heating.freezing ? "success" : "error",
result.master.heating.freezing ? "red" : "green"
);
setValue('.mHeatSetpointTemp', result.master.heating.setpointTemp); setValue('.mHeatSetpointTemp', result.master.heating.setpointTemp);
setValue('.mHeatTargetTemp', result.master.heating.targetTemp); setValue('.mHeatTargetTemp', result.master.heating.targetTemp);
setValue('.mHeatCurrTemp', result.master.heating.currentTemp); setValue('.mHeatCurrTemp', result.master.heating.currentTemp);