mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
refactor: cosmetic changes; move maxModulation setting to opentherm section
This commit is contained in:
@@ -266,30 +266,6 @@ public:
|
||||
return this->publish(this->getTopic(FPSTR(HA_ENTITY_NUMBER), F("heating_max_temp")).c_str(), doc);
|
||||
}
|
||||
|
||||
bool publishNumberHeatingMaxModulation(bool enabledByDefault = true) {
|
||||
JsonDocument doc;
|
||||
doc[FPSTR(HA_ENABLED_BY_DEFAULT)] = enabledByDefault;
|
||||
doc[FPSTR(HA_UNIQUE_ID)] = this->getObjectId(F("heating_max_modulation"));
|
||||
doc[FPSTR(HA_OBJECT_ID)] = this->getObjectId(F("heating_max_modulation"));
|
||||
doc[FPSTR(HA_ENTITY_CATEGORY)] = F("config");
|
||||
doc[FPSTR(HA_DEVICE_CLASS)] = F("power_factor");
|
||||
doc[FPSTR(HA_UNIT_OF_MEASUREMENT)] = F("%");
|
||||
doc[FPSTR(HA_NAME)] = F("Max modulation");
|
||||
doc[FPSTR(HA_ICON)] = F("mdi:speedometer");
|
||||
doc[FPSTR(HA_STATE_TOPIC)] = this->getDeviceTopic(F("settings"));
|
||||
doc[FPSTR(HA_VALUE_TEMPLATE)] = F("{{ value_json.heating.maxModulation|int(1) }}");
|
||||
doc[FPSTR(HA_COMMAND_TOPIC)] = this->getDeviceTopic(F("settings/set"));
|
||||
doc[FPSTR(HA_COMMAND_TEMPLATE)] = F("{\"heating\": {\"maxModulation\" : {{ value }}}}");
|
||||
doc[FPSTR(HA_MIN)] = 1;
|
||||
doc[FPSTR(HA_MAX)] = 100;
|
||||
doc[FPSTR(HA_STEP)] = 1;
|
||||
doc[FPSTR(HA_MODE)] = "box";
|
||||
doc[FPSTR(HA_EXPIRE_AFTER)] = 120;
|
||||
doc.shrinkToFit();
|
||||
|
||||
return this->publish(this->getTopic(FPSTR(HA_ENTITY_NUMBER), F("heating_max_modulation")).c_str(), doc);
|
||||
}
|
||||
|
||||
|
||||
bool publishSwitchDhw(bool enabledByDefault = true) {
|
||||
JsonDocument doc;
|
||||
|
||||
@@ -329,7 +329,6 @@ protected:
|
||||
this->haHelper->publishSensorBoilerHeatingMaxTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishNumberHeatingMinTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishNumberHeatingMaxTemp(settings.system.unitSystem, false);
|
||||
this->haHelper->publishNumberHeatingMaxModulation(false);
|
||||
|
||||
// pid
|
||||
this->haHelper->publishSwitchPid();
|
||||
|
||||
@@ -271,10 +271,10 @@ protected:
|
||||
vars.parameters.maxPower
|
||||
);
|
||||
|
||||
if (settings.heating.maxModulation < vars.parameters.minModulation) {
|
||||
settings.heating.maxModulation = vars.parameters.minModulation;
|
||||
if (settings.opentherm.maxModulation < vars.parameters.minModulation) {
|
||||
settings.opentherm.maxModulation = vars.parameters.minModulation;
|
||||
fsSettings.update();
|
||||
Log.swarningln(FPSTR(L_SETTINGS_OT), F("Updated min modulation: %hhu%%"), settings.heating.maxModulation);
|
||||
Log.swarningln(FPSTR(L_SETTINGS_OT), F("Updated min modulation: %hhu%%"), settings.opentherm.maxModulation);
|
||||
}
|
||||
|
||||
if (fabsf(settings.opentherm.maxPower) < 0.1f && vars.parameters.maxPower > 0) {
|
||||
@@ -289,18 +289,18 @@ protected:
|
||||
|
||||
if (!heatingEnabled && settings.opentherm.modulationSyncWithHeating) {
|
||||
if (this->setMaxModulationLevel(0)) {
|
||||
Log.snoticeln(FPSTR(L_OT_HEATING), F("Set max modulation: 0% (off)"));
|
||||
Log.snoticeln(FPSTR(L_OT), F("Set max modulation: 0% (off)"));
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT_HEATING), F("Failed set max modulation: 0% (off)"));
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed set max modulation: 0% (off)"));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this->setMaxModulationLevel(settings.heating.maxModulation)) {
|
||||
Log.snoticeln(FPSTR(L_OT_HEATING), F("Set max modulation: %hhu%%"), settings.heating.maxModulation);
|
||||
if (this->setMaxModulationLevel(settings.opentherm.maxModulation)) {
|
||||
Log.snoticeln(FPSTR(L_OT), F("Set max modulation: %hhu%%"), settings.opentherm.maxModulation);
|
||||
|
||||
} else {
|
||||
Log.swarningln(FPSTR(L_OT_HEATING), F("Failed set max modulation: %hhu%%"), settings.heating.maxModulation);
|
||||
Log.swarningln(FPSTR(L_OT), F("Failed set max modulation: %hhu%%"), settings.opentherm.maxModulation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ struct Settings {
|
||||
byte faultStateGpio = DEFAULT_OT_FAULT_STATE_GPIO;
|
||||
byte invertFaultState = false;
|
||||
unsigned int memberIdCode = 0;
|
||||
uint8_t maxModulation = 100;
|
||||
float pressureFactor = 1.0f;
|
||||
float dhwFlowRateFactor = 1.0f;
|
||||
float minPower = 0.0f;
|
||||
@@ -105,7 +106,6 @@ struct Settings {
|
||||
float hysteresis = 0.5f;
|
||||
byte minTemp = DEFAULT_HEATING_MIN_TEMP;
|
||||
byte maxTemp = DEFAULT_HEATING_MAX_TEMP;
|
||||
byte maxModulation = 100;
|
||||
} heating;
|
||||
|
||||
struct {
|
||||
|
||||
20
src/utils.h
20
src/utils.h
@@ -345,6 +345,7 @@ 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"]["maxModulation"] = src.opentherm.maxModulation;
|
||||
dst["opentherm"]["pressureFactor"] = roundd(src.opentherm.pressureFactor, 2);
|
||||
dst["opentherm"]["dhwFlowRateFactor"] = roundd(src.opentherm.dhwFlowRateFactor, 2);
|
||||
dst["opentherm"]["minPower"] = roundd(src.opentherm.minPower, 2);
|
||||
@@ -388,7 +389,6 @@ void settingsToJson(const Settings& src, JsonVariant dst, bool safe = false) {
|
||||
dst["heating"]["hysteresis"] = roundd(src.heating.hysteresis, 2);
|
||||
dst["heating"]["minTemp"] = src.heating.minTemp;
|
||||
dst["heating"]["maxTemp"] = src.heating.maxTemp;
|
||||
dst["heating"]["maxModulation"] = src.heating.maxModulation;
|
||||
|
||||
dst["dhw"]["enable"] = src.dhw.enable;
|
||||
dst["dhw"]["target"] = roundd(src.dhw.target, 1);
|
||||
@@ -700,6 +700,15 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!src["opentherm"]["maxModulation"].isNull()) {
|
||||
unsigned char value = src["opentherm"]["maxModulation"].as<unsigned char>();
|
||||
|
||||
if (value > 0 && value <= 100 && value != dst.opentherm.maxModulation) {
|
||||
dst.opentherm.maxModulation = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!src["opentherm"]["pressureFactor"].isNull()) {
|
||||
float value = src["opentherm"]["pressureFactor"].as<float>();
|
||||
|
||||
@@ -1205,15 +1214,6 @@ bool jsonToSettings(const JsonVariantConst src, Settings& dst, bool safe = false
|
||||
}
|
||||
}
|
||||
|
||||
if (!src["heating"]["maxModulation"].isNull()) {
|
||||
unsigned char value = src["heating"]["maxModulation"].as<unsigned char>();
|
||||
|
||||
if (value > 0 && value <= 100 && value != dst.heating.maxModulation) {
|
||||
dst.heating.maxModulation = value;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// dhw
|
||||
if (src["dhw"]["enable"].is<bool>()) {
|
||||
|
||||
@@ -213,8 +213,7 @@
|
||||
},
|
||||
|
||||
"heating": {
|
||||
"hyst": "Hysteresis <small>(in degrees)</small>",
|
||||
"maxMod": "Max modulation level"
|
||||
"hyst": "Hysteresis <small>(in degrees)</small>"
|
||||
},
|
||||
|
||||
"emergency": {
|
||||
@@ -256,10 +255,12 @@
|
||||
},
|
||||
|
||||
"ot": {
|
||||
"advanced": "Advanced Settings",
|
||||
"inGpio": "In GPIO",
|
||||
"outGpio": "Out GPIO",
|
||||
"ledGpio": "RX LED GPIO",
|
||||
"memberIdCode": "Master MemberID code",
|
||||
"maxMod": "Max modulation level",
|
||||
"pressureFactor": {
|
||||
"title": "Coeff. pressure correction",
|
||||
"note": "If the pressure displayed is <b>X10</b> from the real one, set the <b>0.1</b>."
|
||||
|
||||
@@ -213,8 +213,7 @@
|
||||
},
|
||||
|
||||
"heating": {
|
||||
"hyst": "Гистерезис <small>(в градусах)</small>",
|
||||
"maxMod": "Макс. уровень модуляции"
|
||||
"hyst": "Гистерезис <small>(в градусах)</small>"
|
||||
},
|
||||
|
||||
"emergency": {
|
||||
@@ -256,10 +255,12 @@
|
||||
},
|
||||
|
||||
"ot": {
|
||||
"advanced": "Дополнительные настройки",
|
||||
"inGpio": "Вход GPIO",
|
||||
"outGpio": "Выход GPIO",
|
||||
"ledGpio": "RX LED GPIO",
|
||||
"memberIdCode": "Master MemberID код",
|
||||
"maxMod": "Макс. уровень модуляции",
|
||||
"pressureFactor": {
|
||||
"title": "Коэфф. коррекции давления",
|
||||
"note": "Если давление отображается <b>Х10</b> от реального, установите значение <b>0.1</b>."
|
||||
@@ -269,11 +270,11 @@
|
||||
"note": "Если поток ГВС отображается <b>Х10</b> от реального, установите значение <b>0.1</b>."
|
||||
},
|
||||
"minPower": {
|
||||
"title": "Мин. мощность котла <small>(кВ)</small>",
|
||||
"title": "Мин. мощность котла <small>(кВт)</small>",
|
||||
"note": "Это значение соответствует уровню модуляции котла 0–1%. Обычно можно найти в спецификации котла как \"минимальная полезная тепловая мощность\"."
|
||||
},
|
||||
"maxPower": {
|
||||
"title": "Макс. мощность котла <small>(кВ)</small>",
|
||||
"title": "Макс. мощность котла <small>(кВт)</small>",
|
||||
"note": "<b>0</b> - попробовать определить автоматически. Обычно можно найти в спецификации котла как \"максимальная полезная тепловая мощность\"."
|
||||
},
|
||||
"fnv": {
|
||||
|
||||
@@ -166,17 +166,10 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label for="heating-hysteresis">
|
||||
<span data-i18n>settings.heating.hyst</span>
|
||||
<input type="number" inputmode="numeric" id="heating-hysteresis" name="heating[hysteresis]" min="0" max="5" step="0.05" required>
|
||||
</label>
|
||||
|
||||
<label for="heating-max-modulation">
|
||||
<span data-i18n>settings.heating.maxMod</span>
|
||||
<input type="number" inputmode="numeric" id="heating-max-modulation" name="heating[maxModulation]" min="1" max="100" step="1" required>
|
||||
</label>
|
||||
</div>
|
||||
<label for="heating-hysteresis">
|
||||
<span data-i18n>settings.heating.hyst</span>
|
||||
<input type="number" inputmode="numeric" id="heating-hysteresis" name="heating[hysteresis]" min="0" max="5" step="0.05" required>
|
||||
</label>
|
||||
|
||||
<button type="submit" data-i18n>button.save</button>
|
||||
</form>
|
||||
@@ -401,32 +394,23 @@
|
||||
<span data-i18n>settings.ot.outGpio</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-out-gpio" name="opentherm[outGpio]" min="0" max="254" step="1">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label for="opentherm-rx-led-gpio">
|
||||
<span data-i18n>settings.ot.ledGpio</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-rx-led-gpio" name="opentherm[rxLedGpio]" min="0" max="254" step="1">
|
||||
<small data-i18n>settings.note.blankNotUse</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
<label for="opentherm-member-id-code">
|
||||
<span data-i18n>settings.ot.memberIdCode</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-member-id-code" name="opentherm[memberIdCode]" min="0" max="65535" step="1" required>
|
||||
</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 for="opentherm-max-modulation">
|
||||
<span data-i18n>settings.ot.maxMod</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-max-modulation" name="opentherm[maxModulation]" min="1" max="100" step="1" required>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -491,40 +475,6 @@
|
||||
<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">
|
||||
<span data-i18n>settings.ot.faultState.gpio</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-fault-state-gpio" name="opentherm[faultStateGpio]" min="0" max="254" step="1">
|
||||
<small data-i18n>settings.ot.faultState.note</small>
|
||||
</label>
|
||||
|
||||
<label for="opentherm-invert-fault-state">
|
||||
<input type="checkbox" id="opentherm-invert-fault-state" name="opentherm[invertFaultState]" value="true">
|
||||
<span data-i18n>settings.ot.faultState.invert</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<hr />
|
||||
<label for="opentherm-native-heating-control">
|
||||
<input type="checkbox" id="opentherm-native-heating-control" name="opentherm[nativeHeatingControl]" value="true">
|
||||
@@ -532,6 +482,60 @@
|
||||
<small data-i18n>settings.ot.nativeHeating.note</small>
|
||||
</label>
|
||||
</fieldset>
|
||||
<hr />
|
||||
|
||||
<details>
|
||||
<summary role="button" class="secondary" data-i18n>settings.ot.advanced</summary>
|
||||
<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>
|
||||
<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">
|
||||
<span data-i18n>settings.ot.faultState.gpio</span>
|
||||
<input type="number" inputmode="numeric" id="opentherm-fault-state-gpio" name="opentherm[faultStateGpio]" min="0" max="254" step="1">
|
||||
<small data-i18n>settings.ot.faultState.note</small>
|
||||
</label>
|
||||
|
||||
<label for="opentherm-invert-fault-state">
|
||||
<input type="checkbox" id="opentherm-invert-fault-state" name="opentherm[invertFaultState]" value="true">
|
||||
<span data-i18n>settings.ot.faultState.invert</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<button type="submit" data-i18n>button.save</button>
|
||||
</form>
|
||||
@@ -795,6 +799,7 @@
|
||||
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-max-modulation', data.opentherm.maxModulation);
|
||||
setInputValue('#opentherm-pressure-factor', data.opentherm.pressureFactor);
|
||||
setInputValue('#opentherm-dhw-fr-factor', data.opentherm.dhwFlowRateFactor);
|
||||
setInputValue('#opentherm-min-power', data.opentherm.minPower);
|
||||
@@ -856,7 +861,6 @@
|
||||
"max": data.system.unitSystem == 0 ? 100 : 212
|
||||
});
|
||||
setInputValue('#heating-hysteresis', data.heating.hysteresis);
|
||||
setInputValue('#heating-max-modulation', data.heating.maxModulation);
|
||||
setBusy('#heating-settings-busy', '#heating-settings', false);
|
||||
|
||||
// DHW
|
||||
|
||||
Reference in New Issue
Block a user