From 193bef66ddcd9e50ce20034ffb65bbec747bb3d3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 26 Aug 2023 16:29:03 +0200 Subject: [PATCH] Telegram: The same aiomqtt adjustments --- telegram/burrow-telegram.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/telegram/burrow-telegram.py b/telegram/burrow-telegram.py index bf2e46a..22fa145 100755 --- a/telegram/burrow-telegram.py +++ b/telegram/burrow-telegram.py @@ -137,12 +137,14 @@ async def mqtt_loop(): sctx.load_cert_chain('/etc/burrow-mqtt/client.crt', '/etc/burrow-mqtt/client.key') sctx.load_verify_locations(cafile='/etc/burrow-mqtt/ca.crt') - async with aiomqtt.Client(client_id='telegram', hostname="burrow-mqtt", port=8883, tls_context=sctx) as mqtt: - async with mqtt.messages() as messages: - await mqtt.subscribe("burrow/heating/#") - await mqtt.subscribe("burrow/temp/#") - async for msg in messages: - await mqtt_process_msg(msg.topic, msg.payload.decode()) + mqtt = aiomqtt.Client(client_id='telegram', hostname="burrow-mqtt", port=8883, tls_context=sctx) + await mqtt.connect() + + async with mqtt.messages() as messages: + await mqtt.subscribe("burrow/heating/#") + await mqtt.subscribe("burrow/temp/#") + async for msg in messages: + await mqtt_process_msg(msg.topic.value, msg.payload.decode()) async def mqtt_watcher(): -- 2.39.2