confmqtt 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-T5WZ</title>
  5. <script>
  6. function g(i) { return document.getElementById(i) };
  7. function sp(i){g(i).type=(g(i).type==='text'?'password':'text');}
  8. var xhttp, reqTime, reqFin;
  9. function setCbx(el, da) {
  10. if(da == '1') {
  11. el.checked = true;
  12. el.style.visibility = 'visible';
  13. }
  14. else {
  15. el.checked = false;
  16. el.style.visibility = 'visible';
  17. }
  18. }
  19. function updCbxVal(el) {
  20. if (el.checked) el.value = '1';
  21. else {
  22. el.checked = true;
  23. el.value = '0';
  24. el.style.visibility = 'hidden';
  25. }
  26. }
  27. function transmit(f) {
  28. if (!xhttp) {
  29. reqTime = 0;
  30. reqFin = false;
  31. updCbxVal(g('mqttEnable'));
  32. updCbxVal(g('outRet'));
  33. updCbxVal(g('outRetSens'));
  34. updCbxVal(g('willRet'));
  35. updCbxVal(g('hbEnable'));
  36. xhttp = new XMLHttpRequest();
  37. xhttp.timeout = 1000;
  38. xhttp.overrideMimeType('application/json');
  39. xhttp.open('POST', 'confDataMqtt');
  40. xhttp.send(f ? (new FormData(f)) : '');
  41. xhttp.onreadystatechange = function () {
  42. if (xhttp.readyState === XMLHttpRequest.DONE && xhttp.status === 200) {
  43. var data = JSON.parse(xhttp.responseText);
  44. setCbx(g('mqttEnable'), data.mqttEnable);
  45. g('mqttHost').value = data.mqttHost;
  46. g('mqttPort').value = data.mqttPort;
  47. g('mqttUser').value = data.mqttUser;
  48. g('mqttPass').value = data.mqttPass;
  49. g('inTop').value = data.inTop;
  50. g('outTop').value = data.outTop;
  51. g('willTop').value = data.willTop;
  52. g('willQos').value = data.willQos;
  53. setCbx(g('outRet'), data.outRet);
  54. setCbx(g('outRetSens'), data.outRetSens);
  55. g('outPubInt').value = data.outPubInt;
  56. g('outPubIntSens').value = data.outPubIntSens;
  57. setCbx(g('willRet'), data.willRet);
  58. g('willMsg').value = data.willMsg;
  59. g('connMsg').value = data.connMsg;
  60. setCbx(g('hbEnable'), data.hbEnable);
  61. g('hbReconn').value = data.hbReconn;
  62. g('hbReboot').value = data.hbReboot;
  63. xhttp = null;
  64. reqFin = true;
  65. }
  66. else {
  67. if(!reqFin && reqTime > 10) {
  68. xhttp = null;
  69. reqFin = true;
  70. }
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. //transmit();
  77. function saveConf() {
  78. updCbxVal(g('mqttEnable'));
  79. updCbxVal(g('outRet'));
  80. updCbxVal(g('outRetSens'));
  81. updCbxVal(g('willRet'));
  82. updCbxVal(g('hbEnable'));
  83. g('frmConf').submit();
  84. }
  85. function init() {
  86. transmit();
  87. setCbx(g('mqttPassSet'), 0);
  88. }
  89. setInterval(function () { ++reqTime; }, 1000);
  90. </script>
  91. </head>
  92. <body onload='init()'>
  93. <div id='main'>
  94. <div id='head'>WiFiThermostat - WTherm-T5WZ
  95. </div><hr>
  96. <div></div>
  97. <b>Configuration - MQTT</b>
  98. <div class='config'>
  99. <form id='frmConf' action='setConfMqtt' method='POST'>
  100. <br>
  101. <p><b>Enable MQTT *</b>&nbsp;<input type='checkbox' name='mqttEnable' id='mqttEnable'></p>
  102. <fieldset>
  103. <legend>Broker Connection</legend>
  104. <p><b>Hostname *</b><br><input type='text' name='mqttHost' id='mqttHost'></p>
  105. <p><b>Port *</b><br><input type='number' name='mqttPort' id='mqttPort'></p>
  106. <p><b>User *</b><br><input type='text' name='mqttUser' id='mqttUser'></p>
  107. <p><b>Password *</b><input type='checkbox' id='mqttPassSet' name='mqttPassSet' onclick='sp("mqttPass")'><br><input type='password' name='mqttPass' id='mqttPass'></p>
  108. </fieldset>
  109. <br>
  110. <fieldset>
  111. <legend>Last Will</legend>
  112. <p><b>Topic *</b><br><input type='text' name='willTop' id='willTop'></p>
  113. <p><b>Qos *</b><br><select name='willQos' id='willQos'><option>0</option><option>1</option><option selected='selected'>2</option></select></p>
  114. <p><b>Retain-Flag *</b>&nbsp;<input type='checkbox' name='willRet' id='willRet'></p>
  115. <p><b>Last Will Message *</b><br><input type='text' name='willMsg' id='willMsg'></p>
  116. <p><b>Connect Message *</b><br><input type='text' name='connMsg' id='connMsg'></p>
  117. </fieldset>
  118. <br>
  119. <fieldset>
  120. <legend>Base Topics</legend>
  121. <p><b>Base In-Topic *</b><br><input type='text' name='inTop' id='inTop'></p>
  122. <p class='n'>* Sub-Topics like cmd... are added automatically.</p>
  123. <div></div>
  124. <p><b>Out/State-Topic **</b><br><input type='text' name='outTop' id='outTop'></p>
  125. <p class='n'>** default output topic. Sub-Topics are added automatically.</p>
  126. <p><b>Retain (States) *</b>&nbsp;<input type='checkbox' name='outRet' id='outRet'></p>
  127. <p><b>Retain (Sensors) *</b>&nbsp;<input type='checkbox' name='outRetSens' id='outRetSens'></p>
  128. <p class='n'>* If Retain is enabled, data is only sent on change, <br>
  129. otherwise in intervals additionally. <br>
  130. Intervals can also be switched off without retain. <br>
  131. Just set them to 0 to disable.</p>
  132. <p><b>Interval States **</b><br><input type='number' name='outPubInt' id='outPubInt'></p>
  133. <p><b>Interval Sensors **</b><br><input type='number' name='outPubIntSens' id='outPubIntSens'></p>
  134. <p class='n'>** 0 to disable</p>
  135. </fieldset>
  136. <br>
  137. <fieldset>
  138. <legend>Heartbeat</legend>
  139. <p><b>Enable Heartbeat *</b>&nbsp;<input type='checkbox' name='hbEnable' id='hbEnable'></p>
  140. <div></div><div></div>
  141. <p class='n'>on missing Heartbeat:</p>
  142. <p><b>Reconnect after [min]</b><br><input type='text' name='hbReconn' id='hbReconn'></p>
  143. <p><b>Reboot after [min]</b><br><input type='text' name='hbReboot' id='hbReboot'></p>
  144. </fieldset>
  145. <div></div>
  146. </form>
  147. <div></div>
  148. <table style='width:100%'>
  149. <td style='width:50%'><button onclick='location="conf";' class='bgrey'>Cancel</button></td>
  150. <td style='width:50%'><button onclick='return saveConf()' class='bred'>Save &amp; Restart</button></td>
  151. </tr></table>
  152. </div>
  153. <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> v0.6.0 by <a href='https://www.flokra.at/' target='_blank' style='color:#AAA;'>FloKra</a></div>
  154. </div></body></html>