mqtt test v4.3 (with web)

This commit is contained in:
derlole
2025-04-25 10:55:02 +00:00
parent 2563876144
commit f3ce1ea066
2 changed files with 7 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ def fetch_command():
@esp.route('/toggle-machine', methods=['POST'])
def toggle_machine():
pCd = shared.pending_command
shared.reset_command()
pCd['command'] = 'machineToggle'
pCd['command-URL'] = 'NO_URL'
pCd['command-expected'] = 'machineStatusResponse'

View File

@@ -80,7 +80,12 @@
fetch('/unsecure/esp/toggle-machine', { method: 'POST' })
.then(res => res.json())
.then(data => {
document.getElementById("machine-status").innerText = data.status;
console.log(data);
if (data.command === 'machineToggle') {
document.getElementById("machine-status").innerText = "PENDING";
} else {
document.getElementById("machine-status").innerText = "SOME_ERR";
}
});
}
</script>