This commit is contained in:
Robert Borzutzki 2022-10-19 17:49:14 +02:00
parent 201f835aa7
commit 7a9947bc0c

View File

@ -94,7 +94,11 @@ def on_connect(client, userdata, flags, rc):
print("Failed to connect, return code %d\n", rc) print("Failed to connect, return code %d\n", rc)
def on_message(client, userdata, msg): 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": if msg.topic == "openWB/pv/W":
value_pvProduction = ""+msg.payload.decode() 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.username_pw_set(username, password=pw)
client.on_connect = on_connect 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.on_message = on_message
client.connect(broker, port=port) client.connect(broker, port=port)