From e14472f3f5e12774b5b185a718591ef8e5cfe00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 11 Dec 2022 12:29:45 +0100 Subject: Authenticate to MQTT --- bigclown-leds | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bigclown-leds b/bigclown-leds index 516515e..4d635fc 100755 --- a/bigclown-leds +++ b/bigclown-leds @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +import configparser +import sys + import paho.mqtt.client as mqtt @@ -27,11 +30,16 @@ def on_message(client, userdata, msg): def main(): + cnf = configparser.ConfigParser() + cnf.read(sys.argv[1]) + cnf_mqtt = cnf["mqtt"] + client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message # client.on_log = on_log + client.username_pw_set(cnf_mqtt["username"], cnf_mqtt["password"]) client.connect("127.0.0.1", 1883, 60) client.loop_forever() -- cgit v1.2.3