feat: update portal for unit systems

This commit is contained in:
Yurii
2024-03-31 06:32:23 +03:00
parent 14aef20234
commit 0cff35ee12
4 changed files with 40 additions and 9 deletions

View File

@@ -180,23 +180,31 @@
</tr> </tr>
<tr> <tr>
<th scope="row">Indoor temp:</th> <th scope="row">Indoor temp:</th>
<td><b class="indoor-temp"></b> C</td> <td><b class="indoor-temp"></b> <span class="unit-system"></span></td>
</tr> </tr>
<tr> <tr>
<th scope="row">Outdoor temp:</th> <th scope="row">Outdoor temp:</th>
<td><b class="outdoor-temp"></b> C</td> <td><b class="outdoor-temp"></b> <span class="unit-system"></span></td>
</tr> </tr>
<tr> <tr>
<th scope="row">Heating temp:</th> <th scope="row">Heating temp:</th>
<td><b class="heating-temp"></b> C</td> <td><b class="heating-temp"></b> <span class="unit-system"></span></td>
</tr> </tr>
<tr> <tr>
<th scope="row">Heating setpoint temp:</th> <th scope="row">Heating setpoint temp:</th>
<td><b class="heating-setpoint-temp"></b> C</td> <td><b class="heating-setpoint-temp"></b> <span class="unit-system"></span></td>
</tr>
<tr>
<th scope="row">Heating return temp:</th>
<td><b class="heating-return-temp"></b> <span class="unit-system"></span></td>
</tr> </tr>
<tr> <tr>
<th scope="row">DHW temp:</th> <th scope="row">DHW temp:</th>
<td><b class="dhw-temp"></b> C</td> <td><b class="dhw-temp"></b> <span class="unit-system"></span></td>
</tr>
<tr>
<th scope="row">Exhaust temp:</th>
<td><b class="exhaust-temp"></b> <span class="unit-system"></span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

Binary file not shown.

View File

@@ -387,7 +387,8 @@ protected:
bool published = false; bool published = false;
bool isStupidMode = !settings.pid.enable && !settings.equitherm.enable; bool isStupidMode = !settings.pid.enable && !settings.equitherm.enable;
byte heatingMinTemp, heatingMaxTemp = 0; byte heatingMinTemp = 0;
byte heatingMaxTemp = 0;
bool editableOutdoorTemp = settings.sensors.outdoor.type == SensorType::MANUAL; bool editableOutdoorTemp = settings.sensors.outdoor.type == SensorType::MANUAL;
bool editableIndoorTemp = settings.sensors.indoor.type == SensorType::MANUAL; bool editableIndoorTemp = settings.sensors.indoor.type == SensorType::MANUAL;

View File

@@ -484,6 +484,7 @@ async function loadSettings() {
setCheckboxValue('.system-debug', result.system.debug); setCheckboxValue('.system-debug', result.system.debug);
setCheckboxValue('.system-use-serial', result.system.useSerial); setCheckboxValue('.system-use-serial', result.system.useSerial);
setCheckboxValue('.system-use-telnet', result.system.useTelnet); setCheckboxValue('.system-use-telnet', result.system.useTelnet);
setRadioValue('.system-unit-system', result.system.unitSystem);
setBusy('#system-settings-busy', '#system-settings', false); setBusy('#system-settings-busy', '#system-settings', false);
setCheckboxValue('.portal-use-auth', result.portal.useAuth); setCheckboxValue('.portal-use-auth', result.portal.useAuth);
@@ -491,6 +492,7 @@ async function loadSettings() {
setInputValue('.portal-password', result.portal.password); setInputValue('.portal-password', result.portal.password);
setBusy('#portal-settings-busy', '#portal-settings', false); setBusy('#portal-settings-busy', '#portal-settings', false);
setRadioValue('.opentherm-unit-system', result.opentherm.unitSystem);
setInputValue('.opentherm-in-gpio', result.opentherm.inGpio < 255 ? result.opentherm.inGpio : ''); setInputValue('.opentherm-in-gpio', result.opentherm.inGpio < 255 ? result.opentherm.inGpio : '');
setInputValue('.opentherm-out-gpio', result.opentherm.outGpio < 255 ? result.opentherm.outGpio : ''); setInputValue('.opentherm-out-gpio', result.opentherm.outGpio < 255 ? result.opentherm.outGpio : '');
setInputValue('.opentherm-member-id-code', result.opentherm.memberIdCode); setInputValue('.opentherm-member-id-code', result.opentherm.memberIdCode);
@@ -534,6 +536,21 @@ async function loadVars() {
let response = await fetch('/api/vars'); let response = await fetch('/api/vars');
let result = await response.json(); let result = await response.json();
let unitSystemStr;
switch (result.system.unitSystem) {
case 0:
unitSystemStr = 'C';
break;
case 1:
unitSystemStr = 'F';
break;
default:
unitSystemStr = '?';
break;
}
setState('.ot-connected', result.states.otStatus); setState('.ot-connected', result.states.otStatus);
setState('.ot-emergency', result.states.emergency); setState('.ot-emergency', result.states.emergency);
setState('.ot-heating', result.states.heating); setState('.ot-heating', result.states.heating);
@@ -552,10 +569,13 @@ async function loadVars() {
setValue('.outdoor-temp', result.temperatures.outdoor); setValue('.outdoor-temp', result.temperatures.outdoor);
setValue('.heating-temp', result.temperatures.heating); setValue('.heating-temp', result.temperatures.heating);
setValue('.heating-setpoint-temp', result.parameters.heatingSetpoint); setValue('.heating-setpoint-temp', result.parameters.heatingSetpoint);
setValue('.heating-return-temp', result.temperatures.heatingReturn);
setValue('.dhw-temp', result.temperatures.dhw); setValue('.dhw-temp', result.temperatures.dhw);
setValue('.exhaust-temp', result.temperatures.exhaust);
setBusy('.ot-busy', '.ot-table', false); setBusy('.ot-busy', '.ot-table', false);
setValue('.unit-system', unitSystemStr);
setValue('.version', result.system.version); setValue('.version', result.system.version);
setValue('.build-date', result.system.buildDate); setValue('.build-date', result.system.buildDate);
setValue('.uptime', result.system.uptime); setValue('.uptime', result.system.uptime);
@@ -601,12 +621,14 @@ function setState(selector, value) {
} }
function setValue(selector, value) { function setValue(selector, value) {
let item = document.querySelector(selector); let items = document.querySelectorAll(selector);
if (!item) { if (!items.length) {
return; return;
} }
item.innerHTML = value; for (let item of items) {
item.innerHTML = value;
}
} }
function setCheckboxValue(selector, value) { function setCheckboxValue(selector, value) {