Files
OTGateway/src_data/pages/settings.html
T
Yurii d40b7cb85a feat: publish MQTT field changes with periodic refresh
Track 89 settings and state fields with partial structure snapshots and a
fixed-capacity map of publication timestamps. Publish changed or expired
values in bounded passes, updating snapshots only after successful queue
acceptance and keeping failed fields eligible for retry.

Refresh fields after reconnecting and affected temperatures after unit or
Equitherm mode changes. Keep the status heartbeat independent, cache DHW
limits for MQTT and API consumers, and clear non-finite retained readings.

Default the forced publication interval to 60 seconds and accept 15 to
3600 seconds in the API and UI. Set Home Assistant state expiration to
twice this interval and refresh discovery when the interval changes.

Remove network connection and dedicated fault/diagnostic availability
publications. Use existing active states and RSSI for HA availability.
2026-11-29 05:43:52 +03:00

1575 lines
67 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title data-i18n>settings.title</title>
<link rel="stylesheet" href="/static/app.css?{BUILD_TIME}" />
</head>
<body>
<header class="container">
<nav>
<ul>
<li>
<a href="/">
<div class="logo" data-i18n>logo</div>
</a>
</li>
</ul>
<ul>
<li>
<select id="lang" aria-label="Lang">
<option value="en" selected>EN</option>
<option value="cn">CN</option>
<option value="it">IT</option>
<option value="nl">NL</option>
<option value="ru">RU</option>
</select>
</li>
</ul>
</nav>
</header>
<main class="container">
<article>
<hgroup>
<h2 data-i18n>settings.name</h2>
<p></p>
</hgroup>
<details>
<summary><b data-i18n>settings.section.portal</b></summary>
<div>
<div id="portal-settings-busy" aria-busy="true"></div>
<form action="/api/settings/portal" id="portal-settings" data-section="portal" class="hidden">
<div class="grid">
<label>
<span data-i18n>settings.portal.login</span>
<input type="text" name="login" maxlength="12">
</label>
<label>
<span data-i18n>settings.portal.password</span>
<input type="password" name="password" maxlength="32">
</label>
</div>
<label>
<input type="checkbox" name="auth" value="true">
<span data-i18n>settings.portal.auth</span>
</label>
<label>
<input type="checkbox" name="mdns" value="true">
<span data-i18n>settings.portal.mdns</span>
</label>
<br />
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.system</b></summary>
<div>
<div id="system-settings-busy" aria-busy="true"></div>
<form action="/api/settings/system" id="system-settings" data-section="system" class="hidden">
<fieldset>
<legend data-i18n>settings.system.unit</legend>
<label>
<input type="radio" name="unit_system" value="0" />
<span data-i18n>settings.system.metric</span>
</label>
<label>
<input type="radio" name="unit_system" value="1" />
<span data-i18n>settings.system.imperial</span>
</label>
</fieldset>
<fieldset>
<label>
<span data-i18n>settings.system.ntp.server</span>
<input type="text" name="ntp[server]" maxlength="48">
</label>
<label>
<span data-i18n>settings.system.ntp.timezone</span>
<div role="group">
<input type="text" name="ntp[timezone]" maxlength="48">
<select class="presetTimezones">
<option disabled selected data-i18n>settings.system.ntp.timezonePresets</option>
</select>
</div>
</label>
</fieldset>
<fieldset>
<label>
<span data-i18n>settings.system.statusLedGpio</span>
<input type="number" inputmode="numeric" name="status_led_gpio" min="0" max="254" step="1">
<small data-i18n>settings.note.blankNotUse</small>
</label>
</fieldset>
<fieldset>
<legend data-i18n>settings.section.diag</legend>
<label>
<input type="checkbox" name="serial[enabled]" value="true">
<span data-i18n>settings.system.serial.enable</span>
</label>
<label>
<input type="checkbox" name="web_serial[enabled]" value="true">
<span data-i18n>settings.system.webSerial.enable</span>
</label>
<label>
<span data-i18n>settings.system.logLevel</span>
<select name="loglevel">
<option value="0">NONE</option>
<option value="1">ERROR</option>
<option value="2">WARN</option>
<option value="3">INFO</option>
<option value="4">DEBUG</option>
<option value="5">VERBOSE</option>
</select>
</label>
<div class="grid">
<label>
<span data-i18n>settings.system.serial.baud</span>
<select name="serial[baudrate]" required>
<option value="9600">9600</option>
<option value="19200">19200</option>
<option value="38400">38400</option>
<option value="57600">57600</option>
<option value="74880">74880</option>
<option value="115200">115200</option>
</select>
</label>
</div>
<mark data-i18n>settings.note.restart</mark>
</fieldset>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.heating</b></summary>
<div>
<div id="heating-settings-busy" aria-busy="true"></div>
<form action="/api/settings/heating" id="heating-settings" data-section="heating" class="hidden">
<div class="grid">
<label>
<span data-i18n>settings.temp.min</span>
<input type="number" inputmode="numeric" name="min_temp" min="0" max="0" step="0.1" required>
</label>
<label>
<span data-i18n>settings.temp.max</span>
<input type="number" inputmode="numeric" name="max_temp" min="0" max="0" step="0.1" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.heating.turboFactor</span>
<input type="number" inputmode="decimal" name="turbo_factor" min="1.5" max="10" step="0.1" required>
</label>
<label>
<span data-i18n>settings.maxModulation</span>
<input type="number" inputmode="numeric" name="max_modulation" min="1" max="100" step="1" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.heating.indoorTempAvgType.title</span>
<select name="indoor_temp_avg_type">
<option value="0" data-i18n>settings.avgType.mean</option>
<option value="1" data-i18n>settings.avgType.min</option>
<option value="2" data-i18n>settings.avgType.max</option>
</select>
<small data-i18n>settings.heating.indoorTempAvgType.desc</small>
</label>
<label>
<span data-i18n>settings.heating.outdoorTempAvgType.title</span>
<select name="outdoor_temp_avg_type">
<option value="0" data-i18n>settings.avgType.mean</option>
<option value="1" data-i18n>settings.avgType.min</option>
<option value="2" data-i18n>settings.avgType.max</option>
</select>
<small data-i18n>settings.heating.outdoorTempAvgType.desc</small>
</label>
</div>
<hr />
<details>
<summary><b data-i18n>settings.heating.hyst.title</b></summary>
<div>
<fieldset>
<label>
<input type="checkbox" name="hysteresis[enabled]" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.heating.hyst.value</span>
<input type="number" inputmode="decimal" name="hysteresis[value]" min="0" max="5" step="0.05" required>
</label>
</div>
</div>
<small data-i18n>settings.heating.hyst.desc</small>
</details>
<hr />
<details>
<summary><b data-i18n>settings.ohProtection.title</b></summary>
<div class="grid">
<label>
<span data-i18n>settings.ohProtection.highTemp.title</span>
<input type="number" inputmode="numeric" name="overheat_protection[high_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.ohProtection.highTemp.note</small>
</label>
<label>
<span data-i18n>settings.ohProtection.lowTemp.title</span>
<input type="number" inputmode="numeric" name="overheat_protection[low_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.ohProtection.lowTemp.note</small>
</label>
</div>
<small data-i18n>settings.ohProtection.desc</small>
</details>
<hr />
<details>
<summary><b data-i18n>settings.freezeProtection.title</b></summary>
<div class="grid">
<label>
<span data-i18n>settings.freezeProtection.highTemp.title</span>
<input type="number" inputmode="numeric" name="freeze_protection[high_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.freezeProtection.highTemp.note</small>
</label>
<label>
<span data-i18n>settings.freezeProtection.lowTemp.title</span>
<input type="number" inputmode="numeric" name="freeze_protection[low_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.freezeProtection.lowTemp.note</small>
</label>
</div>
<small data-i18n>settings.freezeProtection.desc</small>
</details>
<br />
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.dhw</b></summary>
<div>
<div id="dhw-settings-busy" aria-busy="true"></div>
<form action="/api/settings/dhw" id="dhw-settings" data-section="dhw" class="hidden">
<div class="grid">
<label>
<span data-i18n>settings.temp.min</span>
<input type="number" inputmode="numeric" name="min_temp" min="0" max="0" step="0.1" required>
</label>
<label>
<span data-i18n>settings.temp.max</span>
<input type="number" inputmode="numeric" name="max_temp" min="0" max="0" step="0.1" required>
</label>
</div>
<label>
<span data-i18n>settings.maxModulation</span>
<input type="number" inputmode="numeric" name="max_modulation" min="1" max="100" step="1" required>
</label>
<hr />
<details>
<summary><b data-i18n>settings.ohProtection.title</b></summary>
<div class="grid">
<label>
<span data-i18n>settings.ohProtection.highTemp.title</span>
<input type="number" inputmode="numeric" name="overheat_protection[high_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.ohProtection.highTemp.note</small>
</label>
<label>
<span data-i18n>settings.ohProtection.lowTemp.title</span>
<input type="number" inputmode="numeric" name="overheat_protection[low_temp]" min="0" max="0" step="0.1" required>
<small data-i18n>settings.ohProtection.lowTemp.note</small>
</label>
</div>
<small data-i18n>settings.ohProtection.desc</small>
</details>
<br />
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.emergency</b></summary>
<div>
<div id="emergency-settings-busy" aria-busy="true"></div>
<form action="/api/settings/emergency" id="emergency-settings" data-section="emergency" class="hidden">
<fieldset>
<small data-i18n>settings.emergency.desc</small>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.emergency.target.title</span>
<input type="number" inputmode="numeric" name="target" min="0" max="0" step="1" required>
<small data-i18n>settings.emergency.target.note</small>
</label>
<label>
<span data-i18n>settings.emergency.thresholdTime</span>
<input type="number" inputmode="numeric" name="threshold_time" min="60" max="1800" step="1" required>
</label>
</div>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.equitherm</b></summary>
<div>
<div id="equitherm-settings-busy" aria-busy="true"></div>
<form action="/api/settings/equitherm" id="equitherm-settings" data-section="equitherm" class="hidden">
<fieldset>
<label>
<input type="checkbox" name="enabled" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div>
<div>
<canvas id="etChart"></canvas>
</div>
<label>
<div>
<span data-i18n>settings.equitherm.chart.targetTemp</span>: <b class="etChartTargetTempValue"></b>°
</div>
<input class="etChartTargetTemp" type="range" value="0" min="0" max="0" step="0.5">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.equitherm.slope.title</span>
<input type="number" inputmode="decimal" name="slope" min="0.001" max="10" step="0.001" required>
<small data-i18n>settings.equitherm.slope.note</small>
</label>
<label>
<span data-i18n>settings.equitherm.exponent.title</span>
<input type="number" inputmode="decimal" name="exponent" min="0.1" max="2" step="0.001" required>
<small data-i18n>settings.equitherm.exponent.note</small>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.equitherm.shift.title</span>
<input type="number" inputmode="decimal" name="shift" min="-15" max="15" step="0.01" required>
<small data-i18n>settings.equitherm.shift.note</small>
</label>
<label>
<span data-i18n>settings.equitherm.targetDiffFactor.title</span>
<input type="number" inputmode="decimal" name="target_diff_factor" min="0" max="10" step="0.01" required>
<small data-i18n>settings.equitherm.targetDiffFactor.note</small>
</label>
</div>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.pid</b></summary>
<div>
<div id="pid-settings-busy" aria-busy="true"></div>
<form action="/api/settings/pid" id="pid-settings" data-section="pid" class="hidden">
<fieldset>
<label>
<input type="checkbox" name="enabled" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.pid.p</span>
<input type="number" inputmode="decimal" name="p_factor" min="0.1" max="1000" step="0.01" required>
</label>
<label>
<span data-i18n>settings.pid.i</span>
<input type="number" inputmode="decimal" name="i_factor" min="0" max="100" step="0.0001" required>
</label>
<label>
<span data-i18n>settings.pid.d</span>
<input type="number" inputmode="decimal" name="d_factor" min="0" max="100000" step="0.1" required>
</label>
</div>
<label>
<span data-i18n>settings.pid.dt</span>
<input type="number" inputmode="numeric" name="dt" min="30" max="1800" step="1" required>
</label>
<hr />
<details>
<summary><b data-i18n>settings.pid.limits.title</b></summary>
<div>
<div class="grid">
<label>
<span data-i18n>settings.temp.min</span>
<input type="number" inputmode="decimal" name="min_temp" min="0" max="0" step="0.1" required>
</label>
<label>
<span data-i18n>settings.temp.max</span>
<input type="number" inputmode="numeric" name="max_temp" min="0" max="0" step="0.1" required>
</label>
</div>
<small data-i18n>settings.pid.limits.note</small>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.pid.deadband.title</b></summary>
<div>
<fieldset>
<label>
<input type="checkbox" name="deadband[enabled]" value="true">
<span data-i18n>settings.enable</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.pid.deadband.p_multiplier</span>
<input type="number" inputmode="decimal" name="deadband[p_multiplier]" min="0" max="5" step="0.001" required>
</label>
<label>
<span data-i18n>settings.pid.deadband.i_multiplier</span>
<input type="number" inputmode="decimal" name="deadband[i_multiplier]" min="0" max="1" step="0.001" required>
</label>
<label>
<span data-i18n>settings.pid.deadband.d_multiplier</span>
<input type="number" inputmode="decimal" name="deadband[d_multiplier]" min="0" max="1" step="0.001" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.pid.deadband.thresholdHigh</span>
<input type="number" inputmode="decimal" name="deadband[threshold_high]" min="0" max="5" step="0.01" required>
</label>
<label>
<span data-i18n>settings.pid.deadband.thresholdLow</span>
<input type="number" inputmode="decimal" name="deadband[threshold_low]" min="0" max="5" step="0.01" required>
</label>
</div>
<small data-i18n>settings.pid.deadband.note</small>
</div>
</details>
<br />
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.ot</b></summary>
<div>
<div id="ot-settings-busy" aria-busy="true"></div>
<form action="/api/settings/opentherm" id="ot-settings" data-section="opentherm" class="hidden">
<div class="grid">
<label>
<span data-i18n>settings.ot.inGpio</span>
<input type="number" inputmode="numeric" name="in_gpio" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>settings.ot.outGpio</span>
<input type="number" inputmode="numeric" name="out_gpio" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>settings.ot.ledGpio</span>
<input type="number" inputmode="numeric" name="rx_led_gpio" min="0" max="254" step="1">
<small data-i18n>settings.note.blankNotUse</small>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.ot.memberId</span>
<input type="number" inputmode="numeric" name="member_id" min="0" max="255" step="1" required>
</label>
<label>
<span data-i18n>settings.ot.flags</span>
<input type="number" inputmode="numeric" name="flags" min="0" max="255" step="1" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.ot.minPower.title</span>
<input type="number" inputmode="decimal" name="min_power" min="0" max="1000" step="0.01">
<small data-i18n>settings.ot.minPower.note</small>
</label>
<label>
<span data-i18n>settings.ot.maxPower.title</span>
<input type="number" inputmode="decimal" name="max_power" min="0" max="1000" step="0.01">
<small data-i18n>settings.ot.maxPower.note</small>
</label>
</div>
<hr />
<details>
<summary><b data-i18n>settings.ot.disablingAction.title</b></summary>
<div>
<fieldset>
<small data-i18n>settings.ot.disablingAction.desc</small>
</fieldset>
<fieldset>
<legend><b data-i18n>settings.ot.disablingAction.heating</b></legend>
<label>
<input type="radio" name="heating_disabling_action" value="0" />
<span data-i18n>settings.ot.disablingAction.off</span>
</label>
<label>
<input type="radio" name="heating_disabling_action" value="1" />
<span data-i18n>settings.ot.disablingAction.zeroSetpoint</span>
</label>
<label>
<input type="radio" name="heating_disabling_action" value="2" />
<span data-i18n>settings.ot.disablingAction.offAndZeroSetpoint</span>
</label>
</fieldset>
<hr />
<fieldset>
<legend><b data-i18n>settings.ot.disablingAction.dhw</b></legend>
<label>
<input type="radio" name="dhw_disabling_action" value="0" />
<span data-i18n>settings.ot.disablingAction.off</span>
</label>
<label>
<input type="radio" name="dhw_disabling_action" value="1" />
<span data-i18n>settings.ot.disablingAction.zeroSetpoint</span>
</label>
<label>
<input type="radio" name="dhw_disabling_action" value="2" />
<span data-i18n>settings.ot.disablingAction.offAndZeroSetpoint</span>
</label>
</fieldset>
<hr />
<fieldset>
<legend><b data-i18n>settings.ot.disablingAction.ch2</b></legend>
<label>
<input type="radio" name="ch2_disabling_action" value="0" />
<span data-i18n>settings.ot.disablingAction.off</span>
</label>
<label>
<input type="radio" name="ch2_disabling_action" value="1" />
<span data-i18n>settings.ot.disablingAction.zeroSetpoint</span>
</label>
<label>
<input type="radio" name="ch2_disabling_action" value="2" />
<span data-i18n>settings.ot.disablingAction.offAndZeroSetpoint</span>
</label>
</fieldset>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.ot.options.title</b></summary>
<div>
<fieldset>
<small data-i18n>settings.ot.options.desc</small>
</fieldset>
<fieldset>
<label>
<input type="checkbox" name="options[dhw_support]" value="true">
<span data-i18n>settings.ot.options.dhwSupport</span>
</label>
<label>
<input type="checkbox" name="options[cooling_support]" value="true">
<span data-i18n>settings.ot.options.coolingSupport</span>
</label>
<label>
<input type="checkbox" name="options[summer_winter_mode]" value="true">
<span data-i18n>settings.ot.options.summerWinterMode</span>
</label>
<label>
<input type="checkbox" name="options[heating_state_to_summer_winter_mode]" value="true">
<span data-i18n>settings.ot.options.heatingStateToSummerWinterMode</span>
</label>
<label>
<input type="checkbox" name="options[ch2_always_enabled]" value="true">
<span data-i18n>settings.ot.options.ch2AlwaysEnabled</span>
</label>
<label>
<input type="checkbox" name="options[heating_to_ch2]" value="true">
<span data-i18n>settings.ot.options.heatingToCh2</span>
</label>
<label>
<input type="checkbox" name="options[dhw_to_ch2]" value="true">
<span data-i18n>settings.ot.options.dhwToCh2</span>
</label>
<label>
<input type="checkbox" name="options[dhw_blocking]" value="true">
<span data-i18n>settings.ot.options.dhwBlocking</span>
</label>
<label>
<input type="checkbox" name="options[dhw_state_as_dhw_blocking]" value="true">
<span data-i18n>settings.ot.options.dhwStateAsDhwBlocking</span>
</label>
<label>
<input type="checkbox" name="options[max_temp_sync_with_target_temp]" value="true">
<span data-i18n>settings.ot.options.maxTempSyncWithTargetTemp</span>
</label>
<label>
<input type="checkbox" name="options[get_min_max_temp]" value="true">
<span data-i18n>settings.ot.options.getMinMaxTemp</span>
</label>
<label>
<input type="checkbox" name="options[ignore_diag_state]" value="true">
<span data-i18n>settings.ot.options.ignoreDiagState</span>
</label>
<label>
<input type="checkbox" name="options[auto_fault_reset]" value="true">
<span data-i18n>settings.ot.options.autoFaultReset</span>
</label>
<label>
<input type="checkbox" name="options[auto_diag_reset]" value="true">
<span data-i18n>settings.ot.options.autoDiagReset</span>
</label>
<label>
<input type="checkbox" name="options[set_date_and_time]" value="true">
<span data-i18n>settings.ot.options.setDateAndTime</span>
</label>
<label>
<input type="checkbox" name="options[immergas_fix]" value="true">
<span data-i18n>settings.ot.options.immergasFix</span>
</label>
<label>
<input type="checkbox" name="options[always_send_indoor_temp]" value="true">
<span data-i18n>settings.ot.options.alwaysSendIndoorTemp</span>
</label>
<hr />
<label>
<input type="checkbox" name="options[native_otc]" value="true">
<span data-i18n>settings.ot.nativeOTC.title</span><br />
<small data-i18n>settings.ot.nativeOTC.note</small>
</label>
</fieldset>
</div>
</details>
<br />
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.mqtt</b></summary>
<div>
<div id="mqtt-settings-busy" aria-busy="true"></div>
<form action="/api/settings/mqtt" id="mqtt-settings" data-section="mqtt" class="hidden">
<fieldset>
<label>
<input type="checkbox" name="enabled" value="true">
<span data-i18n>settings.enable</span>
</label>
<label>
<input type="checkbox" name="ha_discovery" value="true">
<span data-i18n>settings.mqtt.homeAssistantDiscovery</span>
</label>
</fieldset>
<label>
<span data-i18n>settings.mqtt.homeAssistantDiscoveryPrefix</span>
<input type="text" name="ha_discovery_prefix" maxlength="32" pattern="[^+#]+" required>
</label>
<div class="grid">
<label>
<span data-i18n>settings.mqtt.server</span>
<input type="text" name="server" maxlength="80" required>
</label>
<label>
<span data-i18n>settings.mqtt.port</span>
<input type="number" inputmode="numeric" name="port" min="1" max="65535" step="1" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.mqtt.user</span>
<input type="text" name="user" maxlength="32">
</label>
<label>
<span data-i18n>settings.mqtt.password</span>
<input type="password" name="password" maxlength="32">
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.mqtt.prefix</span>
<input type="text" name="prefix" maxlength="32" required>
</label>
<label>
<span data-i18n>settings.mqtt.interval</span>
<input type="number" inputmode="numeric" name="interval" min="15" max="3600" step="1" required>
</label>
</div>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.extPump</b></summary>
<div>
<div id="extpump-settings-busy" aria-busy="true"></div>
<form action="/api/settings/ext_pump" id="extpump-settings" data-section="ext_pump" class="hidden">
<fieldset>
<label>
<input type="checkbox" name="use" value="true">
<span data-i18n>settings.extPump.use</span>
</label>
<label>
<input type="checkbox" name="invert_state" value="true">
<span data-i18n>settings.extPump.invertState</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.extPump.gpio</span>
<input type="number" inputmode="numeric" name="gpio" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>settings.extPump.postCirculationTime</span>
<input type="number" inputmode="numeric" name="post_circulation_time" min="1" max="120" step="1" required>
</label>
</div>
<div class="grid">
<label>
<span data-i18n>settings.extPump.antiStuckInterval</span>
<input type="number" inputmode="numeric" name="antistuck_interval" min="1" max="366" step="1" required>
</label>
<label>
<span data-i18n>settings.extPump.antiStuckTime</span>
<input type="number" inputmode="numeric" name="antistuck_time" min="1" max="20" step="1" required>
</label>
</div>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
<hr />
<details>
<summary><b data-i18n>settings.section.cascadeControl</b></summary>
<div>
<div id="cc-settings-busy" aria-busy="true"></div>
<form action="/api/settings/cascade_control" id="cc-settings" data-section="cascade_control" class="hidden">
<fieldset>
<label>
<input type="checkbox" name="input[enabled]" value="true">
<span data-i18n>settings.cascadeControl.input.enable</span>
<br />
<small data-i18n>settings.cascadeControl.input.desc</small>
</label>
<label>
<input type="checkbox" name="input[invert_state]" value="true">
<span data-i18n>settings.cascadeControl.input.invertState</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.cascadeControl.input.gpio</span>
<input type="number" inputmode="numeric" name="input[gpio]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>settings.cascadeControl.input.thresholdTime</span>
<input type="number" inputmode="numeric" name="input[threshold_time]" min="5" max="600" step="1" required>
</label>
</div>
<hr />
<fieldset>
<label>
<input type="checkbox" name="output[enabled]" value="true">
<span data-i18n>settings.cascadeControl.output.enable</span>
<br />
<small data-i18n>settings.cascadeControl.output.desc</small>
</label>
<label>
<input type="checkbox" name="output[invert_state]" value="true">
<span data-i18n>settings.cascadeControl.output.invertState</span>
</label>
</fieldset>
<div class="grid">
<label>
<span data-i18n>settings.cascadeControl.output.gpio</span>
<input type="number" inputmode="numeric" name="output[gpio]" min="0" max="254" step="1">
</label>
<label>
<span data-i18n>settings.cascadeControl.output.thresholdTime</span>
<input type="number" inputmode="numeric" name="output[threshold_time]" min="5" max="600" step="1" required>
</label>
</div>
<fieldset>
<legend data-i18n>settings.cascadeControl.output.events.desc</legend>
<label>
<input type="checkbox" name="output[on_fault]" value="true">
<span data-i18n>settings.cascadeControl.output.events.onFault</span>
</label>
<label>
<input type="checkbox" name="output[on_loss_connection]" value="true">
<span data-i18n>settings.cascadeControl.output.events.onLossConnection</span>
</label>
<label>
<input type="checkbox" name="output[on_enabled_heating]" value="true">
<span data-i18n>settings.cascadeControl.output.events.onEnabledHeating</span>
</label>
</fieldset>
<button type="submit" data-i18n>button.save</button>
</form>
</div>
</details>
</article>
</main>
<footer class="container">
<small>
<b>Made by Laxilef</b>
• <a href="https://github.com/Laxilef/OTGateway/blob/master/LICENSE" target="_blank" class="secondary" data-i18n>nav.license</a>
• <a href="https://github.com/Laxilef/OTGateway/blob/master/" target="_blank" class="secondary" data-i18n>nav.source</a>
• <a href="https://github.com/Laxilef/OTGateway/wiki" target="_blank" class="secondary" data-i18n>nav.help</a>
• <a href="https://github.com/Laxilef/OTGateway/issues" target="_blank" class="secondary" data-i18n>nav.issues</a>
• <a href="https://github.com/Laxilef/OTGateway/releases" target="_blank" class="secondary" data-i18n>nav.releases</a>
</small>
</footer>
<script src="/static/app.js?{BUILD_TIME}"></script>
<script src="/static/chart.js?{BUILD_TIME}"></script>
<script>
document.addEventListener('DOMContentLoaded', async () => {
const lang = new Lang(document.getElementById('lang'));
await lang.build();
let etChart = null;
let etChartConfig = {
slope: null,
exponent: null,
shift: null,
unitSystem: null,
targetTemp: null,
minTemp: null,
maxTemp: null,
decimated: false
};
const hasNeedDecimationChart = () => {
return window.innerWidth <= 800;
}
const makeEquithermChart = () => {
if (etChart == null) {
const ctx = document.getElementById('etChart').getContext('2d');
try {
etChart = new Chart(ctx, {
type: 'line',
data: {
datasets: [{
borderColor: (context) => {
const chart = context.chart;
const { ctx, chartArea } = chart;
if (!chartArea) {
return;
}
const gradient = ctx.createLinearGradient(0, chartArea.bottom, 0, chartArea.top);
gradient.addColorStop(0, 'rgba(1, 114, 173, 1)');
gradient.addColorStop(0.5, 'rgba(255, 99, 132, 1)');
return gradient;
},
borderWidth: 3,
fill: false,
tension: 0.1,
pointRadius: 2,
pointHoverRadius: 4,
indexAxis: "x",
data: []
}]
},
options: {
responsive: true,
resizeDelay: 500,
parsing: false,
interaction: {
mode: 'nearest',
intersect: false
},
plugins: {
tooltip: {
enabled: true,
position: 'nearest',
displayColors: false,
callbacks: {
title: (items) => {
return `${i18n("settings.equitherm.chart.outdoorTemp")}: ${items[0].label}`;
}
}
},
legend: {
display: false
}
},
scales: {
x: {
display: true,
type: "linear",
reverse: true,
title: {
display: true
},
ticks: {
stepSize: 1,
format: {
style: "unit",
unit: "degree",
unitDisplay: "narrow"
}
}
},
y: {
display: true,
title: {
display: true
},
ticks: {
format: {
style: "unit",
unit: "degree",
unitDisplay: "narrow"
}
}
}
}
}
});
} catch (error) {
console.log(error);
}
}
if (!etChart) {
return;
}
let data = [];
etChartConfig.decimated = hasNeedDecimationChart();
for (let value = 30; value >= -30; value -= etChartConfig.decimated ? 2 : 1) {
const outdoorTemp = etChartConfig.unitSystem == 0 ? value : c2f(value);
data.push({
x: parseFloat(outdoorTemp.toFixed(1)),
y: parseFloat((etChartConfig.unitSystem == 0
? calculateEquithermTemp(value)
: c2f(calculateEquithermTemp(value))).toFixed(1))
});
}
etChart.data.datasets[0].data = data;
etChart.data.datasets[0].label = i18n("settings.equitherm.chart.setpointTemp");
etChart.options.scales.x.title.text = i18n("settings.equitherm.chart.outdoorTemp");
etChart.options.scales.y.title.text = i18n("settings.equitherm.chart.setpointTemp");
etChart.update();
}
const calculateEquithermTemp = (outdoorTemp) => {
let result = etChartConfig.targetTemp + etChartConfig.shift;
if (etChartConfig.maxTemp > etChartConfig.targetTemp) {
const tempDelta = etChartConfig.targetTemp - outdoorTemp;
const maxPoint = etChartConfig.targetTemp - (
etChartConfig.maxTemp - etChartConfig.targetTemp
) / etChartConfig.slope;
const sf = (etChartConfig.maxTemp - etChartConfig.targetTemp) / Math.pow(
etChartConfig.targetTemp - maxPoint,
1 / etChartConfig.exponent
);
result = etChartConfig.targetTemp + etChartConfig.shift + sf * (
tempDelta >= 0
? Math.pow(tempDelta, 1 / etChartConfig.exponent)
: -(Math.pow(-(tempDelta), 1 / etChartConfig.exponent))
);
}
if (!Number.isFinite(result)) {
result = etChartConfig.targetTemp + etChartConfig.shift;
}
return Math.max(Math.min(result, etChartConfig.maxTemp), etChartConfig.minTemp);
}
const fillData = (form, data) => {
const section = form.dataset.section;
if (section === 'system') {
setSelectValue("[name='loglevel']", data.system.loglevel, form);
setCheckboxValue("[name='serial[enabled]']", data.system.serial.enabled, form);
setSelectValue("[name='serial[baudrate]']", data.system.serial.baudrate, form);
setCheckboxValue("[name='web_serial[enabled]']", data.system.web_serial.enabled, form);
setInputValue("[name='ntp[server]']", data.system.ntp.server, {}, form);
setInputValue("[name='ntp[timezone]']", data.system.ntp.timezone, {}, form);
setRadioValue("[name='unit_system']", data.system.unit_system, form);
setInputValue("[name='status_led_gpio']", data.system.status_led_gpio < 255 ? data.system.status_led_gpio : '', {}, form);
} else if (section === 'portal') {
setCheckboxValue("[name='auth']", data.portal.auth, form);
setInputValue("[name='login']", data.portal.login, {}, form);
setInputValue("[name='password']", data.portal.password, {}, form);
setCheckboxValue("[name='mdns']", data.portal.mdns, form);
} else if (section === 'opentherm') {
setInputValue("[name='in_gpio']", data.opentherm.in_gpio < 255 ? data.opentherm.in_gpio : '', {}, form);
setInputValue("[name='out_gpio']", data.opentherm.out_gpio < 255 ? data.opentherm.out_gpio : '', {}, form);
setInputValue("[name='rx_led_gpio']", data.opentherm.rx_led_gpio < 255 ? data.opentherm.rx_led_gpio : '', {}, form);
setInputValue("[name='member_id']", data.opentherm.member_id, {}, form);
setInputValue("[name='flags']", data.opentherm.flags, {}, form);
setInputValue("[name='min_power']", data.opentherm.min_power, {}, form);
setInputValue("[name='max_power']", data.opentherm.max_power, {}, form);
setRadioValue("[name='heating_disabling_action']", data.opentherm.heating_disabling_action, form);
setRadioValue("[name='dhw_disabling_action']", data.opentherm.dhw_disabling_action, form);
setRadioValue("[name='ch2_disabling_action']", data.opentherm.ch2_disabling_action, form);
setCheckboxValue("[name='options[dhw_support]']", data.opentherm.options.dhw_support, form);
setCheckboxValue("[name='options[cooling_support]']", data.opentherm.options.cooling_support, form);
setCheckboxValue("[name='options[summer_winter_mode]']", data.opentherm.options.summer_winter_mode, form);
setCheckboxValue("[name='options[heating_state_to_summer_winter_mode]']", data.opentherm.options.heating_state_to_summer_winter_mode, form);
setCheckboxValue("[name='options[ch2_always_enabled]']", data.opentherm.options.ch2_always_enabled, form);
setCheckboxValue("[name='options[heating_to_ch2]']", data.opentherm.options.heating_to_ch2, form);
setCheckboxValue("[name='options[dhw_to_ch2]']", data.opentherm.options.dhw_to_ch2, form);
setCheckboxValue("[name='options[dhw_blocking]']", data.opentherm.options.dhw_blocking, form);
setCheckboxValue("[name='options[dhw_state_as_dhw_blocking]']", data.opentherm.options.dhw_state_as_dhw_blocking, form);
setCheckboxValue("[name='options[max_temp_sync_with_target_temp]']", data.opentherm.options.max_temp_sync_with_target_temp, form);
setCheckboxValue("[name='options[get_min_max_temp]']", data.opentherm.options.get_min_max_temp, form);
setCheckboxValue("[name='options[ignore_diag_state]']", data.opentherm.options.ignore_diag_state, form);
setCheckboxValue("[name='options[auto_fault_reset]']", data.opentherm.options.auto_fault_reset, form);
setCheckboxValue("[name='options[auto_diag_reset]']", data.opentherm.options.auto_diag_reset, form);
setCheckboxValue("[name='options[set_date_and_time]']", data.opentherm.options.set_date_and_time, form);
setCheckboxValue("[name='options[native_otc]']", data.opentherm.options.native_otc, form);
setCheckboxValue("[name='options[immergas_fix]']", data.opentherm.options.immergas_fix, form);
setCheckboxValue("[name='options[always_send_indoor_temp]']", data.opentherm.options.always_send_indoor_temp, form);
} else if (section === 'mqtt') {
setCheckboxValue("[name='enabled']", data.mqtt.enabled, form);
setCheckboxValue("[name='ha_discovery']", data.mqtt.ha_discovery, form);
setInputValue("[name='ha_discovery_prefix']", data.mqtt.ha_discovery_prefix, {}, form);
setInputValue("[name='server']", data.mqtt.server, {}, form);
setInputValue("[name='port']", data.mqtt.port, {}, form);
setInputValue("[name='user']", data.mqtt.user, {}, form);
setInputValue("[name='password']", data.mqtt.password, {}, form);
setInputValue("[name='prefix']", data.mqtt.prefix, {}, form);
setInputValue("[name='interval']", data.mqtt.interval, {}, form);
} else if (section === 'ext_pump') {
setCheckboxValue("[name='use']", data.ext_pump.use, form);
setInputValue("[name='gpio']", data.ext_pump.gpio < 255 ? data.ext_pump.gpio : '', {}, form);
setCheckboxValue("[name='invert_state']", data.ext_pump.invert_state, form);
setInputValue("[name='post_circulation_time']", data.ext_pump.post_circulation_time, {}, form);
setInputValue("[name='antistuck_interval']", data.ext_pump.antistuck_interval, {}, form);
setInputValue("[name='antistuck_time']", data.ext_pump.antistuck_time, {}, form);
} else if (section === 'cascade_control') {
setCheckboxValue("[name='input[enabled]']", data.cascade_control.input.enabled, form);
setInputValue("[name='input[gpio]']", data.cascade_control.input.gpio < 255 ? data.cascade_control.input.gpio : '', {}, form);
setCheckboxValue("[name='input[invert_state]']", data.cascade_control.input.invert_state, form);
setInputValue("[name='input[threshold_time]']", data.cascade_control.input.threshold_time, {}, form);
setCheckboxValue("[name='output[enabled]']", data.cascade_control.output.enabled, form);
setInputValue("[name='output[gpio]']", data.cascade_control.output.gpio < 255 ? data.cascade_control.output.gpio : '', {}, form);
setCheckboxValue("[name='output[invert_state]']", data.cascade_control.output.invert_state, form);
setInputValue("[name='output[threshold_time]']", data.cascade_control.output.threshold_time, {}, form);
setCheckboxValue("[name='output[on_fault]']", data.cascade_control.output.on_fault, form);
setCheckboxValue("[name='output[on_loss_connection]']", data.cascade_control.output.on_loss_connection, form);
setCheckboxValue("[name='output[on_enabled_heating]']", data.cascade_control.output.on_enabled_heating, form);
} else if (section === 'heating') {
setInputValue("[name='min_temp']", Number(data.heating.min_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 0 : 32,
"max": data.system.unit_system == 0 ? 99 : 211
}, form);
setInputValue("[name='max_temp']", Number(data.heating.max_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 1 : 33.8,
"max": data.system.unit_system == 0 ? 100 : 212
}, form);
setCheckboxValue("[name='hysteresis[enabled]']", data.heating.hysteresis.enabled, form);
setInputValue("[name='hysteresis[value]']", data.heating.hysteresis.value, {}, form);
setInputValue("[name='turbo_factor']", data.heating.turbo_factor, {}, form);
setInputValue("[name='max_modulation']", data.heating.max_modulation, {}, form);
setSelectValue("[name='indoor_temp_avg_type']", data.heating.indoor_temp_avg_type, form);
setSelectValue("[name='outdoor_temp_avg_type']", data.heating.outdoor_temp_avg_type, form);
setInputValue("[name='overheat_protection[high_temp]']", Number(data.heating.overheat_protection.high_temp.toFixed(1)), {
"min": 0,
"max": data.system.unit_system == 0 ? 100 : 212
}, form);
setInputValue("[name='overheat_protection[low_temp]']", Number(data.heating.overheat_protection.low_temp.toFixed(1)), {
"min": 0,
"max": data.system.unit_system == 0 ? 99 : 211
}, form);
setInputValue("[name='freeze_protection[high_temp]']", Number(data.heating.freeze_protection.high_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 1 : 33.8,
"max": data.system.unit_system == 0 ? 50 : 122
}, form);
setInputValue("[name='freeze_protection[low_temp]']", Number(data.heating.freeze_protection.low_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 1 : 33.8,
"max": data.system.unit_system == 0 ? 30 : 86
}, form);
} else if (section === 'dhw') {
setInputValue("[name='min_temp']", Number(data.dhw.min_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 0 : 32,
"max": data.system.unit_system == 0 ? 99 : 211
}, form);
setInputValue("[name='max_temp']", Number(data.dhw.max_temp.toFixed(1)), {
"min": data.system.unit_system == 0 ? 1 : 33.8,
"max": data.system.unit_system == 0 ? 100 : 212
}, form);
setInputValue("[name='max_modulation']", data.dhw.max_modulation, {}, form);
setInputValue("[name='overheat_protection[high_temp]']", Number(data.dhw.overheat_protection.high_temp.toFixed(1)), {
"min": 0,
"max": data.system.unit_system == 0 ? 100 : 212
}, form);
setInputValue("[name='overheat_protection[low_temp]']", Number(data.dhw.overheat_protection.low_temp.toFixed(1)), {
"min": 0,
"max": data.system.unit_system == 0 ? 99 : 211
}, form);
} else if (section === 'emergency') {
if (data.opentherm.options.native_otc) {
setInputValue("[name='target']", data.emergency.target, {
"min": data.system.unit_system == 0 ? 5 : 41,
"max": data.system.unit_system == 0 ? 40 : 104
}, form);
} else {
setInputValue("[name='target']", data.emergency.target, {
"min": data.heating.min_temp,
"max": data.heating.max_temp,
}, form);
}
setInputValue("[name='threshold_time']", data.emergency.threshold_time, {}, form);
} else if (section === 'equitherm') {
setCheckboxValue("[name='enabled']", data.equitherm.enabled, form);
setInputValue("[name='slope']", data.equitherm.slope, {}, form);
setInputValue("[name='exponent']", data.equitherm.exponent, {}, form);
setInputValue("[name='shift']", data.equitherm.shift, {}, form);
setInputValue("[name='target_diff_factor']", data.equitherm.target_diff_factor, {}, form);
const etMinTemp = parseInt(data.system.unit_system == 0 ? 5 : 41);
const etMaxTemp = parseInt(data.system.unit_system == 0 ? 30 : 86);
const etTargetTemp = constrain(parseFloat(data.heating.target), etMinTemp, etMaxTemp);
setInputValue(".etChartTargetTemp", etTargetTemp.toFixed(1), {
"min": etMinTemp,
"max": etMaxTemp
}, form);
etChartConfig.slope = data.equitherm.slope;
etChartConfig.exponent = data.equitherm.exponent;
etChartConfig.shift = data.equitherm.shift;
etChartConfig.unitSystem = data.system.unit_system;
etChartConfig.targetTemp = data.system.unit_system == 0 ? etTargetTemp : f2c(etTargetTemp);
etChartConfig.minTemp = data.system.unit_system == 0 ? data.heating.min_temp : f2c(data.heating.min_temp);
etChartConfig.maxTemp = data.system.unit_system == 0 ? data.heating.max_temp : f2c(data.heating.max_temp);
makeEquithermChart();
} else if (section === 'pid') {
setCheckboxValue("[name='enabled']", data.pid.enabled, form);
setInputValue("[name='p_factor']", data.pid.p_factor, {}, form);
setInputValue("[name='i_factor']", data.pid.i_factor, {}, form);
setInputValue("[name='d_factor']", data.pid.d_factor, {}, form);
setInputValue("[name='dt']", data.pid.dt, {}, form);
setInputValue("[name='min_temp']", Number(data.pid.min_temp.toFixed(1)), {
"min": data.equitherm.enabled ? -99 : (data.system.unit_system == 0 ? 0 : 32),
"max": data.equitherm.enabled ? 99 : (data.system.unit_system == 0 ? 99 : 211),
"step": data.equitherm.enabled ? 1 : 0.1
}, form);
setInputValue("[name='max_temp']", Number(data.pid.max_temp.toFixed(1)), {
"min": data.equitherm.enabled ? 1 : (data.system.unit_system == 0 ? 1 : 33.8),
"max": data.equitherm.enabled ? 99 : (data.system.unit_system == 0 ? 100 : 212),
"step": data.equitherm.enabled ? 1 : 0.1
}, form);
setCheckboxValue("[name='deadband[enabled]']", data.pid.deadband.enabled, form);
setInputValue("[name='deadband[p_multiplier]']", data.pid.deadband.p_multiplier, {}, form);
setInputValue("[name='deadband[i_multiplier]']", data.pid.deadband.i_multiplier, {}, form);
setInputValue("[name='deadband[d_multiplier]']", data.pid.deadband.d_multiplier, {}, form);
setInputValue("[name='deadband[threshold_high]']", data.pid.deadband.threshold_high, {}, form);
setInputValue("[name='deadband[threshold_low]']", data.pid.deadband.threshold_low, {}, form);
}
setBusy(`#${form.id}-busy`, `#${form.id}`, false);
};
const loadedSettings = {};
let sectionLoading = Promise.resolve();
const getSettings = async (section) => {
const response = await fetch(`/api/settings/${section}`, {
cache: "no-cache",
credentials: "include"
});
if (!response.ok) {
throw new Error('Response not valid');
}
return response.json();
};
const loadTimezones = async () => {
const selector = document.querySelector(".presetTimezones");
if (selector.options.length > 1) {
return;
}
const response = await fetch("/static/timezones.json");
if (!response.ok) {
throw new Error('Response not valid');
}
const timezones = await response.json();
for (const name in timezones) {
selector.appendChild(new Option(name, timezones[name]));
}
};
const loadSection = (form, result = null) => {
const details = form.closest('details');
if (details.dataset.loading === '1') {
if (result !== null) {
// The saved value must replace any older response still in flight.
details.dataset.reload = '1';
}
return;
}
details.dataset.loading = '1';
const busy = document.getElementById(`${form.id}-busy`);
busy.textContent = '';
busy.setAttribute('aria-busy', true);
setBusy(`#${busy.id}`, `#${form.id}`, true);
// Read one section at a time, including when several cards are opened.
sectionLoading = sectionLoading.then(async () => {
try {
if (!details.open && result === null) {
return;
}
const section = form.dataset.section;
const data = {};
if (['heating', 'dhw', 'emergency', 'equitherm', 'pid'].includes(section)) {
data.system = await getSettings('system');
}
if (section === 'emergency') {
data.opentherm = await getSettings('opentherm');
if (!data.opentherm.options.native_otc) {
data.heating = await getSettings('heating');
}
} else if (section === 'equitherm') {
data.heating = await getSettings('heating');
} else if (section === 'pid') {
data.equitherm = await getSettings('equitherm');
}
data[section] = result === null ? await getSettings(section) : result;
if (section === 'system') {
try {
await loadTimezones();
} catch (error) {
console.log(error);
}
}
if (details.dataset.reload === '1') {
return;
}
fillData(form, data);
loadedSettings[section] = data[section];
details.dataset.preloaded = '1';
} catch (error) {
details.dataset.preloaded = '0';
busy.setAttribute('aria-busy', false);
busy.textContent = i18n('button.error');
console.log(error);
} finally {
details.dataset.loading = '0';
if (details.dataset.reload === '1') {
details.dataset.reload = '0';
if (details.open) {
loadSection(form);
}
}
}
});
};
const setupSettingsForm = (selector, noCastItems = []) => {
const form = document.querySelector(selector);
const details = form.closest('details');
const section = form.dataset.section;
details.addEventListener('toggle', () => {
if (details.open && details.dataset.preloaded !== '1') {
loadSection(form);
}
});
setupForm(selector, (result) => {
const previous = loadedSettings[section];
loadSection(form, result);
let affected = [];
if (section === 'system' && previous.unit_system !== result.unit_system) {
affected = ['heating', 'dhw', 'emergency', 'equitherm', 'pid'];
} else if (section === 'opentherm' && previous.options.native_otc !== result.options.native_otc) {
affected = ['emergency', 'equitherm', 'pid'];
} else if (section === 'heating' && (previous.min_temp !== result.min_temp
|| previous.max_temp !== result.max_temp || previous.target !== result.target)) {
affected = ['emergency', 'equitherm'];
} else if (section === 'equitherm' && previous.enabled !== result.enabled) {
affected = ['pid'];
} else if (section === 'pid' && previous.enabled !== result.enabled) {
affected = ['equitherm'];
}
for (const otherForm of document.querySelectorAll('form[data-section]')) {
if (affected.includes(otherForm.dataset.section)) {
const otherDetails = otherForm.closest('details');
otherDetails.dataset.preloaded = '0';
if (otherDetails.dataset.loading === '1') {
// Finish the old request, then read the normalized values again.
otherDetails.dataset.reload = '1';
} else if (otherDetails.open) {
loadSection(otherForm);
}
}
}
}, noCastItems);
if (details.open) {
loadSection(form);
}
};
setupSettingsForm('#portal-settings', ['login', 'password']);
setupSettingsForm('#system-settings', ['ntp.server', 'ntp.timezone']);
setupSettingsForm('#heating-settings');
setupSettingsForm('#dhw-settings');
setupSettingsForm('#emergency-settings');
setupSettingsForm('#equitherm-settings');
setupSettingsForm('#pid-settings');
setupSettingsForm('#ot-settings');
setupSettingsForm('#mqtt-settings', ['server', 'user', 'password', 'prefix', 'ha_discovery_prefix']);
setupSettingsForm('#extpump-settings');
setupSettingsForm('#cc-settings');
document.querySelector(".presetTimezones").addEventListener('change', (event) => {
document.querySelector("#system-settings [name='ntp[timezone]']").value = event.target.value;
});
document.querySelector(".etChartTargetTemp").addEventListener("input", async (event) => {
setValue('.etChartTargetTempValue', parseFloat(event.target.value).toFixed(1));
});
document.querySelector(".etChartTargetTemp").addEventListener("change", async (event) => {
if (!event.target.checkValidity()) {
return;
}
const targetTemp = parseFloat(event.target.value);
etChartConfig.targetTemp = etChartConfig.unitSystem == 0 ? targetTemp : f2c(targetTemp);
setValue('.etChartTargetTempValue', targetTemp.toFixed(1));
makeEquithermChart();
});
document.querySelector("#equitherm-settings [name='slope']").addEventListener("change", async (event) => {
if (!event.target.checkValidity()) {
return;
}
etChartConfig.slope = parseFloat(event.target.value);
makeEquithermChart();
});
document.querySelector("#equitherm-settings [name='exponent']").addEventListener("change", async (event) => {
if (!event.target.checkValidity()) {
return;
}
etChartConfig.exponent = parseFloat(event.target.value);
makeEquithermChart();
});
document.querySelector("#equitherm-settings [name='shift']").addEventListener("change", async (event) => {
if (!event.target.checkValidity()) {
return;
}
etChartConfig.shift = parseFloat(event.target.value);
makeEquithermChart();
});
window.addEventListener('resize', async (event) => {
if (etChart) {
etChart.resize();
if (etChartConfig.decimated != hasNeedDecimationChart()) {
makeEquithermChart();
}
}
});
});
</script>
</body>
</html>