This commit is contained in:
Robert 2024-02-02 00:07:51 +01:00
parent fbb22a3572
commit fc7d944ce0

View File

@ -90,7 +90,7 @@ def subscribe(client: mqtt_client, topic):
client.on_message = on_message client.on_message = on_message
client.loop_stop() client.loop_stop()
def monitor(topics): def init_monitor(topics):
logging.info("epd2in13b_V3 Demo") logging.info("epd2in13b_V3 Demo")
logging.info(libdir) logging.info(libdir)
@ -120,21 +120,6 @@ def monitor(topics):
drawblack.text((4, 64), 'Batterie Entladen', font = font16, fill = 0) drawblack.text((4, 64), 'Batterie Entladen', font = font16, fill = 0)
drawblack.text((4, 80), 'Auto Laden', font = font16, fill = 0) drawblack.text((4, 80), 'Auto Laden', font = font16, fill = 0)
for topic_id, topic_info in topics.items():
print("\nTopic ID:", topic_id)
for key in topic_info:
print(key + ':', topic_info[key])
print(topic_info["line"])
print(topic_info["value"])
drawblack.text((160, int(topic_info["line"])), str(topic_info["value"]), font = font16, fill = 0)
#drawblack.text((160, 16), str(house_power), font = font16, fill = 0)
#drawblack.text((160, 32), str(power_import_export), font = font16, fill = 0)
#drawblack.text((160, 48), str(house_battery_soc), font = font16, fill = 0)
#drawblack.text((160, 64), str(house_battery_power), font = font16, fill = 0)
#drawblack.text((160, 80), str(charge_point_power), font = font16, fill = 0)
epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage)) epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
#logging.info("Clear...") #logging.info("Clear...")
@ -156,17 +141,8 @@ def monitor(topics):
def run(): def run():
client = connect_mqtt()
for topic_id, topic_info in topics.items():
print("\nTopic ID:", topic_id)
for key in topic_info:
print(key + ':', topic_info[key])
topic_info["value"] = subscribe(client, topic_info["topic"])
try: try:
monitor(topics) init_monitor(topics)
except IOError as e: except IOError as e:
logging.info(e) logging.info(e)
@ -176,6 +152,19 @@ def run():
epd2in13b_V3.epdconfig.module_exit() epd2in13b_V3.epdconfig.module_exit()
exit() exit()
client = connect_mqtt()
for topic_id, topic_info in topics.items():
print("\nTopic ID:", topic_id)
for key in topic_info:
print(key + ':', topic_info[key])
topic_info["value"] = subscribe(client, topic_info["topic"])
print(topic_info["line"])
print(topic_info["value"])
drawblack.text((160, int(topic_info["line"])), str(topic_info["value"]), font = font16, fill = 0)
if __name__ == '__main__': if __name__ == '__main__':
run() run()