mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
refactor: reworked the setting of the maximum modulation level, added the parameter of the maximum modulation level for DHW
This commit is contained in:
@@ -342,13 +342,23 @@ protected:
|
||||
vars.slave.modulation.min, vars.slave.power.max
|
||||
);
|
||||
|
||||
if (settings.opentherm.maxModulation < vars.slave.modulation.min) {
|
||||
settings.opentherm.maxModulation = vars.slave.modulation.min;
|
||||
if (settings.heating.maxModulation < vars.slave.modulation.min) {
|
||||
settings.heating.maxModulation = vars.slave.modulation.min;
|
||||
fsSettings.update();
|
||||
|
||||
Log.swarningln(
|
||||
FPSTR(L_SETTINGS_OT), F("Updated min modulation: %hhu%%"),
|
||||
settings.opentherm.maxModulation
|
||||
FPSTR(L_SETTINGS_HEATING), F("Updated min modulation: %hhu%%"),
|
||||
settings.heating.maxModulation
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.dhw.maxModulation < vars.slave.modulation.min) {
|
||||
settings.dhw.maxModulation = vars.slave.modulation.min;
|
||||
fsSettings.update();
|
||||
|
||||
Log.swarningln(
|
||||
FPSTR(L_SETTINGS_DHW), F("Updated min modulation: %hhu%%"),
|
||||
settings.dhw.maxModulation
|
||||
);
|
||||
}
|
||||
|
||||
@@ -367,29 +377,6 @@ protected:
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed receive min modulation and max power"));
|
||||
}
|
||||
|
||||
if (!vars.master.heating.enabled && settings.opentherm.options.modulationSyncWithHeating) {
|
||||
if (this->setMaxModulationLevel(0)) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Set max modulation: 0% (response: %hhu%%)"), vars.slave.modulation.max);
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed set max modulation: 0% (response: %hhu%%)"), vars.slave.modulation.max);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this->setMaxModulationLevel(settings.opentherm.maxModulation)) {
|
||||
Log.snoticeln(
|
||||
FPSTR(L_OT), F("Set max modulation: %hhu%% (response: %hhu%%)"),
|
||||
settings.opentherm.maxModulation, vars.slave.modulation.max
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(
|
||||
FPSTR(L_OT), F("Failed set max modulation: %hhu%% (response: %hhu%%)"),
|
||||
settings.opentherm.maxModulation, vars.slave.modulation.max
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get DHW min/max temp (if necessary)
|
||||
if (settings.opentherm.options.dhwSupport && settings.opentherm.options.getMinMaxTemp) {
|
||||
@@ -517,6 +504,29 @@ protected:
|
||||
this->prevUpdateNonEssentialVars = millis();
|
||||
}
|
||||
|
||||
// Set max modulation level
|
||||
uint8_t targetMaxModulation = vars.slave.modulation.max;
|
||||
if (vars.slave.heating.active) {
|
||||
targetMaxModulation = settings.heating.maxModulation;
|
||||
|
||||
} else if (vars.slave.dhw.active) {
|
||||
targetMaxModulation = settings.dhw.maxModulation;
|
||||
}
|
||||
|
||||
if (vars.slave.modulation.max != targetMaxModulation) {
|
||||
if (this->setMaxModulationLevel(targetMaxModulation)) {
|
||||
Log.snoticeln(
|
||||
FPSTR(L_OT), F("Set max modulation: %hhu%% (response: %hhu%%)"),
|
||||
targetMaxModulation, vars.slave.modulation.max
|
||||
);
|
||||
|
||||
} else {
|
||||
Log.swarningln(
|
||||
FPSTR(L_OT), F("Failed set max modulation: %hhu%% (response: %hhu%%)"),
|
||||
targetMaxModulation, vars.slave.modulation.max
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Update modulation level
|
||||
if (
|
||||
|
||||
@@ -59,7 +59,6 @@ struct Settings {
|
||||
byte rxLedGpio = DEFAULT_OT_RX_LED_GPIO;
|
||||
uint8_t memberId = 0;
|
||||
uint8_t flags = 0;
|
||||
uint8_t maxModulation = 100;
|
||||
float minPower = 0.0f;
|
||||
float maxPower = 0.0f;
|
||||
|
||||
@@ -72,7 +71,6 @@ struct Settings {
|
||||
bool heatingToCh2 = false;
|
||||
bool dhwToCh2 = false;
|
||||
bool dhwBlocking = false;
|
||||
bool modulationSyncWithHeating = false;
|
||||
bool maxTempSyncWithTargetTemp = true;
|
||||
bool getMinMaxTemp = true;
|
||||
bool nativeHeatingControl = false;
|
||||
@@ -104,6 +102,7 @@ struct Settings {
|
||||
float turboFactor = 7.5f;
|
||||
byte minTemp = DEFAULT_HEATING_MIN_TEMP;
|
||||
byte maxTemp = DEFAULT_HEATING_MAX_TEMP;
|
||||
uint8_t maxModulation = 100;
|
||||
} heating;
|
||||
|
||||
struct {
|
||||
@@ -111,6 +110,7 @@ struct Settings {
|
||||
float target = DEFAULT_DHW_TARGET_TEMP;
|
||||
byte minTemp = DEFAULT_DHW_MIN_TEMP;
|
||||
byte maxTemp = DEFAULT_DHW_MAX_TEMP;
|
||||
uint8_t maxModulation = 100;
|
||||
} dhw;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -131,7 +131,6 @@ const char S_MIN_POWER[] PROGMEM = "minPower";
|
||||
const char S_MIN_TEMP[] PROGMEM = "minTemp";
|
||||
const char S_MODEL[] PROGMEM = "model";
|
||||
const char S_MODULATION[] PROGMEM = "modulation";
|
||||
const char S_MODULATION_SYNC_WITH_HEATING[] PROGMEM = "modulationSyncWithHeating";
|
||||
const char S_MQTT[] PROGMEM = "mqtt";
|
||||
const char S_NAME[] PROGMEM = "name";
|
||||
const char S_NATIVE_HEATING_CONTROL[] PROGMEM = "nativeHeatingControl";
|
||||
|
||||
41
src/utils.h
41
src/utils.h
@@ -449,7 +449,6 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
opentherm[FPSTR(S_RX_LED_GPIO)] = src.opentherm.rxLedGpio;
|
||||
opentherm[FPSTR(S_MEMBER_ID)] = src.opentherm.memberId;
|
||||
opentherm[FPSTR(S_FLAGS)] = src.opentherm.flags;
|
||||
opentherm[FPSTR(S_MAX_MODULATION)] = src.opentherm.maxModulation;
|
||||
opentherm[FPSTR(S_MIN_POWER)] = roundf(src.opentherm.minPower, 2);
|
||||
opentherm[FPSTR(S_MAX_POWER)] = roundf(src.opentherm.maxPower, 2);
|
||||
|
||||
@@ -462,7 +461,6 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
otOptions[FPSTR(S_HEATING_TO_CH2)] = src.opentherm.options.heatingToCh2;
|
||||
otOptions[FPSTR(S_DHW_TO_CH2)] = src.opentherm.options.dhwToCh2;
|
||||
otOptions[FPSTR(S_DHW_BLOCKING)] = src.opentherm.options.dhwBlocking;
|
||||
otOptions[FPSTR(S_MODULATION_SYNC_WITH_HEATING)] = src.opentherm.options.modulationSyncWithHeating;
|
||||
otOptions[FPSTR(S_MAX_TEMP_SYNC_WITH_TARGET_TEMP)] = src.opentherm.options.maxTempSyncWithTargetTemp;
|
||||
otOptions[FPSTR(S_GET_MIN_MAX_TEMP)] = src.opentherm.options.getMinMaxTemp;
|
||||
otOptions[FPSTR(S_NATIVE_HEATING_CONTROL)] = src.opentherm.options.nativeHeatingControl;
|
||||
@@ -491,12 +489,14 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
heating[FPSTR(S_TURBO_FACTOR)] = roundf(src.heating.turboFactor, 3);
|
||||
heating[FPSTR(S_MIN_TEMP)] = src.heating.minTemp;
|
||||
heating[FPSTR(S_MAX_TEMP)] = src.heating.maxTemp;
|
||||
heating[FPSTR(S_MAX_MODULATION)] = src.heating.maxModulation;
|
||||
|
||||
auto dhw = dst[FPSTR(S_DHW)].to<JsonObject>();
|
||||
dhw[FPSTR(S_ENABLED)] = src.dhw.enabled;
|
||||
dhw[FPSTR(S_TARGET)] = roundf(src.dhw.target, 1);
|
||||
dhw[FPSTR(S_MIN_TEMP)] = src.dhw.minTemp;
|
||||
dhw[FPSTR(S_MAX_TEMP)] = src.dhw.maxTemp;
|
||||
dhw[FPSTR(S_MAX_MODULATION)] = src.dhw.maxModulation;
|
||||
|
||||
auto equitherm = dst[FPSTR(S_EQUITHERM)].to<JsonObject>();
|
||||
equitherm[FPSTR(S_ENABLED)] = src.equitherm.enabled;
|
||||
@@ -811,15 +811,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_OPENTHERM)][FPSTR(S_MAX_MODULATION)].isNull()) {
|
||||
unsigned char value = src[FPSTR(S_OPENTHERM)][FPSTR(S_MAX_MODULATION)].as<unsigned char>();
|
||||
|
||||
if (value > 0 && value <= 100 && value != dst.opentherm.maxModulation) {
|
||||
dst.opentherm.maxModulation = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_OPENTHERM)][FPSTR(S_MIN_POWER)].isNull()) {
|
||||
float value = src[FPSTR(S_OPENTHERM)][FPSTR(S_MIN_POWER)].as<float>();
|
||||
|
||||
@@ -928,15 +919,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_MODULATION_SYNC_WITH_HEATING)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_MODULATION_SYNC_WITH_HEATING)].as<bool>();
|
||||
|
||||
if (value != dst.opentherm.options.modulationSyncWithHeating) {
|
||||
dst.opentherm.options.modulationSyncWithHeating = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_MAX_TEMP_SYNC_WITH_TARGET_TEMP)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_OPENTHERM)][FPSTR(S_OPTIONS)][FPSTR(S_MAX_TEMP_SYNC_WITH_TARGET_TEMP)].as<bool>();
|
||||
|
||||
@@ -1301,6 +1283,16 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
|
||||
|
||||
if (!src[FPSTR(S_HEATING)][FPSTR(S_MAX_MODULATION)].isNull()) {
|
||||
unsigned char value = src[FPSTR(S_HEATING)][FPSTR(S_MAX_MODULATION)].as<unsigned char>();
|
||||
|
||||
if (value > 0 && value <= 100 && value != dst.heating.maxModulation) {
|
||||
dst.heating.maxModulation = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// dhw
|
||||
if (src[FPSTR(S_DHW)][FPSTR(S_ENABLED)].is<bool>()) {
|
||||
bool value = src[FPSTR(S_DHW)][FPSTR(S_ENABLED)].as<bool>();
|
||||
@@ -1334,6 +1326,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!src[FPSTR(S_DHW)][FPSTR(S_MAX_MODULATION)].isNull()) {
|
||||
unsigned char value = src[FPSTR(S_DHW)][FPSTR(S_MAX_MODULATION)].as<unsigned char>();
|
||||
|
||||
if (value > 0 && value <= 100 && value != dst.dhw.maxModulation) {
|
||||
dst.dhw.maxModulation = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!safe) {
|
||||
// external pump
|
||||
|
||||
Reference in New Issue
Block a user