From d067c2344c69c18004dd1f95236e3aedc80b80ac Mon Sep 17 00:00:00 2001 From: NilsGrunwald Date: Sun, 2 Oct 2022 18:53:54 +0200 Subject: [PATCH] Added reconnect --- web2mqtt/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web2mqtt/views.py b/web2mqtt/views.py index d7942bd..997e469 100644 --- a/web2mqtt/views.py +++ b/web2mqtt/views.py @@ -39,6 +39,9 @@ def command(): if request.args.get('opts'): opts = request.args.get('opts') + if not client.is_connected(): + print("reconnection to mqtt server...") + client.connect("192.168.178.76",1884,keepalive=60) client.publish(command,opts) content = f"Command: {command} triggered with opts: {opts}"