mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-23 14:53:07 +05:00
Restore legacy backups through the settings APIs, update the dashboard and sensor controls, and keep translations in sync. Package the backup converter separately and wait for all compressed web assets before building LittleFS.
835 lines
32 KiB
HTML
835 lines
32 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>dashboard.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>dashboard.name</h2>
|
|
<p></p>
|
|
</hgroup>
|
|
|
|
<div id="dashboard-busy" aria-busy="true"></div>
|
|
<div id="dashboard-container" class="hidden">
|
|
<details open>
|
|
<summary><b data-i18n>dashboard.section.control</b></summary>
|
|
<div class="grid">
|
|
<div class="thermostat tHeat" data-purpose="heating" data-min="0" data-max="100" data-step="0.1" data-big-step="1">
|
|
<div class="thermostat-header" data-i18n>dashboard.thermostat.heating</div>
|
|
<div class="thermostat-temp">
|
|
<div class="thermostat-temp-target"><span class="targetTemp"></span> <span class="tempUnit"></span></div>
|
|
<div class="thermostat-temp-current"><span data-i18n>dashboard.thermostat.currentTemp</span>: <span id="tHeatCurrentTemp"></span> <span class="tempUnit"></span></div>
|
|
</div>
|
|
<div class="thermostat-minus">
|
|
<button class="tAction outline" data-action="decrement"><i class="icons-down"></i></button>
|
|
</div>
|
|
<div class="thermostat-plus">
|
|
<button class="tAction outline" data-action="increment"><i class="icons-up"></i></button>
|
|
</div>
|
|
<div class="thermostat-control">
|
|
<input type="checkbox" role="switch" id="tHeatEnabled" value="true">
|
|
<label htmlFor="tHeatEnabled" data-i18n>dashboard.thermostat.enable</label>
|
|
|
|
<input type="checkbox" role="switch" id="tHeatTurbo" value="true">
|
|
<label htmlFor="tHeatTurbo" data-i18n>dashboard.thermostat.turbo</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="thermostat tDhw" data-purpose="dhw" data-min="0" data-max="100" data-step="1" data-big-step="5">
|
|
<div class="thermostat-header" data-i18n>dashboard.thermostat.dhw</div>
|
|
<div class="thermostat-temp">
|
|
<div class="thermostat-temp-target"><span class="targetTemp"></span> <span class="tempUnit"></span></div>
|
|
<div class="thermostat-temp-current"><span data-i18n>dashboard.thermostat.currentTemp</span>: <span id="tDhwCurrentTemp"></span> <span class="tempUnit"></span></div>
|
|
</div>
|
|
<div class="thermostat-minus">
|
|
<button class="tAction outline" data-action="decrement"><i class="icons-down"></i></button>
|
|
</div>
|
|
<div class="thermostat-plus">
|
|
<button class="tAction outline" data-action="increment"><i class="icons-up"></i></button>
|
|
</div>
|
|
<div class="thermostat-control">
|
|
<input type="checkbox" role="switch" id="tDhwEnabled" value="true">
|
|
<label htmlFor="tDhwEnabled" data-i18n>dashboard.thermostat.enable</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="notify notify-error notify-fault hidden">
|
|
<div class="notify-icon">
|
|
<i class="icons-error"></i>
|
|
</div>
|
|
<div class="notify-content">
|
|
<b data-i18n>dashboard.notify.fault.title</b><br />
|
|
<small>
|
|
<span data-i18n>dashboard.notify.fault.note</span> <b class="sFaultCode"></b>
|
|
</small>
|
|
</div>
|
|
<div class="notify-actions">
|
|
<button class="reset" data-i18n>dashboard.notify.reset</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="notify notify-alarm notify-diag hidden">
|
|
<div class="notify-icon">
|
|
<i class="icons-alarm"></i>
|
|
</div>
|
|
<div class="notify-content">
|
|
<b data-i18n>dashboard.notify.diag.title</b><br />
|
|
<small>
|
|
<span data-i18n>dashboard.notify.diag.note</span> <b class="sDiagCode"></b>
|
|
</small>
|
|
</div>
|
|
<div class="notify-actions">
|
|
<button class="reset" data-i18n>dashboard.notify.reset</button>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
|
|
<hr />
|
|
|
|
<details>
|
|
<summary><b data-i18n>dashboard.section.states</b></summary>
|
|
<table>
|
|
<tbody>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mNetworkConnected</th>
|
|
<td><i class="mNetworkConnected"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mMqttConnected</th>
|
|
<td><i class="mMqttConnected"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mEmergencyState</th>
|
|
<td><i class="mEmergencyState"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mExtPumpState</th>
|
|
<td><i class="mExtPumpState"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mCascadeControlInput</th>
|
|
<td><i class="mCascadeControlInput"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mCascadeControlOutput</th>
|
|
<td><i class="mCascadeControlOutput"></i></td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sConnected</th>
|
|
<td><i class="sConnected"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sFlame</th>
|
|
<td><i class="sFlame"></i></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sCoolingActive</th>
|
|
<td><i class="sCoolingActive"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sCoolingSetpoint</th>
|
|
<td><b class="sCoolingSetpoint"></b> %</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sFaultActive</th>
|
|
<td><i class="sFaultActive"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sFaultCode</th>
|
|
<td><b class="sFaultCode"></b></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sDiagActive</th>
|
|
<td><i class="sDiagActive"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sDiagCode</th>
|
|
<td><b class="sDiagCode"></b></td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatEnabled</th>
|
|
<td><i class="mHeatEnabled"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatBlocking</th>
|
|
<td><i class="mHeatBlocking"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatOverheat</th>
|
|
<td><i class="mHeatOverheat"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatFreezing</th>
|
|
<td><i class="mHeatFreezing"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sHeatActive</th>
|
|
<td><i class="sHeatActive"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatTargetTemp</th>
|
|
<td><b class="mHeatTargetTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatSetpointTemp</th>
|
|
<td><b class="mHeatSetpointTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatCurrTemp</th>
|
|
<td><b class="mHeatCurrTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatRetTemp</th>
|
|
<td><b class="mHeatRetTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatIndoorTemp</th>
|
|
<td><b class="mHeatIndoorTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mHeatOutdoorTemp</th>
|
|
<td><b class="mHeatOutdoorTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mDhwEnabled</th>
|
|
<td><i class="mDhwEnabled"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mDhwOverheat</th>
|
|
<td><i class="mDhwOverheat"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.sDhwActive</th>
|
|
<td><i class="sDhwActive"></i></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mDhwTargetTemp</th>
|
|
<td><b class="mDhwTargetTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mDhwCurrTemp</th>
|
|
<td><b class="mDhwCurrTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" data-i18n>dashboard.states.mDhwRetTemp</th>
|
|
<td><b class="mDhwRetTemp"></b> <span class="tempUnit"></span></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</details>
|
|
|
|
<hr />
|
|
|
|
<details>
|
|
<summary><b data-i18n>dashboard.section.sensors</b></summary>
|
|
<table>
|
|
<tbody class="sensors">
|
|
<tr class="sensor template hidden">
|
|
<td style="width: 1.35rem">
|
|
<span class="sStatusContainer">
|
|
<i class="sStatus"></i>
|
|
</span>
|
|
</td>
|
|
<th scope="row" class="sName"></th>
|
|
<td class="sValue"></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</details>
|
|
|
|
<hr />
|
|
|
|
<details>
|
|
<summary><b data-i18n>dashboard.section.diag</b></summary>
|
|
<pre><b>Vendor:</b> <span class="sVendor"></span>
|
|
<b>Member ID:</b> <span class="sMemberId"></span>
|
|
<b>Flags:</b> <span class="sFlags"></span>
|
|
<b>Type:</b> <span class="sType"></span>
|
|
<b>AppVersion:</b> <span class="sAppVersion"></span>
|
|
<b>OT version:</b> <span class="sProtocolVersion"></span>
|
|
<b>Modulation:</b> min: <span class="sModMin"></span> %, curr. max: <span class="sModMax"></span> %
|
|
<b>Power limits:</b> <span class="sPowerMin"></span>...<span class="sPowerMax"></span> kW
|
|
<b>Heating limits:</b> <span class="sHeatMinTemp"></span>...<span class="sHeatMaxTemp"></span> <span class="tempUnit"></span>
|
|
<b>DHW limits:</b> <span class="sDhwMinTemp"></span>...<span class="sDhwMaxTemp"></span> <span class="tempUnit"></span></pre>
|
|
</details>
|
|
</div>
|
|
</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>
|
|
let modifiedTime = null;
|
|
let prevSettings;
|
|
let newSettings = {
|
|
heating: {
|
|
enabled: false,
|
|
turbo: false,
|
|
target: 0
|
|
},
|
|
dhw: {
|
|
enabled: false,
|
|
target: 0
|
|
}
|
|
};
|
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
const lang = new Lang(document.getElementById('lang'));
|
|
await lang.build();
|
|
|
|
let activePress = null;
|
|
const stopPress = () => {
|
|
if (!activePress) {
|
|
return;
|
|
}
|
|
|
|
const press = activePress;
|
|
activePress = null;
|
|
clearInterval(press.timer);
|
|
if (press.button.hasPointerCapture(press.pointerId)) {
|
|
press.button.releasePointerCapture(press.pointerId);
|
|
}
|
|
};
|
|
|
|
document.querySelectorAll('.tAction').forEach((item) => {
|
|
const action = item.dataset.action;
|
|
const tContainer = item.parentNode.parentNode;
|
|
const changeTarget = (step, minTemp, maxTemp) => {
|
|
const purpose = tContainer.dataset.purpose;
|
|
let value = 0;
|
|
if (action == 'increment') {
|
|
value = step;
|
|
|
|
} else if (action == 'decrement') {
|
|
value = -(step);
|
|
}
|
|
|
|
const newValue = parseFloat(constrain(newSettings[purpose].target + value, minTemp, maxTemp).toFixed(2));
|
|
if (newSettings[purpose].target != newValue) {
|
|
newSettings[purpose].target = newValue;
|
|
modifiedTime = Date.now();
|
|
|
|
setValue('.targetTemp', newValue, tContainer);
|
|
tContainer.querySelector('.thermostat-header').setAttribute("aria-busy", "true");
|
|
}
|
|
};
|
|
|
|
item.addEventListener('pointerdown', (event) => {
|
|
if (!prevSettings || activePress || event.button !== 0) {
|
|
return;
|
|
}
|
|
|
|
const minTemp = parseFloat(tContainer.dataset.min);
|
|
const maxTemp = parseFloat(tContainer.dataset.max);
|
|
const bigStep = parseFloat(tContainer.dataset.bigStep);
|
|
const press = {button: item, pointerId: event.pointerId, timer: null, longPress: false};
|
|
activePress = press;
|
|
item.setPointerCapture(event.pointerId);
|
|
press.timer = setInterval(() => {
|
|
press.longPress = true;
|
|
changeTarget(bigStep, minTemp, maxTemp);
|
|
}, 500);
|
|
});
|
|
|
|
item.addEventListener('pointerup', (event) => {
|
|
if (!activePress || activePress.button !== item || activePress.pointerId !== event.pointerId) {
|
|
return;
|
|
}
|
|
|
|
const longPress = activePress.longPress;
|
|
stopPress();
|
|
if (!longPress) {
|
|
changeTarget(
|
|
parseFloat(tContainer.dataset.step),
|
|
parseFloat(tContainer.dataset.min), parseFloat(tContainer.dataset.max)
|
|
);
|
|
}
|
|
});
|
|
|
|
for (const eName of ['pointercancel', 'lostpointercapture']) {
|
|
item.addEventListener(eName, (event) => {
|
|
if (activePress && activePress.button === item && activePress.pointerId === event.pointerId) {
|
|
stopPress();
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
window.addEventListener('blur', stopPress);
|
|
document.addEventListener('visibilitychange', () => {
|
|
if (document.hidden) {
|
|
stopPress();
|
|
}
|
|
});
|
|
|
|
document.querySelector('#tHeatEnabled').addEventListener('change', (event) => {
|
|
if (newSettings.heating.enabled == event.currentTarget.checked) {
|
|
return;
|
|
}
|
|
|
|
modifiedTime = Date.now();
|
|
newSettings.heating.enabled = event.currentTarget.checked;
|
|
document.querySelector('.tHeat .thermostat-header').setAttribute("aria-busy", "true");
|
|
});
|
|
|
|
document.querySelector('#tHeatTurbo').addEventListener('change', (event) => {
|
|
if (newSettings.heating.turbo == event.currentTarget.checked) {
|
|
return;
|
|
}
|
|
|
|
modifiedTime = Date.now();
|
|
newSettings.heating.turbo = event.currentTarget.checked;
|
|
document.querySelector('.tHeat .thermostat-header').setAttribute("aria-busy", "true");
|
|
});
|
|
|
|
document.querySelector('#tDhwEnabled').addEventListener('change', (event) => {
|
|
if (newSettings.dhw.enabled == event.currentTarget.checked) {
|
|
return;
|
|
}
|
|
|
|
modifiedTime = Date.now();
|
|
newSettings.dhw.enabled = event.currentTarget.checked;
|
|
document.querySelector('.tDhw .thermostat-header').setAttribute("aria-busy", "true");
|
|
});
|
|
|
|
document.querySelector('.notify-fault .reset').addEventListener('click', async (event) => {
|
|
const resetBtn = document.querySelector(".notify-fault .reset");
|
|
if (!resetBtn.disabled) {
|
|
resetBtn.disabled = true;
|
|
}
|
|
|
|
let response = await fetch("/api/vars", {
|
|
method: "POST",
|
|
cache: "no-cache",
|
|
credentials: "include",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
"actions": {
|
|
"reset_fault": true
|
|
}
|
|
})
|
|
});
|
|
|
|
setTimeout(() => {
|
|
if (resetBtn.disabled) {
|
|
resetBtn.disabled = false;
|
|
}
|
|
}, 10000);
|
|
});
|
|
|
|
document.querySelector('.notify-diag .reset').addEventListener('click', async (event) => {
|
|
const resetBtn = document.querySelector(".notify-diag .reset");
|
|
if (!resetBtn.disabled) {
|
|
resetBtn.disabled = true;
|
|
}
|
|
|
|
let response = await fetch("/api/vars", {
|
|
method: "POST",
|
|
cache: "no-cache",
|
|
credentials: "include",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
body: JSON.stringify({
|
|
"actions": {
|
|
"reset_diagnostic": true
|
|
}
|
|
})
|
|
});
|
|
|
|
setTimeout(() => {
|
|
if (resetBtn.disabled) {
|
|
resetBtn.disabled = false;
|
|
}
|
|
}, 10000);
|
|
});
|
|
|
|
const requestSettingsSection = async (section, values = null) => {
|
|
const parameters = {
|
|
method: "GET",
|
|
cache: "no-cache",
|
|
credentials: "include"
|
|
};
|
|
|
|
if (values !== null) {
|
|
parameters.method = "POST";
|
|
parameters.headers = {"Content-Type": "application/json"};
|
|
parameters.body = JSON.stringify(values);
|
|
}
|
|
|
|
const response = await fetch(`/api/settings/${section}`, parameters);
|
|
if (!response.ok) {
|
|
throw new Error('Response not valid');
|
|
}
|
|
|
|
return response.json();
|
|
};
|
|
|
|
setTimeout(async function onLoadPage() {
|
|
let unitSystem = null;
|
|
|
|
if (modifiedTime) {
|
|
if ((Date.now() - modifiedTime) < 5000) {
|
|
setTimeout(onLoadPage, 1000);
|
|
return;
|
|
}
|
|
|
|
modifiedTime = null;
|
|
}
|
|
|
|
// settings
|
|
try {
|
|
const heatingSettings = {...newSettings.heating};
|
|
const dhwSettings = {...newSettings.dhw};
|
|
const heatingModified = prevSettings && (
|
|
(prevSettings.heating.enabled != heatingSettings.enabled)
|
|
|| (prevSettings.heating.turbo != heatingSettings.turbo)
|
|
|| (prevSettings.heating.target != heatingSettings.target)
|
|
);
|
|
const dhwModified = prevSettings && prevSettings.opentherm.options.dhw_support && (
|
|
(prevSettings.dhw.enabled != dhwSettings.enabled)
|
|
|| (prevSettings.dhw.target != dhwSettings.target)
|
|
);
|
|
|
|
const system = await requestSettingsSection('system');
|
|
const opentherm = await requestSettingsSection('opentherm');
|
|
const heating = await requestSettingsSection('heating', heatingModified ? heatingSettings : null);
|
|
const dhw = await requestSettingsSection('dhw', dhwModified ? dhwSettings : null);
|
|
const result = {system, opentherm, heating, dhw};
|
|
prevSettings = result;
|
|
unitSystem = result.system.unit_system;
|
|
|
|
if (result.opentherm.options.dhw_support) {
|
|
show('.tDhw');
|
|
} else {
|
|
hide('.tDhw');
|
|
}
|
|
|
|
setValue('.tempUnit', temperatureUnit(unitSystem));
|
|
setValue('.pressureUnit', pressureUnit(unitSystem));
|
|
setValue('.volumeUnit', volumeUnit(unitSystem));
|
|
|
|
// An edit made while these requests were in flight is still waiting to be sent.
|
|
if (modifiedTime === null) {
|
|
newSettings.heating.enabled = result.heating.enabled;
|
|
newSettings.heating.turbo = result.heating.turbo;
|
|
newSettings.heating.target = result.heating.target;
|
|
newSettings.dhw.enabled = result.dhw.enabled;
|
|
newSettings.dhw.target = result.dhw.target;
|
|
|
|
setCheckboxValue('#tHeatEnabled', result.heating.enabled);
|
|
setCheckboxValue('#tHeatTurbo', result.heating.turbo);
|
|
setValue('.tHeat .targetTemp', result.heating.target);
|
|
|
|
setCheckboxValue('#tDhwEnabled', result.dhw.enabled);
|
|
setValue('.tDhw .targetTemp', result.dhw.target);
|
|
|
|
document.querySelectorAll('.thermostat-header').forEach((item) => {
|
|
item.setAttribute("aria-busy", "false");
|
|
});
|
|
}
|
|
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
// vars
|
|
try {
|
|
const response = await fetch("/api/vars", {
|
|
cache: "no-cache",
|
|
credentials: "include"
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Response not valid');
|
|
}
|
|
|
|
const result = await response.json();
|
|
|
|
// Graph
|
|
setValue('#tHeatCurrentTemp', result.master.heating.indoor_temp_control
|
|
? result.master.heating.indoor_temp
|
|
: result.master.heating.current_temp
|
|
);
|
|
setValue('#tDhwCurrentTemp', result.master.dhw.current_temp);
|
|
|
|
|
|
// SLAVE
|
|
setValue('.sMemberId', result.slave.member_id);
|
|
setValue('.sVendor', memberIdToVendor(result.slave.member_id));
|
|
setValue('.sFlags', result.slave.flags);
|
|
setValue('.sType', result.slave.type);
|
|
setValue('.sAppVersion', result.slave.app_version);
|
|
setValue('.sProtocolVersion', result.slave.protocol_version);
|
|
|
|
setStatus(
|
|
'.sConnected',
|
|
result.slave.connected ? "success" : "error",
|
|
result.slave.connected ? "green" : "red"
|
|
);
|
|
setState('.sFlame', result.slave.flame);
|
|
|
|
setState('.sCoolingActive', result.slave.cooling.active);
|
|
setValue('.sCoolingSetpoint', result.slave.cooling.setpoint);
|
|
|
|
setValue('.sModMin', result.slave.modulation.min);
|
|
setValue('.sModMax', result.slave.modulation.max);
|
|
|
|
setValue('.sPowerMin', result.slave.power.min);
|
|
setValue('.sPowerMax', result.slave.power.max);
|
|
|
|
setState('.sHeatActive', result.slave.heating.active);
|
|
setValue('.sHeatMinTemp', result.slave.heating.min_temp);
|
|
setValue('.sHeatMaxTemp', result.slave.heating.max_temp);
|
|
|
|
setState('.sDhwActive', result.slave.dhw.active);
|
|
setValue('.sDhwMinTemp', result.slave.dhw.min_temp);
|
|
setValue('.sDhwMaxTemp', result.slave.dhw.max_temp);
|
|
|
|
setStatus(
|
|
'.sFaultActive',
|
|
result.slave.fault.active ? "success" : "error",
|
|
result.slave.fault.active ? "red" : "green"
|
|
);
|
|
setValue(
|
|
'.sFaultCode',
|
|
result.slave.fault.active
|
|
? `${result.slave.fault.code} (0x${dec2hex(result.slave.fault.code)})`
|
|
: "-"
|
|
);
|
|
|
|
if (result.slave.fault.active) {
|
|
show(".notify-fault");
|
|
|
|
} else {
|
|
hide('.notify-fault');
|
|
}
|
|
|
|
setStatus(
|
|
'.sDiagActive',
|
|
result.slave.diag.active ? "success" : "error",
|
|
result.slave.diag.active ? "red" : "green"
|
|
);
|
|
setValue(
|
|
'.sDiagCode',
|
|
result.slave.diag.active
|
|
? `${result.slave.diag.code} (0x${dec2hex(result.slave.diag.code)})`
|
|
: "-"
|
|
);
|
|
|
|
if (result.slave.diag.active) {
|
|
show(".notify-diag");
|
|
|
|
} else {
|
|
hide('.notify-diag');
|
|
}
|
|
|
|
|
|
// MASTER
|
|
setState('.mHeatEnabled', result.master.heating.enabled);
|
|
setStatus(
|
|
'.mHeatBlocking',
|
|
result.master.heating.blocking ? "success" : "error",
|
|
result.master.heating.blocking ? "red" : "green"
|
|
);
|
|
setState('.mHeatIndoorTempControl', result.master.heating.indoor_temp_control);
|
|
setStatus(
|
|
'.mHeatOverheat',
|
|
result.master.heating.overheat ? "success" : "error",
|
|
result.master.heating.overheat ? "red" : "green"
|
|
);
|
|
setStatus(
|
|
'.mHeatFreezing',
|
|
result.master.heating.freezing ? "success" : "error",
|
|
result.master.heating.freezing ? "red" : "green"
|
|
);
|
|
setValue('.mHeatSetpointTemp', result.master.heating.setpoint_temp);
|
|
setValue('.mHeatTargetTemp', result.master.heating.target_temp);
|
|
setValue('.mHeatCurrTemp', result.master.heating.current_temp);
|
|
setValue('.mHeatRetTemp', result.master.heating.return_temp);
|
|
setValue('.mHeatIndoorTemp', result.master.heating.indoor_temp);
|
|
setValue('.mHeatOutdoorTemp', result.master.heating.outdoor_temp);
|
|
setValue('.mHeatMinTemp', result.master.heating.min_temp);
|
|
setValue('.mHeatMaxTemp', result.master.heating.max_temp);
|
|
|
|
setState('.mDhwEnabled', result.master.dhw.enabled);
|
|
setStatus(
|
|
'.mDhwOverheat',
|
|
result.master.dhw.overheat ? "success" : "error",
|
|
result.master.dhw.overheat ? "red" : "green"
|
|
);
|
|
setValue('.mDhwTargetTemp', result.master.dhw.target_temp);
|
|
setValue('.mDhwCurrTemp', result.master.dhw.current_temp);
|
|
setValue('.mDhwRetTemp', result.master.dhw.return_temp);
|
|
setValue('.mDhwMinTemp', result.master.dhw.min_temp);
|
|
setValue('.mDhwMaxTemp', result.master.dhw.max_temp);
|
|
|
|
setStatus(
|
|
'.mNetworkConnected',
|
|
result.master.network.connected ? "success" : "error",
|
|
result.master.network.connected ? "green" : "red"
|
|
);
|
|
setState('.mMqttConnected', result.master.mqtt.connected);
|
|
setStatus(
|
|
'.mEmergencyState',
|
|
result.master.emergency.state ? "success" : "error",
|
|
result.master.emergency.state ? "red" : "green"
|
|
);
|
|
setState('.mExtPumpState', result.master.ext_pump.state);
|
|
setState('.mCascadeControlInput', result.master.cascade_control.input);
|
|
setState('.mCascadeControlOutput', result.master.cascade_control.output);
|
|
|
|
const tHeat = document.querySelector('.tHeat');
|
|
tHeat.dataset.min = result.master.heating.min_temp;
|
|
tHeat.dataset.max = result.master.heating.max_temp;
|
|
|
|
const tDhw = document.querySelector('.tDhw');
|
|
tDhw.dataset.min = result.master.dhw.min_temp;
|
|
tDhw.dataset.max = result.master.dhw.max_temp;
|
|
|
|
setBusy('#dashboard-busy', '#dashboard-container', false);
|
|
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
// sensors
|
|
try {
|
|
const response = await fetch("/api/sensors?detailed=1", {
|
|
cache: "no-cache",
|
|
credentials: "include"
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error("Response not valid");
|
|
}
|
|
|
|
const container = document.querySelector(".sensors");
|
|
const templateNode = container.querySelector(".template");
|
|
const result = await response.json();
|
|
|
|
for (const sensorId in result) {
|
|
let sensorNode = container.querySelector(`.sensor[data-id='${sensorId}']`);
|
|
if (sensorNode) {
|
|
continue;
|
|
}
|
|
|
|
sensorNode = templateNode.cloneNode(true);
|
|
sensorNode.dataset.id = sensorId;
|
|
sensorNode.classList.remove("template");
|
|
container.appendChild(sensorNode);
|
|
}
|
|
|
|
for (const sensorId in result) {
|
|
const sensorNode = container.querySelector(`.sensor[data-id='${sensorId}']`);
|
|
if (!sensorNode) {
|
|
continue;
|
|
}
|
|
|
|
const sData = result[sensorId];
|
|
if (!sData.enabled || sData.purpose == 255) {
|
|
sensorNode.classList.toggle("hidden", true);
|
|
continue;
|
|
}
|
|
|
|
sensorNode.classList.toggle("hidden", false);
|
|
|
|
setStatus(
|
|
".sStatus",
|
|
sData.connected ? "success" : "error",
|
|
sData.connected ? "green" : "red",
|
|
sensorNode
|
|
);
|
|
setTextValue(".sName", sData.name, sensorNode);
|
|
setValue(".sValue", "", sensorNode);
|
|
|
|
const statusNode = sensorNode.querySelector(`.sStatusContainer`);
|
|
if (statusNode) {
|
|
statusNode.dataset.tooltip = `${sData.signal_quality}%`;
|
|
}
|
|
|
|
if (sData.value !== undefined) {
|
|
const sUnit = purposeUnit(sData.purpose, unitSystem);
|
|
appendValue(".sValue", `<b>${sData.value.toFixed(2)}</b> ${sUnit !== null ? sUnit : ``}`, `<br />`, sensorNode);
|
|
}
|
|
|
|
if (sData.temperature !== undefined) {
|
|
const sUnit = temperatureUnit(unitSystem);
|
|
appendValue(".sValue", `${i18n('dashboard.sensors.values.temp')}: <b>${sData.temperature.toFixed(2)}</b> ${sUnit !== null ? sUnit : ``}`, `<br />`, sensorNode);
|
|
}
|
|
|
|
if (sData.humidity !== undefined) {
|
|
appendValue(".sValue", `${i18n('dashboard.sensors.values.humidity')}: <b>${sData.humidity.toFixed(2)}</b> %`, `<br />`, sensorNode);
|
|
}
|
|
|
|
if (sData.battery !== undefined) {
|
|
appendValue(".sValue", `${i18n('dashboard.sensors.values.battery')}: <b>${sData.battery.toFixed(2)}</b> %`, `<br />`, sensorNode);
|
|
}
|
|
|
|
if (sData.rssi !== undefined) {
|
|
appendValue(".sValue", `${i18n('dashboard.sensors.values.rssi')}: <b>${sData.rssi.toFixed(0)}</b> ${i18n('units.dbm')}`, `<br />`, sensorNode);
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
setTimeout(onLoadPage, 10000);
|
|
}, 1000);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|