index 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <html><head>
  2. <meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>
  3. <link rel='stylesheet' href='style.css'>
  4. <title>WiFiThermostat - WTherm-3598</title>
  5. <script>
  6. function g(i) { return document.getElementById(i) };
  7. var xhttp, updateTime, reqTime, reqFin;
  8. function sendBtn(btn, conf) {
  9. var frmn='BtnFrm'+btn;
  10. var form = g(frmn);
  11. if(conf !== undefined) {
  12. if(confirm(conf)) return transmit(form);
  13. else return false;
  14. }
  15. else return transmit(form);
  16. }
  17. function transmit(f) {
  18. if (!xhttp) {
  19. reqTime = 0;
  20. reqFin = false;
  21. xhttp = new XMLHttpRequest();
  22. xhttp.timeout = 1000;
  23. xhttp.overrideMimeType("application/json");
  24. xhttp.open('POST', 'api');
  25. xhttp.send(f ? (new FormData(f)) : '');
  26. xhttp.onreadystatechange = function () {
  27. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  28. var data = JSON.parse(xhttp.responseText);
  29. if(data.setTemp !== undefined) g('setTemp').innerHTML = data.setTemp.toFixed(1) + '&deg;';
  30. if(data.currSetTemp !== undefined) g('currSetTemp').innerHTML = data.currSetTemp.toFixed(1) + '&deg;';
  31. if(data.psetName !== undefined) g('pset').innerHTML = data.psetName.toUpperCase();
  32. if(data.psetName0 !== undefined) g('btnPs0').innerHTML = data.psetName0;
  33. if(data.psetName1 !== undefined) g('btnPs1').innerHTML = data.psetName1;
  34. if(data.psetName2 !== undefined) g('btnPs2').innerHTML = data.psetName2;
  35. if(data.temp !== undefined && data.hum !== undefined) g('currTempHum').innerHTML = data.temp.toFixed(1) + '&deg;&nbsp;&nbsp;&nbsp;' + data.hum.toFixed(0) + '%';
  36. else if(data.temp !== undefined) g('currTempHum').innerHTML = data.temp.toFixed(1) + '&deg;';
  37. if(data.outTemp !== undefined && data.outHum !== undefined) g('outTempHum').innerHTML = data.outTemp.toFixed(1) + '&deg;&nbsp;&nbsp;&nbsp;' + data.outHum.toFixed(0) + '%';
  38. else if(data.outTemp !== undefined) g('outTempHum').innerHTML = data.outTemp.toFixed(1) + '&deg;';
  39. if(data.modeName !== undefined) g('mode').innerHTML = data.modeName.toUpperCase();
  40. if(data.mode == '1') { g('btnModeOn').setAttribute('class', ''); g('btnModeOff').setAttribute('class', 'bgrey');}
  41. else { g('btnModeOn').setAttribute('class', 'bgrey'); g('btnModeOff').setAttribute('class', '');}
  42. if(data.pset == '0') { g('btnPs0').setAttribute('class', ''); g('btnPs1').setAttribute('class', 'bgrey'); g('btnPs2').setAttribute('class', 'bgrey');}
  43. else if(data.pset == '1') {g('btnPs0').setAttribute('class', 'bgrey'); g('btnPs1').setAttribute('class', ''); g('btnPs2').setAttribute('class', 'bgrey');}
  44. else if(data.pset == '2') {g('btnPs0').setAttribute('class', 'bgrey'); g('btnPs1').setAttribute('class', 'bgrey'); g('btnPs2').setAttribute('class', ''); }
  45. if(data.heating == '1' && data.mode == '1') { g('heating').innerHTML = 'HEATING'; g('heating').style = 'color:red;'; }
  46. else if(data.heating == '0' && data.mode == '1') { g('heating').innerHTML = 'IDLE'; g('heating').style = 'color:#1fa3ec;'; }
  47. else if(data.mode == '0') { g('heating').innerHTML = 'OFF'; g('heating').style = 'color:black;'; }
  48. var APname;
  49. if(data.WiFiNum == 1) APname='Default';
  50. else if(data.WiFiNum == 1) APname='Fallback';
  51. if(data.ssid !== undefined && data.WiFiNum !== undefined && data.WiFiNum > 0) g('ssid').innerHTML = data.ssid + ' (' + APname + '-AP)';
  52. else if(data.ssid !== undefined) g('ssid').innerHTML = data.ssid;
  53. if(data.mqttstate !== undefined) {
  54. if(data.mqttstate == "CONNECTED") { g('mqttstate').innerHTML = data.mqttstate + ' to <i>' + data.mqtthost + '</i>'; }
  55. else g('mqttstate').innerHTML = data.mqttstate;
  56. }
  57. if(data.uptime !== undefined) g('uptime').innerHTML = data.uptime;
  58. if(data.date !== undefined) g('date').innerHTML = data.date;
  59. else g('date').innerHTML = 'NTP disabled';
  60. if(data.time !== undefined) g('time').innerHTML = data.time;
  61. else g('time').innerHTML = 'NTP disabled';
  62. if(data.mqttreconn !== undefined) g('mqttreconn').innerHTML = data.mqttreconn;
  63. xhttp = null;
  64. updateTime = 0;
  65. reqFin = true;
  66. }
  67. else {
  68. if(!reqFin && reqTime > 10) {
  69. xhttp = null;
  70. reqFin = true;
  71. }
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. function init() {
  78. transmit();
  79. }
  80. setInterval(transmit, 2500);
  81. </script>
  82. </head>
  83. <body onload='init()'>
  84. <div id='main'>
  85. <div id='head'>WiFiThermostat - WTherm-3598
  86. </div><hr>
  87. <div></div>
  88. <p><b>Temperature</b></p>
  89. <div id='setTemp' style='text-align:center;font-weight:bold;font-size:40px'></div>
  90. <div></div>
  91. <table style='width:100%'><tr>
  92. <td style='width:50%'><form id='BtnFrmMinus'><input type='hidden' name='BtnMinus' value='1'><button onclick='return sendBtn("Minus")'>-</button></form></td>
  93. <td style='width:50%'><form id='BtnFrmPlus'><input type='hidden' name='BtnPlus' value='1'><button onclick='return sendBtn("Plus")'>+</button></form></td>
  94. </tr></table>
  95. <table style='width:100%'>
  96. <tr><td style='width:50%'>Current Temp/Hum </td><td><b><span id='currTempHum'></span></td></tr>
  97. <tr><td>Outside Temp/Hum </td><td><b><span id='outTempHum'></span></td></tr>
  98. <tr><td>Actual set Temp </td><td><b><span id='currSetTemp'></span></b></td></tr>
  99. <tr><td>Heating State </td><td><b><span id='heating'></span></b></td></tr>
  100. </table>
  101. <div></div>
  102. <div></div>
  103. <p><b>Preset</b></p>
  104. <div id='pset' style='text-align:center;font-weight:bold;font-size:20px'></div>
  105. <div></div>
  106. <form id='BtnFrmPset0'><input type='hidden' name='BtnPset0' value='1'><button id='btnPs0' onclick='return sendBtn("Pset0")'>NORMAL</button></form>
  107. <form id='BtnFrmPset1'><input type='hidden' name='BtnPset1' value='1'><button id='btnPs1' onclick='return sendBtn("Pset1")'>REDUCTION 1</button></form>
  108. <form id='BtnFrmPset2'><input type='hidden' name='BtnPset2' value='1'><button id='btnPs2' onclick='return sendBtn("Pset2")'>REDUCTION 2</button></form>
  109. <div></div>
  110. <div></div>
  111. <div></div>
  112. <form action='redTemps' method='GET'><button>Set Reduction Temps</button></form>
  113. <div></div>
  114. <p><b>Mode</b></p>
  115. <div id='mode' style='text-align:center;font-weight:bold;font-size:20px'></div>
  116. <div></div>
  117. <table style='width:100%'><tr>
  118. <td style='width:50%'><form id='BtnFrmOn'><input type='hidden' name='BtnOn' value='1'><button id='btnModeOn' onclick='return sendBtn("On")'>HEAT</button></form></td>
  119. <td style='width:50%'><form id='BtnFrmOff'><input type='hidden' name='BtnOff' value='1'><button id='btnModeOff' onclick='return sendBtn("Off")'>OFF</button></form></td>
  120. </tr></table>
  121. <hr>
  122. <div></div>
  123. <p><b>System</b></p>
  124. <table style='width:100%'>
  125. <tr><td colspan=3>WiFi connected to <i><span id='ssid'></span></i></tr></td>
  126. <tr><td colspan=3>MQTT <span id='mqttstate'></span></tr></td>
  127. <tr><td colspan=3>MQTT reconnects: <span id='mqttreconn'></span></tr></td>
  128. <tr><td>Uptime</td><td><span id='uptime'></span></td></tr>
  129. <tr><td>Date</td><td><span id='date'></span></td></tr>
  130. <tr><td>Time</td><td><span id='time'></span></td></tr>
  131. </table>
  132. <br>
  133. <table style='width:100%'>
  134. <tr><td style='width:100%'><form action='conf' method='get'><button>Configuration</button></form></td></tr>
  135. <tr><td style='width:100%'><form action='console' method='get'><button>Web Console</button></form></td></tr>
  136. <tr><td style='width:100%'><form action='wsconsole' method='get'><button>WebSockets Console</button></form></td></tr>
  137. <tr><td style='width:100%'><form action='/' method='get' onsubmit='return confirm("Confirm Restart");'><button name='restart' class='bred'>Restart</button></form></td></tr>
  138. </table>
  139. <div style='text-align:right;font-size:0.7em;color:#AAA;'><hr/><a href='https://git.flokra.at/flo/WiFiThermostat' target='_blank' style='color:#AAA;'>WiFiThermostat</a> 0.6.1 by <a href='https://www.flokra.at/' target='_blank' style='color:#AAA;'>FloKra</a></div>
  140. </div></body></html>