This commit is contained in:
Robert Borzutzki 2022-10-19 17:46:36 +02:00
parent d485016a39
commit 201f835aa7

View File

@ -94,16 +94,7 @@ 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
value_pvProduction = ""
value_wHouseConsumption = ""
value_energyImportExport = ""
value_houseBatterySoC = ""
value_houseBatteryLoadUnload = ""
if msg.topic == "openWB/pv/W": if msg.topic == "openWB/pv/W":
value_pvProduction = ""+msg.payload.decode() value_pvProduction = ""+msg.payload.decode()
@ -133,6 +124,18 @@ def on_message(client, userdata, msg):
client = mqtt_client.Client(client_id, protocol=paho.MQTTv31) 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)