|
@@ -158,10 +158,12 @@
|
|
|
<li><a href="https://jomjol.github.io/AI-on-the-edge-device-docs/" target="_blank">Help</a></li>
|
|
<li><a href="https://jomjol.github.io/AI-on-the-edge-device-docs/" target="_blank">Help</a></li>
|
|
|
</ul>
|
|
</ul>
|
|
|
</li>
|
|
</li>
|
|
|
- <li id="ManualControl" style="display:none;"><a>Manual Control <i class="arrow down"></i></a> <!-- Workaround: Hide menu if no entry is available -->
|
|
|
|
|
|
|
+ <li id="ManualControl"><a>Manual Control <i class="arrow down"></i></a>
|
|
|
<ul class="submenu" style="width: 300px">
|
|
<ul class="submenu" style="width: 300px">
|
|
|
- <li><a href="#" onclick="flow_start()">Start Round</a></li>
|
|
|
|
|
- <li id="HASendDiscovery" style="width: 300px" style="display:none;"><a href="#" onclick="HA_send_discovery()">Resend Homeassistant Discovery</a></li>
|
|
|
|
|
|
|
+ <li><a href="#" onclick="flow_pause()">Pause after current round</a></li>
|
|
|
|
|
+ <li><a href="#" onclick="flow_resume()">Resume automatic flow</a></li>
|
|
|
|
|
+ <li><a href="#" onclick="flow_start()">Start one round now</a></li>
|
|
|
|
|
+ <li id="HASendDiscovery" style="width: 300px; display:none;"><a href="#" onclick="HA_send_discovery()">Resend Homeassistant Discovery</a></li>
|
|
|
</ul>
|
|
</ul>
|
|
|
</li>
|
|
</li>
|
|
|
</ul>
|
|
</ul>
|
|
@@ -206,26 +208,29 @@
|
|
|
document.getElementById('maincontent').src = getCookie("page");
|
|
document.getElementById('maincontent').src = getCookie("page");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ function call_flow_control(endpoint) {
|
|
|
|
|
+ var xhttp = new XMLHttpRequest();
|
|
|
|
|
+ xhttp.onreadystatechange = function() {
|
|
|
|
|
+ if (this.readyState == 4) {
|
|
|
|
|
+ var okay = this.status >= 200 && this.status < 300;
|
|
|
|
|
+ firework.launch(xhttp.responseText || (okay ? "Flow command accepted" : "Flow command failed"),
|
|
|
|
|
+ okay ? "success" : "danger", 5000);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ xhttp.open("GET", getDomainname() + endpoint, true);
|
|
|
|
|
+ xhttp.send();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function flow_start() {
|
|
function flow_start() {
|
|
|
- var url = getDomainname() + '/flow_start';
|
|
|
|
|
- var xhttp = new XMLHttpRequest();
|
|
|
|
|
- xhttp.onreadystatechange = function() {
|
|
|
|
|
- if (this.readyState == 4 && this.status == 200) {
|
|
|
|
|
- firework.launch(xhttp.responseText, 'success', 5000);
|
|
|
|
|
- /*if (xhttp.responseText.substring(0,3) == "001") {
|
|
|
|
|
- firework.launch('Flow start triggered', 'success', 5000);
|
|
|
|
|
- window.location.reload();
|
|
|
|
|
- }
|
|
|
|
|
- else if (xhttp.responseText.substring(0,3) == "002") {
|
|
|
|
|
- firework.launch('Flow start scheduled. Start after round is completed', 'success', 5000);
|
|
|
|
|
- }
|
|
|
|
|
- else if (xhttp.responseText.substring(0,3) == "099") {
|
|
|
|
|
- firework.launch('Flow start triggered, but start not possible (no flow task available)', 'danger', 5000);
|
|
|
|
|
- }*/
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- xhttp.open("GET", url, true);
|
|
|
|
|
- xhttp.send();
|
|
|
|
|
|
|
+ call_flow_control('/flow_start');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function flow_pause() {
|
|
|
|
|
+ call_flow_control('/flow_pause');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function flow_resume() {
|
|
|
|
|
+ call_flow_control('/flow_resume');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -236,7 +241,6 @@
|
|
|
param = getConfigParameters();
|
|
param = getConfigParameters();
|
|
|
|
|
|
|
|
if (category["MQTT"]["enabled"] && param["MQTT"]["HomeassistantDiscovery"].value1 == "true") {
|
|
if (category["MQTT"]["enabled"] && param["MQTT"]["HomeassistantDiscovery"].value1 == "true") {
|
|
|
- document.getElementById("ManualControl").style.display="";
|
|
|
|
|
document.getElementById("HASendDiscovery").style.display="";
|
|
document.getElementById("HASendDiscovery").style.display="";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|