Is it possible to subscribe to MQTT topic on-demand via python script

Assuming we have the MQTT Engine module, is it possible to subscribe to an MQTT topic via python script? At this point, we’re looking at just reading plain vanilla payloads (non-Sparkplug).

I know system.cirruslink.engine.publish exists to publish but haven’t been able to find a subscribe API.

I also understand that we could setup a Custom Namespace with a tag name wildcard filter to only pull the payload of a single topic which would send to the MQTT Engine tag provider as a tag but I was just wondering if we could grab that payload via script without involving a tag provider.

Now that I think about it, this probably doesn’t make much sense. The whole purpose of subscribing to an MQTT topic is to “wait” for changes that get published. But assuming the retained flag is set when published, it would still be nice to subscribe via a button click (python script) and then close the connection. Definitely not looking to create a listener by any means.

I supposed paho.mqtt.client is probably a solution. Am I on the right track?

1 Like