diff --git a/src/OpenThermTask.h b/src/OpenThermTask.h index 788ad3a..df76f20 100644 --- a/src/OpenThermTask.h +++ b/src/OpenThermTask.h @@ -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; diff --git a/src/Settings.h b/src/Settings.h index caefec4..8787aaf 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -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; diff --git a/src/defines.h b/src/defines.h index 0c8d158..40f37a1 100644 --- a/src/defines.h +++ b/src/defines.h @@ -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! diff --git a/src/utils.h b/src/utils.h index b9e7466..9dee8f8 100644 --- a/src/utils.h +++ b/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(); + + 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(); + + 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 value = src["opentherm"]["dhwPresent"].as(); diff --git a/src_data/locales/en.json b/src_data/locales/en.json index 04405b0..0f754fe 100644 --- a/src_data/locales/en.json +++ b/src_data/locales/en.json @@ -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 X10 from the real one, set the 10." + }, + "dhwFlowRateMultiplier": { + "title": "Coeff. DHW flow rate correction", + "note": "If the DHW flow rate displayed is X10 from the real one, set the 10." + }, "options": { "dhwPresent": "DHW present", diff --git a/src_data/locales/ru.json b/src_data/locales/ru.json index 0884611..ba7a578 100644 --- a/src_data/locales/ru.json +++ b/src_data/locales/ru.json @@ -261,6 +261,14 @@ "outGpio": "Выход GPIO", "ledGpio": "RX LED GPIO", "memberIdCode": "Master MemberID код", + "pressureMultiplier": { + "title": "Коэфф. коррекции давления", + "note": "Если давление отображается Х10 от реального, установите значение 10." + }, + "dhwFlowRateMultiplier": { + "title": "Коэфф. коррекции потока ГВС", + "note": "Если поток ГВС отображается Х10 от реального, установите значение 10." + }, "options": { "dhwPresent": "Контур ГВС", diff --git a/src_data/pages/settings.html b/src_data/pages/settings.html index fdb7356..4cb1cd9 100644 --- a/src_data/pages/settings.html +++ b/src_data/pages/settings.html @@ -401,6 +401,20 @@ +
+ + + +
+
settings.section.ot.options