This commit is contained in:
Franzi 2024-07-30 18:44:25 +02:00
parent d3124ac846
commit d526864603
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -14,7 +14,7 @@ try:
with open(argv[1], "rb") as f:
config = load(f)
TITLE = config["printout"]["title"]
MQTT_SUB = "{}/#".format(config["mqtt"]["prefix"])
MQTT_SUB = "{}/".format(config["mqtt"]["prefix"])
except Exception as e:
print(f"Usage: {argv[0]} config.toml")
exit(1)
@ -58,7 +58,7 @@ mqtt_data = {}
def on_connect(client, userdata, flags, rc):
LOG.info(f"Connected to mqtt server")
mqtt.subscribe(MQTT_SUB)
mqtt.subscribe(f"{MQTT_SUB}#")
LOG.info(f"subscribing to {MQTT_SUB}")
@ -103,20 +103,20 @@ def generate_layout():
try:
LOG.info('mooooin!')
LOG.info("mooooin!")
mqtt = mqtt.Client()
mqtt.on_connect = on_connect
mqtt.on_disconnect = on_disconnect
mqtt.on_message = on_message
mqtt.connect(config["mqtt"]["host"], config["mqtt"]["port"], 10)
LOG.info('starting loop')
LOG.info("starting loop")
mqtt.loop_start()
with Live(generate_layout(), screen=True) as live:
while True:
live.update(generate_layout())
sleep(0.5)
mqtt.loop_stop()
LOG.info('bye')
LOG.info("bye")
except Exception:
LOG.exception("oops")