From b2506c6b23d37d7c4b9a5cf024be64defc7e80f4 Mon Sep 17 00:00:00 2001 From: Robert Borzutzki Date: Wed, 19 Oct 2022 10:48:51 +0200 Subject: [PATCH] add values --- examples/mqtt.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/mqtt.py b/examples/mqtt.py index b80ca55..3ce8e5b 100644 --- a/examples/mqtt.py +++ b/examples/mqtt.py @@ -66,13 +66,19 @@ def on_connect(client, userdata, flags, rc): print("Failed to connect, return code %d\n", rc) def on_message(client, userdata, msg): - drawblack.text((150, 0), '99', font = font10, fill = 0) - drawblack.text((150, 15), '99', font = font10, fill = 0) - drawblack.text((150, 30), '99', font = font10, fill = 0) - drawblack.text((150, 45), '99', font = font10, fill = 0) - drawblack.text((150, 60), '99', font = font10, fill = 0) + if msg.topic == "openWB/pv/W": + line = 0 + elif msg.topic == "openWB/global/WHouseConsumption": + line = 15 + elif msg.topic == "openWB/evu/W": + line = 30 + elif msg.topic == "openWB/housebattery/%Soc": + line = 45 + elif msg.topic == "openWB/housebattery/W": + line = 60 + drawblack.text((150, line), {msg.payload.decode()}, font = font10, fill = 0) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRedimage)) - print(f"`{msg.topic}`: `{msg.payload.decode()}`") + #print(f"`{msg.topic}`: `{msg.payload.decode()}`") Connected = False #global variable for the state of the connection