aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-12-11 12:29:45 +0100
committerKarel Kočí <cynerd@email.cz>2022-12-11 12:32:47 +0100
commite14472f3f5e12774b5b185a718591ef8e5cfe00f (patch)
tree9619a15fc92d628ec0176cb9020e52991e43d35b
parentebcd89846d987a311459cf06397762531464e169 (diff)
downloadbigclown-leds-e14472f3f5e12774b5b185a718591ef8e5cfe00f.tar.gz
bigclown-leds-e14472f3f5e12774b5b185a718591ef8e5cfe00f.tar.bz2
bigclown-leds-e14472f3f5e12774b5b185a718591ef8e5cfe00f.zip
Authenticate to MQTT
-rwxr-xr-xbigclown-leds8
1 files changed, 8 insertions, 0 deletions
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()