From 2366aa7214c051a32f2a5784a38d49842a468dff Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Tue, 23 Jul 2024 19:42:24 +0200 Subject: [PATCH] update script --- mqtt2log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mqtt2log.py b/mqtt2log.py index 557d501..9f4986a 100755 --- a/mqtt2log.py +++ b/mqtt2log.py @@ -40,7 +40,7 @@ def write2file(msg): def on_message(client, userdata, msg): """The callback for when a PUBLISH message is received from the server.""" - #print(msg.topic + ' ' + str(msg.payload)) + print(msg.topic + ' ' + str(msg.payload)) result = _parse_mqtt_message(msg.topic, msg.payload.decode('utf-8')) if result is None: print("Couldn't parse sensor data!") @@ -51,7 +51,7 @@ def on_message(client, userdata, msg): return def main(): - mqtt_client = mqtt.Client(MQTT_CLIENT_ID) + mqtt_client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1,MQTT_CLIENT_ID) mqtt_client.username_pw_set(MQTT_USER, MQTT_PASSWORD) mqtt_client.on_connect = on_connect mqtt_client.on_message = on_message