X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=telegram%2Fburrow-telegram.py;h=22fa145eda4f97ef4cacb5cb859b5c4891f18d69;hb=ef81a4d74227ac8fb82b0d153ae85b25cfc7b18b;hp=bf2e46a8ce3edb80cd7dbe3530e7748849ecec28;hpb=10c033f95cdeeaa692c7f62eabcfcc83536d81bf;p=home-hw.git 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():