feat: added correction coeff. settings for pressure and dhw flow rate

This commit is contained in:
Yurii
2024-10-11 01:29:50 +03:00
parent 3c69f1295e
commit b0a9460257
7 changed files with 68 additions and 17 deletions

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();
}
@@ -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;

View File

@@ -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;

View File

@@ -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!

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"]["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>();