From b35db8e68dd696dfdb91129a6e29c363cf49b773 Mon Sep 17 00:00:00 2001 From: Pavel Sklenar Date: Mon, 11 Mar 2024 07:55:53 +0100 Subject: [PATCH] fixed --- mqtt-switch2.py | 4 +++- templates/switch_control.html | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mqtt-switch2.py b/mqtt-switch2.py index c203150..d2c72c3 100644 --- a/mqtt-switch2.py +++ b/mqtt-switch2.py @@ -174,9 +174,10 @@ def health_check(): @app.route('/control', methods=['GET']) def control_page(): + global manual_control, last_call state = 'ON' if switch.is_lit else 'OFF' manual_control_state = 'ON' if manual_control else 'OFF' - return render_template('switch_control.html', state=state, manual_control=manual_control_state) + return render_template('switch_control.html', state=state, manual_control=manual_control_state, last_call=last_call) @app.route('/switch/', methods=['POST']) def change_switch(state): @@ -192,6 +193,7 @@ def change_switch(state): @app.route('/mode/', methods=['POST']) def change_mode(state): + global manual_control if state == 'ON': manual_control = True elif state == 'OFF': diff --git a/templates/switch_control.html b/templates/switch_control.html index 68d089e..8b65e86 100644 --- a/templates/switch_control.html +++ b/templates/switch_control.html @@ -15,6 +15,7 @@

Manual mode switch

Current State: {{ manual_control }}

+

Last Call from MQTT: {{ last_call }}