From 7a9947bc0c5a2decba05ae4d78dee3ff634260cf Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Wed, 19 Oct 2022 17:49:14 +0200 Subject: [PATCH] fix --- examples/mqtt.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index b49335e..7a70883 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -94,7 +94,11 @@ def on_connect(client, userdata, flags, rc): print("Failed to connect, return code %d\n", rc) def on_message(client, userdata, msg): - + global value_pvProduction + global value_wHouseConsumption + global value_energyImportExport + global value_houseBatterySoC + global value_houseBatteryLoadUnload if msg.topic == "openWB/pv/W": value_pvProduction = ""+msg.payload.decode() @@ -125,17 +129,6 @@ client = mqtt_client.Client(client_id, protocol=paho.MQTTv31) client.username_pw_set(username, password=pw) client.on_connect = on_connect -global value_pvProduction -global value_wHouseConsumption -global value_energyImportExport -global value_houseBatterySoC -global value_houseBatteryLoadUnload -value_pvProduction = "" -value_wHouseConsumption = "" -value_energyImportExport = "" -value_houseBatterySoC = "" -value_houseBatteryLoadUnload = "" - client.on_message = on_message client.connect(broker, port=port)