From f3ce1ea06695480b79efae8f5a6f528e60d46e4b Mon Sep 17 00:00:00 2001 From: derlole <122916573+derlole@users.noreply.github.com> Date: Fri, 25 Apr 2025 10:55:02 +0000 Subject: [PATCH] mqtt test v4.3 (with web) --- routes/esp_routes.py | 1 + templates/index.html | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/routes/esp_routes.py b/routes/esp_routes.py index 1376955..d28c29c 100644 --- a/routes/esp_routes.py +++ b/routes/esp_routes.py @@ -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' diff --git a/templates/index.html b/templates/index.html index 2efc449..03ff30b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -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"; + } }); }