mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-02-28 04:07:07 +05:00
refactor: impoved freeze protection
This commit is contained in:
@@ -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,28 +275,43 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
|
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
|
||||||
if (!this->freezeDetected) {
|
if (!vars.master.heating.freezing) {
|
||||||
this->freezeDetected = true;
|
if (!this->freezeDetected) {
|
||||||
this->freezeDetectedTime = millis();
|
this->freezeDetected = true;
|
||||||
|
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;
|
||||||
|
vars.master.heating.freezing = true;
|
||||||
|
|
||||||
|
if (!settings.heating.enabled) {
|
||||||
|
settings.heating.enabled = true;
|
||||||
|
fsSettings.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.sinfoln(
|
||||||
|
FPSTR(L_MAIN),
|
||||||
|
F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
|
||||||
|
lowTemp, settings.heating.freezeProtection.lowTemp
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (this->freezeDetected) {
|
||||||
this->freezeDetected = false;
|
this->freezeDetected = false;
|
||||||
settings.heating.enabled = true;
|
}
|
||||||
fsSettings.update();
|
|
||||||
|
if (vars.master.heating.freezing) {
|
||||||
|
vars.master.heating.freezing = false;
|
||||||
|
|
||||||
Log.sinfoln(
|
Log.sinfoln(
|
||||||
FPSTR(L_MAIN),
|
FPSTR(L_MAIN),
|
||||||
F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
|
F("No freezing detected, current low temp: %.2f, threshold: %hhu"),
|
||||||
lowTemp, settings.heating.freezeProtection.lowTemp
|
lowTemp, settings.heating.freezeProtection.lowTemp
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (this->freezeDetected) {
|
|
||||||
this->freezeDetected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (this->freezeDetected) {
|
|
||||||
this->freezeDetected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user