oops
This commit is contained in:
parent
d3124ac846
commit
d526864603
1 changed files with 5 additions and 5 deletions
10
printout.py
10
printout.py
|
@ -14,7 +14,7 @@ try:
|
||||||
with open(argv[1], "rb") as f:
|
with open(argv[1], "rb") as f:
|
||||||
config = load(f)
|
config = load(f)
|
||||||
TITLE = config["printout"]["title"]
|
TITLE = config["printout"]["title"]
|
||||||
MQTT_SUB = "{}/#".format(config["mqtt"]["prefix"])
|
MQTT_SUB = "{}/".format(config["mqtt"]["prefix"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Usage: {argv[0]} config.toml")
|
print(f"Usage: {argv[0]} config.toml")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
@ -58,7 +58,7 @@ mqtt_data = {}
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, rc):
|
||||||
LOG.info(f"Connected to mqtt server")
|
LOG.info(f"Connected to mqtt server")
|
||||||
mqtt.subscribe(MQTT_SUB)
|
mqtt.subscribe(f"{MQTT_SUB}#")
|
||||||
LOG.info(f"subscribing to {MQTT_SUB}")
|
LOG.info(f"subscribing to {MQTT_SUB}")
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,20 +103,20 @@ def generate_layout():
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
LOG.info('mooooin!')
|
LOG.info("mooooin!")
|
||||||
mqtt = mqtt.Client()
|
mqtt = mqtt.Client()
|
||||||
mqtt.on_connect = on_connect
|
mqtt.on_connect = on_connect
|
||||||
mqtt.on_disconnect = on_disconnect
|
mqtt.on_disconnect = on_disconnect
|
||||||
mqtt.on_message = on_message
|
mqtt.on_message = on_message
|
||||||
mqtt.connect(config["mqtt"]["host"], config["mqtt"]["port"], 10)
|
mqtt.connect(config["mqtt"]["host"], config["mqtt"]["port"], 10)
|
||||||
|
|
||||||
LOG.info('starting loop')
|
LOG.info("starting loop")
|
||||||
mqtt.loop_start()
|
mqtt.loop_start()
|
||||||
with Live(generate_layout(), screen=True) as live:
|
with Live(generate_layout(), screen=True) as live:
|
||||||
while True:
|
while True:
|
||||||
live.update(generate_layout())
|
live.update(generate_layout())
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
mqtt.loop_stop()
|
mqtt.loop_stop()
|
||||||
LOG.info('bye')
|
LOG.info("bye")
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("oops")
|
LOG.exception("oops")
|
||||||
|
|
Loading…
Reference in a new issue