How to subscribe to a channel

I am trying to subscribe to a mutt channel using Python Cayenne-mqtt library.

A Raspberry PI is publishing the data on channel 1 (i.e temp) and another Raspberry PI should receive the data by subscribing to it. The publishing part is working find, but I cannot find how to subscribe using the python cayenne library. Can you help me ?

I tried to used paho-mqtt library (client.subscribe) but connection to the device is stopped and restarted at every request… Strange !

I thought that this code works and send all messages, we don’t subscribe to a specific channel.

client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message

def on_message(message):'MQTT Message received ')'   Channel: %s', str('   Value  : %s', str(message.value))'   Topic  : %s', str(message.topic))'   Client : %s', str(message.client_id))'   Msg_ID : %s', str(message.msg_id))

Any idea how to do it ?

I also tried to run tinter graphical interface to show values. It required to start a myWindow.loop() which avoid running any other loop, like the mqtt client.loop() or loop_forever() in the same code.

What’s the best practices to run these two event code based ? Multi-Threading ?

you can use this Python code to access basic cayenne API