mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
feat: added correction coeff. settings for pressure and dhw flow rate
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -817,7 +813,7 @@ protected:
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.temperatures.outdoor) >= 0.1f) {
|
||||
vars.temperatures.outdoor += (value - vars.temperatures.outdoor) * EXT_SENSORS_FILTER_K;
|
||||
vars.temperatures.outdoor += (value - vars.temperatures.outdoor) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.temperatures.outdoor = value;
|
||||
@@ -849,7 +845,7 @@ protected:
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.temperatures.exhaust) >= 0.1f) {
|
||||
vars.temperatures.exhaust += (value - vars.temperatures.exhaust) * EXT_SENSORS_FILTER_K;
|
||||
vars.temperatures.exhaust += (value - vars.temperatures.exhaust) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.temperatures.exhaust = value;
|
||||
@@ -881,7 +877,7 @@ protected:
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.temperatures.heating) >= 0.1f) {
|
||||
vars.temperatures.heating += (value - vars.temperatures.heating) * EXT_SENSORS_FILTER_K;
|
||||
vars.temperatures.heating += (value - vars.temperatures.heating) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.temperatures.heating = value;
|
||||
@@ -908,7 +904,7 @@ protected:
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.temperatures.heatingReturn) >= 0.1f) {
|
||||
vars.temperatures.heatingReturn += (value - vars.temperatures.heatingReturn) * EXT_SENSORS_FILTER_K;
|
||||
vars.temperatures.heatingReturn += (value - vars.temperatures.heatingReturn) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.temperatures.heatingReturn = value;
|
||||
@@ -942,7 +938,7 @@ protected:
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.temperatures.dhw) >= 0.1f) {
|
||||
vars.temperatures.dhw += (value - vars.temperatures.dhw) * EXT_SENSORS_FILTER_K;
|
||||
vars.temperatures.dhw += (value - vars.temperatures.dhw) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.temperatures.dhw = value;
|
||||
@@ -963,12 +959,12 @@ 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 / settings.opentherm.dhwFlowRateMultiplier,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
);
|
||||
@@ -1021,7 +1017,7 @@ protected:
|
||||
|
||||
float value = CustomOpenTherm::getFloat(response);
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.sensors.modulation) >= 0.1f) {
|
||||
vars.sensors.modulation += (value - vars.sensors.modulation) * EXT_SENSORS_FILTER_K;
|
||||
vars.sensors.modulation += (value - vars.sensors.modulation) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.sensors.modulation = value;
|
||||
@@ -1042,18 +1038,18 @@ 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;
|
||||
}
|
||||
|
||||
value = convertPressure(
|
||||
value / this->pressureMultiplier,
|
||||
value / settings.opentherm.pressureMultiplier,
|
||||
settings.opentherm.unitSystem,
|
||||
settings.system.unitSystem
|
||||
);
|
||||
|
||||
if (settings.opentherm.filteringNumValues && fabs(vars.sensors.pressure) >= 0.1f) {
|
||||
vars.sensors.pressure += (value - vars.sensors.pressure) * EXT_SENSORS_FILTER_K;
|
||||
vars.sensors.pressure += (value - vars.sensors.pressure) * OT_NUM_VALUES_FILTER_K;
|
||||
|
||||
} else {
|
||||
vars.sensors.pressure = value;
|
||||
|
||||
@@ -54,6 +54,8 @@ struct Settings {
|
||||
byte faultStateGpio = DEFAULT_OT_FAULT_STATE_GPIO;
|
||||
byte invertFaultState = false;
|
||||
unsigned int memberIdCode = 0;
|
||||
int8_t pressureMultiplier = 1;
|
||||
int8_t dhwFlowRateMultiplier = 1;
|
||||
bool dhwPresent = true;
|
||||
bool summerWinterMode = false;
|
||||
bool heatingCh2Enabled = true;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#define EXT_SENSORS_INTERVAL 5000
|
||||
#define EXT_SENSORS_FILTER_K 0.15
|
||||
#define OT_NUM_VALUES_FILTER_K 0.1
|
||||
|
||||
#define CONFIG_URL "http://%s/"
|
||||
#define SETTINGS_VALID_VALUE "stvalid" // only 8 chars!
|
||||
|
||||
20
src/utils.h
20
src/utils.h
@@ -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"]["pressureMultiplier"] = roundd(src.opentherm.pressureMultiplier, 2);
|
||||
dst["opentherm"]["dhwFlowRateMultiplier"] = roundd(src.opentherm.dhwFlowRateMultiplier, 2);
|
||||
dst["opentherm"]["dhwPresent"] = src.opentherm.dhwPresent;
|
||||
dst["opentherm"]["summerWinterMode"] = src.opentherm.summerWinterMode;
|
||||
dst["opentherm"]["heatingCh2Enabled"] = src.opentherm.heatingCh2Enabled;
|
||||
@@ -695,6 +697,24 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!src["opentherm"]["pressureMultiplier"].isNull()) {
|
||||
float value = src["opentherm"]["pressureMultiplier"].as<float>();
|
||||
|
||||
if (value > 0 && value <= 100 && fabs(value - dst.opentherm.pressureMultiplier) > 0.0001f) {
|
||||
dst.opentherm.pressureMultiplier = roundd(value, 2);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src["opentherm"]["dhwFlowRateMultiplier"].isNull()) {
|
||||
float value = src["opentherm"]["dhwFlowRateMultiplier"].as<float>();
|
||||
|
||||
if (value > 0 && value <= 100 && fabs(value - dst.opentherm.dhwFlowRateMultiplier) > 0.0001f) {
|
||||
dst.opentherm.dhwFlowRateMultiplier = roundd(value, 2);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (src["opentherm"]["dhwPresent"].is<bool>()) {
|
||||
bool value = src["opentherm"]["dhwPresent"].as<bool>();
|
||||
|
||||
|
||||
@@ -261,6 +261,14 @@
|
||||
"outGpio": "Out GPIO",
|
||||
"ledGpio": "RX LED GPIO",
|
||||
"memberIdCode": "Master MemberID code",
|
||||
"pressureMultiplier": {
|
||||
"title": "Coeff. pressure correction",
|
||||
"note": "If the pressure displayed is <b>X10</b> from the real one, set the <b>10</b>."
|
||||
},
|
||||
"dhwFlowRateMultiplier": {
|
||||
"title": "Coeff. DHW flow rate correction",
|
||||
"note": "If the DHW flow rate displayed is <b>X10</b> from the real one, set the <b>10</b>."
|
||||
},
|
||||
|
||||
"options": {
|
||||
"dhwPresent": "DHW present",
|
||||
|
||||
@@ -261,6 +261,14 @@
|
||||
"outGpio": "Выход GPIO",
|
||||
"ledGpio": "RX LED GPIO",
|
||||
"memberIdCode": "Master MemberID код",
|
||||
"pressureMultiplier": {
|
||||
"title": "Коэфф. коррекции давления",
|
||||
"note": "Если давление отображается <b>Х10</b> от реального, установите значение <b>10</b>."
|
||||
},
|
||||
"dhwFlowRateMultiplier": {
|
||||
"title": "Коэфф. коррекции потока ГВС",
|
||||
"note": "Если поток ГВС отображается <b>Х10</b> от реального, установите значение <b>10</b>."
|
||||
},
|
||||
|
||||
"options": {
|
||||
"dhwPresent": "Контур ГВС",
|
||||
|
||||
@@ -401,6 +401,20 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label for="opentherm-pressure-multiplier">
|
||||
<span data-i18n>settings.ot.pressureMultiplier.title</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-pressure-multiplier" name="opentherm[pressureMultiplier]" min="0.1" max="100" step="0.01">
|
||||
<small data-i18n>settings.ot.pressureMultiplier.note</small>
|
||||
</label>
|
||||
|
||||
<label for="opentherm-dhw-fr-multiplier">
|
||||
<span data-i18n>settings.ot.dhwFlowRateMultiplier.title</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-dhw-fr-multiplier" name="opentherm[dhwFlowRateMultiplier]" min="0.1" max="100" step="0.01">
|
||||
<small data-i18n>settings.ot.dhwFlowRateMultiplier.note</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<legend data-i18n>settings.section.ot.options</legend>
|
||||
<label for="opentherm-dhw-present">
|
||||
@@ -737,6 +751,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-multiplier', data.opentherm.pressureMultiplier);
|
||||
setInputValue('#opentherm-dhw-fr-multiplier', data.opentherm.dhwFlowRateMultiplier);
|
||||
setCheckboxValue('#opentherm-dhw-present', data.opentherm.dhwPresent);
|
||||
setCheckboxValue('#opentherm-sw-mode', data.opentherm.summerWinterMode);
|
||||
setCheckboxValue('#opentherm-heating-ch2-enabled', data.opentherm.heatingCh2Enabled);
|
||||
|
||||
Reference in New Issue
Block a user