From b561663aba8c69b30ff14fb985df4cbf28ef0e6a Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 29 Mar 2023 21:20:40 +0200 Subject: adding user/pass for mqtt, made a service for neohub --- scripts/mqtt_watch.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts/mqtt_watch.py') diff --git a/scripts/mqtt_watch.py b/scripts/mqtt_watch.py index 371debd..d61ecc0 100644 --- a/scripts/mqtt_watch.py +++ b/scripts/mqtt_watch.py @@ -11,6 +11,8 @@ mqtt_server = os.environ['el_mqtt_server'] mqtt_port = int(os.environ['el_mqtt_port']) keepalive = int(os.environ['el_mqtt_keepalive']) mqtt_topic = os.environ['el_mqtt_topic'] +mqtt_user = os.environ['el_mqtt_user'] +mqtt_pass = os.environ['el_mqtt_pass'] # The callback for when the client receives a CONNACK response from the server. def on_connect(client, userdata, flags, rc): @@ -45,6 +47,8 @@ client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message +client.username_pw_set(mqtt_user, password=mqtt_pass) + client.connect(mqtt_server, mqtt_port, keepalive) # Blocking call that processes network traffic, dispatches callbacks and -- cgit v1.2.3