mqtt test v4.3 (with web)
This commit is contained in:
@@ -18,6 +18,7 @@ def fetch_command():
|
|||||||
@esp.route('/toggle-machine', methods=['POST'])
|
@esp.route('/toggle-machine', methods=['POST'])
|
||||||
def toggle_machine():
|
def toggle_machine():
|
||||||
pCd = shared.pending_command
|
pCd = shared.pending_command
|
||||||
|
shared.reset_command()
|
||||||
pCd['command'] = 'machineToggle'
|
pCd['command'] = 'machineToggle'
|
||||||
pCd['command-URL'] = 'NO_URL'
|
pCd['command-URL'] = 'NO_URL'
|
||||||
pCd['command-expected'] = 'machineStatusResponse'
|
pCd['command-expected'] = 'machineStatusResponse'
|
||||||
|
|||||||
@@ -80,7 +80,12 @@
|
|||||||
fetch('/unsecure/esp/toggle-machine', { method: 'POST' })
|
fetch('/unsecure/esp/toggle-machine', { method: 'POST' })
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.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>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user