7 Commits

Author SHA1 Message Date
Yurii
05ff426b28 chore: bump version to 1.4.5 2024-10-13 22:39:20 +03:00
Yurii
45af7a30d8 refactor: cosmetic changes; added coeff. setting for filtering numeric values 2024-10-13 21:42:33 +03:00
Yurii
8aab541afa fix: added min DHW flow rate of 0.1 l/min 2024-10-11 01:38:05 +03:00
Yurii
7672c4b927 fix: fix types 2024-10-11 01:33:49 +03:00
Yurii
b0a9460257 feat: added correction coeff. settings for pressure and dhw flow rate 2024-10-11 01:29:50 +03:00
Yurii
3c69f1295e feat: added opentherm option for filtering numeric values 2024-10-10 21:08:13 +03:00
Yurii
282a02ecdb fix: added request for set opentherm version 2024-10-09 12:33:58 +03:00
8 changed files with 238 additions and 43 deletions

View File

@@ -13,7 +13,7 @@
extra_configs = secrets.default.ini
[env]
version = 1.4.4
version = 1.4.5
framework = arduino
lib_deps =
bblanchon/ArduinoJson@^7.1.0

View File

@@ -22,8 +22,6 @@ protected:
bool isInitialized = false;
unsigned long initializedTime = 0;
unsigned int initializedMemberIdCode = 0;
byte dhwFlowRateMultiplier = 1;
byte pressureMultiplier = 1;
bool pump = true;
unsigned long lastSuccessResponse = 0;
unsigned long prevUpdateNonEssentialVars = 0;
@@ -228,8 +226,6 @@ protected:
this->isInitialized = true;
this->initializedTime = millis();
this->initializedMemberIdCode = settings.opentherm.memberIdCode;
this->dhwFlowRateMultiplier = 1;
this->pressureMultiplier = 1;
this->initialize();
}
@@ -258,7 +254,7 @@ protected:
// These parameters will be updated every minute
if (millis() - this->prevUpdateNonEssentialVars > 60000) {
if (!heatingEnabled && settings.opentherm.modulationSyncWithHeating) {
if (setMaxModulationLevel(0)) {
if (this->setMaxModulationLevel(0)) {
Log.snoticeln(FPSTR(L_OT_HEATING), F("Set max modulation 0% (off)"));
} else {
@@ -266,7 +262,7 @@ protected:
}
} else {
if (setMaxModulationLevel(settings.heating.maxModulation)) {
if (this->setMaxModulationLevel(settings.heating.maxModulation)) {
Log.snoticeln(FPSTR(L_OT_HEATING), F("Set max modulation %hhu%%"), settings.heating.maxModulation);
} else {
@@ -277,7 +273,7 @@ protected:
// Get DHW min/max temp (if necessary)
if (settings.opentherm.dhwPresent && settings.opentherm.getMinMaxTemp) {
if (updateMinMaxDhwTemp()) {
if (this->updateMinMaxDhwTemp()) {
if (settings.dhw.minTemp < vars.parameters.dhwMinTemp) {
settings.dhw.minTemp = vars.parameters.dhwMinTemp;
fsSettings.update();
@@ -307,7 +303,7 @@ protected:
// Get heating min/max temp
if (settings.opentherm.getMinMaxTemp) {
if (updateMinMaxHeatingTemp()) {
if (this->updateMinMaxHeatingTemp()) {
if (settings.heating.minTemp < vars.parameters.heatingMinTemp) {
settings.heating.minTemp = vars.parameters.heatingMinTemp;
fsSettings.update();
@@ -334,14 +330,9 @@ protected:
fsSettings.update();
}
// Get outdoor temp (if necessary)
if (settings.sensors.outdoor.type == SensorType::BOILER) {
updateOutsideTemp();
}
// Get fault code (if necessary)
if (vars.states.fault) {
updateFaultCode();
this->updateFaultCode();
} else if (vars.sensors.faultCode != 0) {
vars.sensors.faultCode = 0;
@@ -349,13 +340,23 @@ protected:
// Get diagnostic code (if necessary)
if (vars.states.fault || vars.states.diagnostic) {
updateDiagCode();
this->updateDiagCode();
} else if (vars.sensors.diagnosticCode != 0) {
vars.sensors.diagnosticCode = 0;
}
updatePressure();
// If filtering is disabled, then it is enough to
// update these parameters once a minute
if (!settings.opentherm.filterNumValues.enable) {
// Get outdoor temp (if necessary)
if (settings.sensors.outdoor.type == SensorType::BOILER) {
this->updateOutdoorTemp();
}
// Get pressure
this->updatePressure();
}
this->prevUpdateNonEssentialVars = millis();
}
@@ -363,7 +364,7 @@ protected:
// Get current modulation level (if necessary)
if (vars.states.flame) {
updateModulationLevel();
this->updateModulationLevel();
} else {
vars.sensors.modulation = 0;
@@ -371,8 +372,8 @@ protected:
// Update DHW sensors (if necessary)
if (settings.opentherm.dhwPresent) {
updateDhwTemp();
updateDhwFlowRate();
this->updateDhwTemp();
this->updateDhwFlowRate();
} else {
vars.temperatures.dhw = 0.0f;
@@ -380,13 +381,25 @@ protected:
}
// Get current heating temp
updateHeatingTemp();
this->updateHeatingTemp();
// Get heating return temp
updateHeatingReturnTemp();
this->updateHeatingReturnTemp();
// Get exhaust temp
updateExhaustTemp();
this->updateExhaustTemp();
// If filtering is enabled, these parameters
// must be updated every time.
if (settings.opentherm.filterNumValues.enable) {
// Get outdoor temp (if necessary)
if (settings.sensors.outdoor.type == SensorType::BOILER) {
this->updateOutdoorTemp();
}
// Get pressure
this->updatePressure();
}
// Fault reset action
@@ -557,6 +570,13 @@ protected:
Log.swarningln(FPSTR(L_OT), F("Get slave OT version failed"));
}
if (this->setMasterOtVersion(2.2f)) {
Log.straceln(FPSTR(L_OT), F("Master OT version: %f"), vars.parameters.masterOtVersion);
} else {
Log.swarningln(FPSTR(L_OT), F("Set master OT version failed"));
}
if (this->updateSlaveConfig()) {
Log.straceln(FPSTR(L_OT), F("Slave member id: %u, flags: %u"), vars.parameters.slaveMemberId, vars.parameters.slaveFlags);
@@ -792,7 +812,7 @@ protected:
return CustomOpenTherm::isValidResponse(response);
}
bool updateOutsideTemp() {
bool updateOutdoorTemp() {
unsigned long response = this->instance->sendRequest(CustomOpenTherm::buildRequest(
OpenThermRequestType::READ_DATA,
OpenThermMessageID::Toutside,
@@ -803,12 +823,19 @@ protected:
return false;
}
vars.temperatures.outdoor = settings.sensors.outdoor.offset + convertTemp(
float value = settings.sensors.outdoor.offset + convertTemp(
CustomOpenTherm::getFloat(response),
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.temperatures.outdoor) >= 0.1f) {
vars.temperatures.outdoor += (value - vars.temperatures.outdoor) * settings.opentherm.filterNumValues.factor;
} else {
vars.temperatures.outdoor = value;
}
return true;
}
@@ -828,12 +855,19 @@ protected:
return false;
}
vars.temperatures.exhaust = convertTemp(
value = convertTemp(
value,
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.temperatures.exhaust) >= 0.1f) {
vars.temperatures.exhaust += (value - vars.temperatures.exhaust) * settings.opentherm.filterNumValues.factor;
} else {
vars.temperatures.exhaust = value;
}
return true;
}
@@ -853,12 +887,19 @@ protected:
return false;
}
vars.temperatures.heating = convertTemp(
value = convertTemp(
value,
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.temperatures.heating) >= 0.1f) {
vars.temperatures.heating += (value - vars.temperatures.heating) * settings.opentherm.filterNumValues.factor;
} else {
vars.temperatures.heating = value;
}
return true;
}
@@ -873,12 +914,20 @@ protected:
return false;
}
vars.temperatures.heatingReturn = convertTemp(
float value = convertTemp(
CustomOpenTherm::getFloat(response),
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.temperatures.heatingReturn) >= 0.1f) {
vars.temperatures.heatingReturn += (value - vars.temperatures.heatingReturn) * settings.opentherm.filterNumValues.factor;
} else {
vars.temperatures.heatingReturn = value;
}
return true;
}
@@ -899,12 +948,19 @@ protected:
return false;
}
vars.temperatures.dhw = convertTemp(
value = convertTemp(
value,
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.temperatures.dhw) >= 0.1f) {
vars.temperatures.dhw += (value - vars.temperatures.dhw) * settings.opentherm.filterNumValues.factor;
} else {
vars.temperatures.dhw = value;
}
return true;
}
@@ -920,15 +976,17 @@ protected:
}
float value = CustomOpenTherm::getFloat(response);
if (this->dhwFlowRateMultiplier != 10 && value > convertVolume(16, UnitSystem::METRIC, settings.opentherm.unitSystem)) {
this->dhwFlowRateMultiplier = 10;
if (value < 0 || value > convertVolume(16, UnitSystem::METRIC, settings.opentherm.unitSystem)) {
return false;
}
vars.sensors.dhwFlowRate = convertVolume(
value / this->dhwFlowRateMultiplier,
value = convertVolume(
value * settings.opentherm.dhwFlowRateFactor,
settings.opentherm.unitSystem,
settings.system.unitSystem
);
vars.sensors.dhwFlowRate = value > 0.09f ? value : 0.0f;
return true;
}
@@ -976,7 +1034,13 @@ protected:
return false;
}
vars.sensors.modulation = CustomOpenTherm::getFloat(response);
float value = CustomOpenTherm::getFloat(response);
if (settings.opentherm.filterNumValues.enable && fabs(vars.sensors.modulation) >= 0.1f) {
vars.sensors.modulation += (value - vars.sensors.modulation) * settings.opentherm.filterNumValues.factor;
} else {
vars.sensors.modulation = value;
}
return true;
}
@@ -993,16 +1057,23 @@ protected:
}
float value = CustomOpenTherm::getFloat(response);
if (this->pressureMultiplier != 10 && value > convertPressure(5, UnitSystem::METRIC, settings.opentherm.unitSystem)) {
this->pressureMultiplier = 10;
if (value < 0 || value > convertPressure(5, UnitSystem::METRIC, settings.opentherm.unitSystem)) {
return false;
}
vars.sensors.pressure = convertPressure(
value / this->pressureMultiplier,
value = convertPressure(
value * settings.opentherm.pressureFactor,
settings.opentherm.unitSystem,
settings.system.unitSystem
);
if (settings.opentherm.filterNumValues.enable && fabs(vars.sensors.pressure) >= 0.1f) {
vars.sensors.pressure += (value - vars.sensors.pressure) * settings.opentherm.filterNumValues.factor;
} else {
vars.sensors.pressure = value;
}
return true;
}
};

View File

@@ -139,7 +139,8 @@ protected:
// if use pid
if (settings.pid.enable) {
if (vars.parameters.heatingEnabled) {
//if (vars.parameters.heatingEnabled) {
if (settings.heating.enable) {
float pidResult = getPidTemp(
settings.equitherm.enable ? (settings.pid.maxTemp * -1) : settings.pid.minTemp,
settings.pid.maxTemp
@@ -160,8 +161,8 @@ protected:
}
} else if (fabs(pidRegulator.integral) > 0.0001f) {
pidRegulator.integral = 0;
Log.sinfoln(FPSTR(L_REGULATOR_PID), F("Integral sum has been reset"));
pidRegulator.integral = 0;
Log.sinfoln(FPSTR(L_REGULATOR_PID), F("Integral sum has been reset"));
}
// default temp, manual mode
@@ -259,7 +260,7 @@ protected:
pidRegulator.setLimits(minTemp, maxTemp);
pidRegulator.setDt(settings.pid.dt * 1000u);
pidRegulator.input = vars.temperatures.indoor;
pidRegulator.setpoint = settings.heating.target;
pidRegulator.setpoint = vars.states.emergency ? settings.emergency.target : settings.heating.target;
return pidRegulator.getResultTimer();
}

View File

@@ -54,6 +54,8 @@ struct Settings {
byte faultStateGpio = DEFAULT_OT_FAULT_STATE_GPIO;
byte invertFaultState = false;
unsigned int memberIdCode = 0;
float pressureFactor = 1.0f;
float dhwFlowRateFactor = 1.0f;
bool dhwPresent = true;
bool summerWinterMode = false;
bool heatingCh2Enabled = true;
@@ -64,6 +66,11 @@ struct Settings {
bool getMinMaxTemp = true;
bool nativeHeatingControl = false;
bool immergasFix = false;
struct {
bool enable = false;
float factor = 0.1f;
} filterNumValues;
} opentherm;
struct {

View File

@@ -345,6 +345,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
dst["opentherm"]["faultStateGpio"] = src.opentherm.faultStateGpio;
dst["opentherm"]["invertFaultState"] = src.opentherm.invertFaultState;
dst["opentherm"]["memberIdCode"] = src.opentherm.memberIdCode;
dst["opentherm"]["pressureFactor"] = roundd(src.opentherm.pressureFactor, 2);
dst["opentherm"]["dhwFlowRateFactor"] = roundd(src.opentherm.dhwFlowRateFactor, 2);
dst["opentherm"]["dhwPresent"] = src.opentherm.dhwPresent;
dst["opentherm"]["summerWinterMode"] = src.opentherm.summerWinterMode;
dst["opentherm"]["heatingCh2Enabled"] = src.opentherm.heatingCh2Enabled;
@@ -355,6 +357,8 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
dst["opentherm"]["getMinMaxTemp"] = src.opentherm.getMinMaxTemp;
dst["opentherm"]["nativeHeatingControl"] = src.opentherm.nativeHeatingControl;
dst["opentherm"]["immergasFix"] = src.opentherm.immergasFix;
dst["opentherm"]["filterNumValues"]["enable"] = src.opentherm.filterNumValues.enable;
dst["opentherm"]["filterNumValues"]["factor"] = roundd(src.opentherm.filterNumValues.factor, 2);
dst["mqtt"]["enable"] = src.mqtt.enable;
dst["mqtt"]["server"] = src.mqtt.server;
@@ -694,6 +698,42 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
}
}
if (!src["opentherm"]["pressureFactor"].isNull()) {
float value = src["opentherm"]["pressureFactor"].as<float>();
if (value > 0 && value <= 100 && fabs(value - dst.opentherm.pressureFactor) > 0.0001f) {
dst.opentherm.pressureFactor = roundd(value, 2);
changed = true;
}
}
if (!src["opentherm"]["dhwFlowRateFactor"].isNull()) {
float value = src["opentherm"]["dhwFlowRateFactor"].as<float>();
if (value > 0 && value <= 100 && fabs(value - dst.opentherm.dhwFlowRateFactor) > 0.0001f) {
dst.opentherm.dhwFlowRateFactor = roundd(value, 2);
changed = true;
}
}
if (src["opentherm"]["filterNumValues"]["enable"].is<bool>()) {
bool value = src["opentherm"]["filterNumValues"]["enable"].as<bool>();
if (value != dst.opentherm.filterNumValues.enable) {
dst.opentherm.filterNumValues.enable = value;
changed = true;
}
}
if (!src["opentherm"]["filterNumValues"]["factor"].isNull()) {
float value = src["opentherm"]["filterNumValues"]["factor"].as<float>();
if (value > 0 && value <= 1 && fabs(value - dst.opentherm.filterNumValues.factor) > 0.0001f) {
dst.opentherm.filterNumValues.factor = roundd(value, 2);
changed = true;
}
}
if (src["opentherm"]["dhwPresent"].is<bool>()) {
bool value = src["opentherm"]["dhwPresent"].as<bool>();

View File

@@ -261,6 +261,25 @@
"outGpio": "Out GPIO",
"ledGpio": "RX LED GPIO",
"memberIdCode": "Master MemberID code",
"pressureFactor": {
"title": "Coeff. pressure correction",
"note": "If the pressure displayed is <b>X10</b> from the real one, set the <b>0.1</b>."
},
"dhwFlowRateFactor": {
"title": "Coeff. DHW flow rate correction",
"note": "If the DHW flow rate displayed is <b>X10</b> from the real one, set the <b>0.1</b>."
},
"fnv": {
"title": "Filtering numeric values",
"enable": {
"title": "Enable filtering",
"note": "It can be useful if there is a lot of sharp noise on the charts. The filter used is \"Running Average\"."
},
"factor": {
"title": "Filtration coeff.",
"note": "The lower the value, the smoother and <u>longer</u> the change in numeric values."
}
},
"options": {
"dhwPresent": "DHW present",

View File

@@ -261,6 +261,25 @@
"outGpio": "Выход GPIO",
"ledGpio": "RX LED GPIO",
"memberIdCode": "Master MemberID код",
"pressureFactor": {
"title": "Коэфф. коррекции давления",
"note": "Если давление отображается <b>Х10</b> от реального, установите значение <b>0.1</b>."
},
"dhwFlowRateFactor": {
"title": "Коэфф. коррекции потока ГВС",
"note": "Если поток ГВС отображается <b>Х10</b> от реального, установите значение <b>0.1</b>."
},
"fnv": {
"title": "Фильтрация числовых значений",
"enable": {
"title": "Включить фильтрацию",
"note": "Может быть полезно, если на графиках много резкого шума. В качестве фильтра используется \"бегущее среднее\"."
},
"factor": {
"title": "Коэфф. фильтрации",
"note": "Чем меньше коэф., тем плавнее и <u>дольше</u> изменение числовых значений."
}
},
"options": {
"dhwPresent": "Контур ГВС",

View File

@@ -401,6 +401,20 @@
</label>
</div>
<div class="grid">
<label for="opentherm-pressure-factor">
<span data-i18n>settings.ot.pressureFactor.title</span>
<input type="number" inputmode="numeric" id="opentherm-pressure-factor" name="opentherm[pressureFactor]" min="0.1" max="100" step="0.01">
<small data-i18n>settings.ot.pressureFactor.note</small>
</label>
<label for="opentherm-dhw-fr-factor">
<span data-i18n>settings.ot.dhwFlowRateFactor.title</span>
<input type="number" inputmode="numeric" id="opentherm-dhw-fr-factor" name="opentherm[dhwFlowRateFactor]" min="0.1" max="100" step="0.01">
<small data-i18n>settings.ot.dhwFlowRateFactor.note</small>
</label>
</div>
<fieldset>
<legend data-i18n>settings.section.ot.options</legend>
<label for="opentherm-dhw-present">
@@ -443,11 +457,31 @@
<span data-i18n>settings.ot.options.getMinMaxTemp</span>
</label>
<label for="opentherm-immergas-fix"></label>
<label for="opentherm-immergas-fix">
<input type="checkbox" id="opentherm-immergas-fix" name="opentherm[immergasFix]" value="true">
<span data-i18n>settings.ot.options.immergasFix</span>
</label>
<hr />
<fieldset>
<legend>
<span data-i18n>settings.ot.fnv.title</span>
</legend>
<label for="opentherm-fnv-enable">
<input type="checkbox" id="opentherm-fnv-enable" name="opentherm[filterNumValues][enable]" value="true">
<span data-i18n>settings.ot.fnv.enable.title</span>
<br>
<small data-i18n>settings.ot.fnv.enable.note</small>
</label>
<label for="opentherm-fnv-factor">
<span data-i18n>settings.ot.fnv.factor.title</span>
<input type="number" inputmode="numeric" id="opentherm-fnv-factor" name="opentherm[filterNumValues][factor]" min="0.01" max="1" step="0.01">
<small data-i18n>settings.ot.fnv.factor.note</small>
</label>
</fieldset>
<hr />
<fieldset>
<label for="opentherm-fault-state-gpio">
@@ -732,6 +766,8 @@
setInputValue('#opentherm-fault-state-gpio', data.opentherm.faultStateGpio < 255 ? data.opentherm.faultStateGpio : '');
setCheckboxValue('#opentherm-invert-fault-state', data.opentherm.invertFaultState);
setInputValue('#opentherm-member-id-code', data.opentherm.memberIdCode);
setInputValue('#opentherm-pressure-factor', data.opentherm.pressureFactor);
setInputValue('#opentherm-dhw-fr-factor', data.opentherm.dhwFlowRateFactor);
setCheckboxValue('#opentherm-dhw-present', data.opentherm.dhwPresent);
setCheckboxValue('#opentherm-sw-mode', data.opentherm.summerWinterMode);
setCheckboxValue('#opentherm-heating-ch2-enabled', data.opentherm.heatingCh2Enabled);
@@ -742,6 +778,8 @@
setCheckboxValue('#opentherm-get-min-max-temp', data.opentherm.getMinMaxTemp);
setCheckboxValue('#opentherm-native-heating-control', data.opentherm.nativeHeatingControl);
setCheckboxValue('#opentherm-immergas-fix', data.opentherm.immergasFix);
setCheckboxValue('#opentherm-fnv-enable', data.opentherm.filterNumValues.enable);
setInputValue('#opentherm-fnv-factor', data.opentherm.filterNumValues.factor);
setBusy('#opentherm-settings-busy', '#opentherm-settings', false);
// MQTT