Closed Narsskrarc closed 2 years ago
I've never tried that arrangement but I think it should work fine. I would do something like this. In the callback:
if condition_is_met:
asyncio.create_task(subscribe_to, topic, qos)
And then
async def subscribe_to(topic, qos):
await client.subscribe(topic, qos)
That sounds as a good idea. I will test it asap. Thanks!
Well, I tested it now. ;-)
A little change: it has to be
asyncio.create_task(subscribe_to(topic, qos))
...and then this works. Thanks again!
Yes. Brain-fade there on my part :)
Hi all,
I try to setup an ESP32 which get its config from a mqtt topic. So I subscribe the topic in the connect_coro. When the message comes I want to subscribe other topics according to this message. But how can I subscribe something in the subs_cb? It is no coroutine and when I try to await mqtt.subscribe() inside the subs_cb it isn't called at all.
What would be the right way to do that?