aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mqtt_watch.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-03-29 21:20:40 +0200
committerDennis Eriksen <d@ennis.no>2023-03-29 21:20:44 +0200
commitb561663aba8c69b30ff14fb985df4cbf28ef0e6a (patch)
tree67e7e50f7310e27114e03af08f15a40e89409e73 /scripts/mqtt_watch.py
parententsoe has new api-url (diff)
downloadenergyscripts-b561663aba8c69b30ff14fb985df4cbf28ef0e6a.tar.gz
adding user/pass for mqtt, made a service for neohub
Diffstat (limited to 'scripts/mqtt_watch.py')
-rw-r--r--scripts/mqtt_watch.py4
1 files changed, 4 insertions, 0 deletions
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