8 Commits

Author SHA1 Message Date
Yurii
6539211b8f refactor: reworked freeze protection 2026-02-16 11:48:28 +03:00
Yurii
40fe40eb8a refactor: impoved freeze protection 2026-02-12 23:33:22 +03:00
Yurii
3a6bb03456 chore: fix build 2026-02-12 23:32:39 +03:00
Yurii
7fcca3c4aa chore: fix ha blueprints to support all source sensors 2026-01-26 02:09:57 +03:00
Yurii
2f6bd237c7 chore: updated ha blueprints for new releases 2026-01-26 01:59:03 +03:00
Yurii
e4d1ba7d7b refactor: added different timeouts for wired and wireless sensors 2026-01-26 01:03:26 +03:00
Yurii
b70c212235 fix: filtering fake data from ds18b20 (#217) 2026-01-23 00:19:03 +03:00
Yurii
781b2a1f9c chore: bump pioarduino/platform-espressif32 from 3.3.5 to 3.3.6 2026-01-23 00:17:30 +03:00
17 changed files with 160 additions and 85 deletions

View File

@@ -1,5 +1,5 @@
# Blueprint for reporting indoor/outdoor temperature to OpenTherm Gateway from any home assistant sensor
# Updated: 03.09.2024
# Updated: 26.01.2026
blueprint:
name: Report temp to OpenTherm Gateway
@@ -15,7 +15,6 @@ blueprint:
multiple: false
filter:
- domain: sensor
device_class: temperature
target_entity:
name: Target entity
description: "Usually ``number.opentherm_indoor_temp`` or ``number.opentherm_outdoor_temp``"
@@ -38,8 +37,12 @@ condition:
value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action:
- if:
- condition: or
conditions:
- condition: template
value_template: "{{ (states(source_entity)|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.01 }}"
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp(states[target_entity].last_updated)) | int(0) > 300 }}"
then:
- service: number.set_value
data:

View File

@@ -1,5 +1,5 @@
# Blueprint for reporting temperature to OpenTherm Gateway from home assistant weather integration
# Updated: 03.09.2024
# Updated: 26.01.2026
blueprint:
name: Report temp to OpenTherm Gateway from Weather
@@ -37,8 +37,12 @@ condition:
value_template: "{{ states(source_entity) != 'unavailable' and states(target_entity) != 'unavailable' }}"
action:
- if:
- condition: or
conditions:
- condition: template
value_template: "{{ (state_attr(source_entity, 'temperature')|float(0) - states(target_entity)|float(0)) | abs | round(2) >= 0.1 }}"
- condition: template
value_template: "{{ (as_timestamp(now()) - as_timestamp(states[target_entity].last_updated)) | int(0) > 300 }}"
then:
- service: number.set_value
data:

View File

@@ -25,8 +25,11 @@ lib_deps =
gyverlibs/FileData@^1.0.3
gyverlibs/GyverPID@^3.3.2
gyverlibs/GyverBlinker@^1.1.1
https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg
pstolarz/OneWireNg@^0.14.1
;milesburton/DallasTemperature@^4.0.5
https://github.com/Laxilef/Arduino-Temperature-Control-Library#fix_85c
laxilef/TinyLogger@^1.1.1
lib_ignore = OneWire
build_type = ${secrets.build_type}
build_flags =
-mtext-section-literals
@@ -73,7 +76,7 @@ platform_packages = ${env.platform_packages}
lib_deps =
${env.lib_deps}
nrwiersma/ESP8266Scheduler@^1.2
lib_ignore =
lib_ignore = ${env.lib_ignore}
extra_scripts =
post:tools/build.py
build_type = ${env.build_type}
@@ -92,14 +95,14 @@ check_flags = ${env.check_flags}
;platform_packages =
; framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.5
; framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-lib-builder/releases/download/idf-release_v5.1/esp32-arduino-libs-idf-release_v5.1-33fbade6.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.36/platform-espressif32.zip
platform_packages = ${env.platform_packages}
board_build.partitions = esp32_partitions.csv
lib_deps =
${env.lib_deps}
laxilef/ESP32Scheduler@^1.0.1
nimble_lib = h2zero/NimBLE-Arduino@2.3.7
lib_ignore =
lib_ignore = ${env.lib_ignore}
extra_scripts =
post:tools/esp32.py
post:tools/build.py

View File

@@ -43,8 +43,6 @@ protected:
bool telnetStarted = false;
bool emergencyDetected = false;
unsigned long emergencyFlipTime = 0;
bool freezeDetected = false;
unsigned long freezeDetectedTime = 0;
#if defined(ARDUINO_ARCH_ESP32)
const char* getTaskName() override {
@@ -135,8 +133,6 @@ protected:
tMqtt->disable();
}
Sensors::setConnectionStatusByType(Sensors::Type::MANUAL, !settings.mqtt.enabled || vars.mqtt.connected, false);
} else {
if (this->ntpStarted) {
this->ntpStarted = false;
@@ -245,7 +241,7 @@ protected:
void heating() {
// freeze protection
if (!settings.heating.enabled) {
{
float lowTemp = 255.0f;
uint8_t availableSensors = 0;
@@ -276,29 +272,40 @@ protected:
availableSensors++;
}
if (availableSensors && lowTemp <= settings.heating.freezeProtection.lowTemp) {
if (!this->freezeDetected) {
this->freezeDetected = true;
this->freezeDetectedTime = millis();
} else if (millis() - this->freezeDetectedTime > (settings.heating.freezeProtection.thresholdTime * 1000)) {
this->freezeDetected = false;
settings.heating.enabled = true;
fsSettings.update();
if (availableSensors) {
if (vars.master.heating.freezing) {
if (lowTemp - (float) settings.heating.freezeProtection.highTemp + 0.0001f >= 0.0f) {
vars.master.heating.freezing = false;
Log.sinfoln(
FPSTR(L_MAIN),
F("Heating turned on by freeze protection, current low temp: %.2f, threshold: %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp
F("No freezing detected. Current low temp: %.2f, threshold (high): %hhu"),
lowTemp, settings.heating.freezeProtection.highTemp
);
}
} else if (this->freezeDetected) {
this->freezeDetected = false;
} else {
if ((float) settings.heating.freezeProtection.lowTemp - lowTemp + 0.0001f >= 0.0f) {
vars.master.heating.freezing = true;
if (!settings.heating.enabled) {
settings.heating.enabled = true;
fsSettings.update();
}
} else if (this->freezeDetected) {
this->freezeDetected = false;
Log.sinfoln(
FPSTR(L_MAIN),
F("Freezing detected! Current low temp: %.2f, threshold (low): %hhu"),
lowTemp, settings.heating.freezeProtection.lowTemp
);
}
}
} else if (vars.master.heating.freezing) {
vars.master.heating.freezing = false;
Log.sinfoln(FPSTR(L_MAIN), F("No sensors available, freeze protection unavailable!"));
}
}
}

View File

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

View File

@@ -240,6 +240,11 @@ protected:
) * 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;
}
};

View File

@@ -66,7 +66,8 @@ public:
}
protected:
const unsigned int disconnectedTimeout = 120000;
const unsigned int wiredDisconnectTimeout = 180000u;
const unsigned int wirelessDisconnectTimeout = 600000u;
const unsigned short dallasSearchInterval = 60000;
const unsigned short dallasPollingInterval = 10000;
const unsigned short globalPollingInterval = 15000;
@@ -1004,12 +1005,16 @@ protected:
} else if (rSensor.connected && sSensor.purpose == Sensors::Purpose::NOT_CONFIGURED) {
Sensors::setConnectionStatusById(sensorId, false, false);
} else if (sSensor.type != Sensors::Type::MANUAL && rSensor.connected && (millis() - rSensor.activityTime) > this->disconnectedTimeout) {
} else if (rSensor.connected) {
if (sSensor.type == Sensors::Type::MANUAL || sSensor.type == Sensors::Type::BLUETOOTH) {
if ((millis() - rSensor.activityTime) > this->wirelessDisconnectTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false);
}
}/* else if (!rSensor.connected) {
rSensor.connected = true;
}*/
} else if ((millis() - rSensor.activityTime) > this->wiredDisconnectTimeout) {
Sensors::setConnectionStatusById(sensorId, false, false);
}
}
}
}

View File

@@ -121,8 +121,8 @@ struct Settings {
} overheatProtection;
struct {
uint8_t highTemp = 15;
uint8_t lowTemp = 10;
unsigned short thresholdTime = 600;
} freezeProtection;
} heating;
@@ -304,6 +304,7 @@ struct Variables {
bool enabled = false;
bool indoorTempControl = false;
bool overheat = false;
bool freezing = false;
float setpointTemp = 0.0f;
float targetTemp = 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_FAULT[] PROGMEM = "fault";
const char S_FREEZE_PROTECTION[] PROGMEM = "freezeProtection";
const char S_FREEZING[] PROGMEM = "freezing";
const char S_FILTERING[] PROGMEM = "filtering";
const char S_FILTERING_FACTOR[] PROGMEM = "filteringFactor";
const char S_FLAGS[] PROGMEM = "flags";

View File

@@ -505,8 +505,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
heatingOverheatProtection[FPSTR(S_LOW_TEMP)] = src.heating.overheatProtection.lowTemp;
auto freezeProtection = heating[FPSTR(S_FREEZE_PROTECTION)].to<JsonObject>();
freezeProtection[FPSTR(S_HIGH_TEMP)] = src.heating.freezeProtection.highTemp;
freezeProtection[FPSTR(S_LOW_TEMP)] = src.heating.freezeProtection.lowTemp;
freezeProtection[FPSTR(S_THRESHOLD_TIME)] = src.heating.freezeProtection.thresholdTime;
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
@@ -1426,6 +1426,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
changed = true;
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_HIGH_TEMP)].as<uint8_t>();
if (isValidTemp(value, dst.system.unitSystem, 1, 50) && value != dst.heating.freezeProtection.highTemp) {
dst.heating.freezeProtection.highTemp = value;
changed = true;
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_LOW_TEMP)].as<uint8_t>();
@@ -1435,16 +1444,10 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
if (!src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].isNull()) {
unsigned short value = src[FPSTR(S_HEATING)][FPSTR(S_FREEZE_PROTECTION)][FPSTR(S_THRESHOLD_TIME)].as<unsigned short>();
if (value >= 30 && value <= 1800) {
if (value != dst.heating.freezeProtection.thresholdTime) {
dst.heating.freezeProtection.thresholdTime = value;
if (dst.heating.freezeProtection.highTemp < dst.heating.freezeProtection.lowTemp) {
dst.heating.freezeProtection.highTemp = dst.heating.freezeProtection.lowTemp;
changed = true;
}
}
}
// dhw
@@ -2109,21 +2112,18 @@ bool jsonToSensorResult(const uint8_t sensorId, const JsonVariantConst src) {
return false;
}
auto& dst = Sensors::results[sensorId];
bool changed = false;
// value
if (!src[FPSTR(S_VALUE)].isNull()) {
float value = src[FPSTR(S_VALUE)].as<float>();
uint8_t vType = static_cast<uint8_t>(Sensors::ValueType::PRIMARY);
if (fabsf(value - dst.values[vType]) > 0.0001f) {
dst.values[vType] = roundf(value, 2);
changed = true;
}
return Sensors::setValueById(
sensorId,
src[FPSTR(S_VALUE)].as<float>(),
Sensors::ValueType::PRIMARY,
true,
true
);
}
return changed;
return false;
}
void varsToJson(const Variables& src, JsonVariant dst) {
@@ -2173,6 +2173,7 @@ void varsToJson(const Variables& src, JsonVariant dst) {
mHeating[FPSTR(S_BLOCKING)] = src.master.heating.blocking;
mHeating[FPSTR(S_INDOOR_TEMP_CONTROL)] = src.master.heating.indoorTempControl;
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_TARGET_TEMP)] = roundf(src.master.heating.targetTemp, 2);
mHeating[FPSTR(S_CURRENT_TEMP)] = roundf(src.master.heating.currentTemp, 2);

View File

@@ -320,9 +320,15 @@
},
"freezeProtection": {
"title": "防冻保护",
"desc": "当热媒或室内温度在<b>等待时间</b> 内降至<b>低温阈值</b>以下时,系统将强制启动加热功能。",
"lowTemp": "低温阈值",
"thresholdTime": "等待时间<small>(秒)</small>"
"desc": "如果热载体或室内温度低于 <b>低温</b>,加热将被强制开启。",
"highTemp": {
"title": "高温阈值",
"note": "防冻保护激活后系统恢复正常模式的阈值"
},
"lowTemp": {
"title": "低温阈值",
"note": "强制开启加热的阈值"
}
},
"portal": {

View File

@@ -119,6 +119,7 @@
"mHeatEnabled": "Heating enabled",
"mHeatBlocking": "Heating blocked",
"mHeatOverheat": "Heating overheat",
"mHeatFreezing": "Heating freezing",
"sHeatActive": "Heating active",
"mHeatSetpointTemp": "Heating setpoint temp",
"mHeatTargetTemp": "Heating target temp",
@@ -320,9 +321,15 @@
},
"freezeProtection": {
"title": "Freeze protection",
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b> during <b>Waiting time</b>.",
"lowTemp": "Low temperature threshold",
"thresholdTime": "Waiting time <small>(sec)</small>"
"desc": "Heating will be forced to turn on if the heat carrier or indoor temperature drops below <b>Low temperature</b>.",
"highTemp": {
"title": "High temperature threshold",
"note": "Threshold when the system returns to normal mode after freeze protection activation"
},
"lowTemp": {
"title": "Low temperature threshold",
"note": "Threshold when heating is forced to turn on"
}
},
"portal": {

View File

@@ -320,9 +320,15 @@
},
"freezeProtection": {
"title": "Protezione antigelo",
"desc": "Il riscaldamento verrà attivato forzatamente se la temperatura del vettore di calore o interna scende al di sotto della <b>temperatura minima</b> durante il <b>tempo di attesa</b>.",
"lowTemp": "Soglia di temperatura minima",
"thresholdTime": "Tempo di attesa <small>(sec)</small>"
"desc": "Il riscaldamento verrà forzatamente attivato se la temperatura del vettore termico o la temperatura interna scende al di sotto della <b>Soglia di temperatura bassa</b>.",
"highTemp": {
"title": "Soglia di temperatura alta",
"note": "Soglia quando il sistema ritorna alla modalità normale dopo l'attivazione della protezione antigelo"
},
"lowTemp": {
"title": "Soglia di temperatura bassa",
"note": "Soglia quando il riscaldamento viene forzatamente attivato"
}
},
"portal": {

View File

@@ -294,11 +294,18 @@
}
},
"freezeProtection": {
"title": "Vorstbeveiliging",
"desc": "De verwarming wordt geforceerd ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur onder de <b>Lage temperatuur</b> daalt gedurende de <b>Wachttijd</b>.",
"lowTemp": "Drempelwaarde lage temperatuur",
"thresholdTime": "Wachttijd <small>(sec)</small>"
"title": "Vorbeveiliging",
"desc": "Verwarming zal geforceerd worden ingeschakeld als de temperatuur van de warmtedrager of de binnentemperatuur daalt onder de <b>Lage temperatuurdrempel</b>.",
"highTemp": {
"title": "Hoge temperatuurdrempel",
"note": "Drempel waarna het systeem terugkeert naar de normale modus na activering van de vorbeveiliging"
},
"lowTemp": {
"title": "Lage temperatuurdrempel",
"note": "Drempel wanneer de verwarming geforceerd wordt ingeschakeld"
}
},
"portal": {
"login": "Gebruikersnaam",
"password": "Wachtwoord",

View File

@@ -320,9 +320,15 @@
},
"freezeProtection": {
"title": "Защита от замерзания",
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b> в течение <b>времени ожидания</b>.",
"lowTemp": "Нижний порог температуры",
"thresholdTime": "Время ожидания <small>(сек)</small>"
"desc": "Отопление будет принудительно включено, если темп. теплоносителя или внутренняя темп. опустится ниже <b>нижнего порога</b>.",
"highTemp": {
"title": "Верхний порог температуры",
"note": "Порог, при котором система вернется в нормальное состояние после активации защиты от замерзания"
},
"lowTemp": {
"title": "Нижний порог температуры",
"note": "Порог, при котором отопление будет принудительно включено"
}
},
"portal": {

View File

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

View File

@@ -265,13 +265,15 @@
<div class="grid">
<label>
<span data-i18n>settings.freezeProtection.lowTemp</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
<span data-i18n>settings.freezeProtection.highTemp.title</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][highTemp]" min="0" max="0" step="1" required>
<small data-i18n>settings.freezeProtection.highTemp.note</small>
</label>
<label>
<span data-i18n>settings.freezeProtection.thresholdTime</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][thresholdTime]" min="30" max="1800" step="1" required>
<span data-i18n>settings.freezeProtection.lowTemp.title</span>
<input type="number" inputmode="numeric" name="heating[freezeProtection][lowTemp]" min="0" max="0" step="1" required>
<small data-i18n>settings.freezeProtection.lowTemp.note</small>
</label>
</div>
@@ -1184,11 +1186,14 @@
"min": 0,
"max": data.system.unitSystem == 0 ? 99 : 211
});
setInputValue("[name='heating[freezeProtection][highTemp]']", data.heating.freezeProtection.highTemp, {
"min": data.system.unitSystem == 0 ? 1 : 34,
"max": data.system.unitSystem == 0 ? 50 : 122
});
setInputValue("[name='heating[freezeProtection][lowTemp]']", data.heating.freezeProtection.lowTemp, {
"min": data.system.unitSystem == 0 ? 1 : 34,
"max": data.system.unitSystem == 0 ? 30 : 86
});
setInputValue("[name='heating[freezeProtection][thresholdTime]']", data.heating.freezeProtection.thresholdTime);
setBusy('#heating-settings-busy', '#heating-settings', false);
// DHW