Python docs for MQTT

I just tried to use your MQTT API and saw the python code. there is no docs for it (or very well hidden).

I have no idea how the PI works. for example, what are the inputs client.celsiusWrite gets? how does other functions work?

I googled but found no detailed API docs for MQTT python library

Hi @hadi.farnoud,

Apologies for this, it is somewhat hidden. Once you have the Python MQTT library installed via the instructions in this readme, you can get the sort of detailed documentation you’re looking for with the command pydoc cayenne.client.

Ultimately, you’ll notice that functions like celsiusWrite() or luxWrite() are just shorthand for the more generic virtualWrite() function. The former allow you to skip specifying the data and unit types, where as the latter being generic wants you to explicitly define them. For a really quick example,

client.celsiusWrite(2, 25.2)
and
client.virtualWrite(2, 25.2, "temp", "c")

are directly equivalent – both will pass 25.2˚C as a value to MQTT channel 2.

You’ll likely find this thread useful if you want to see what your data/unit options are for populating virtualWrite().

If you edit this file on your local install, you can define your own functions that wrap virtualWrite() as well.