From aef8260f34f9578176e24e722f53c14ec59da5f5 Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Wed, 19 Oct 2022 16:46:39 +0200 Subject: [PATCH] fix --- examples/mqtt.py | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index f9e95b8..28e59a2 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -17,7 +17,25 @@ import paho.mqtt.client as paho logging.basicConfig(level=logging.DEBUG) -Connected = False +Connected = False #global variable for the state of the connection + +broker = "192.168.99.224" +port = 1883 +topic_wHouseConsumption = "openWB/global/WHouseConsumption" +topic_pvProduction = "openWB/pv/W" +topic_energyImportExport = "openWB/evu/W" +topic_houseBatterySoC = "openWB/housebattery/%Soc" +topic_houseBatteryLoadUnload = "openWB/housebattery/W" + +username = "mqtt-user" +pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP" +client_id = "solarmonitor" + +value_pvProduction = 0 +value_wHouseConsumption = 0 +value_energyImportExport = 0 +value_houseBatterySoC = 0 +value_houseBatteryLoadUnload = 0 try: logging.info("epd2in13bc Demo") @@ -93,26 +111,6 @@ def on_message(client, userdata, msg): epd.DisplayPartial(epd.getbuffer(HBlackimage)) #print(f"`{msg.topic}`: `{msg.payload.decode()}`") -Connected = False #global variable for the state of the connection - -broker = "192.168.99.224" -port = 1883 -topic_wHouseConsumption = "openWB/global/WHouseConsumption" -topic_pvProduction = "openWB/pv/W" -topic_energyImportExport = "openWB/evu/W" -topic_houseBatterySoC = "openWB/housebattery/%Soc" -topic_houseBatteryLoadUnload = "openWB/housebattery/W" - -value_pvProduction = 0 -value_wHouseConsumption = 0 -value_energyImportExport = 0 -value_houseBatterySoC = 0 -value_houseBatteryLoadUnload = 0 - -username = "mqtt-user" -pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP" -client_id = "solarmonitor" - client = mqtt_client.Client(client_id, protocol=paho.MQTTv31) client.username_pw_set(username, password=pw) client.on_connect = on_connect