From 6f77bf000b43dfd67baeb274ba65648ce65ed40e Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Wed, 19 Oct 2022 09:07:32 +0200 Subject: [PATCH] add multiple topics --- examples/mqtt.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index b0c6990..e467aef 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -36,7 +36,12 @@ Connected = False #global variable for the state of the connection broker = "192.168.99.224" port = 1883 -topic = "openWB/evu/W" +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" @@ -53,7 +58,11 @@ client.loop_start() #start the loop while Connected != True: #Wait for connection time.sleep(1) -client.subscribe(topic) +client.subscribe(topic_wHouseConsumption) +client.subscribe(topic_pvProduction) +client.subscribe(topic_energyImportExport) +client.subscribe(topic_houseBatterySoC) +client.subscribe(topic_wHouseCtopic_houseBatteryLoadUnloadonsumption) try: while True: