add multiple topics

This commit is contained in:
Robert Borzutzki 2022-10-19 09:07:32 +02:00
parent 2f2db95e80
commit 6f77bf000b

View File

@ -36,7 +36,12 @@ Connected = False #global variable for the state of the connection
broker = "192.168.99.224" broker = "192.168.99.224"
port = 1883 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" username = "mqtt-user"
pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP" pw = "phio6yiR9ohs1veeghu4WaeGhaiRi8he4EiWasheev4faeku8tohdiuthah7zahP"
client_id = "solarmonitor" client_id = "solarmonitor"
@ -53,7 +58,11 @@ client.loop_start() #start the loop
while Connected != True: #Wait for connection while Connected != True: #Wait for connection
time.sleep(1) 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: try:
while True: while True: