Cayenne and MQTT Subscribe


#1

Hi All,

I am using a WiPy and I am trying using micropython to control a digital pin on my WiPy by pushing a digital button in Cayenne interface.
I am behind a router, so I have forwarded the external IP to the internal IP of the WiPy at port 1883, but it doesn’t seem to work.

What is the exact topic I have to subscribe in order to “catch” the button press?
For publishing I am using topic “v1/CLIENT_ID/things/USER_NAME/data/CHANNEL_NUMBER”

What should I use for the command button on Cayenne?

I also have included the following lines of code:

client.set_callback(sub_cb)
client.connect()

where the sub_cb function just prints the message “Button pressed in Cayenne Dashboard…”

Thanks! Hope you can help me on this


#2

Hello and Welcome to the Cayenne Community,
I think that you have to use this topic:

v1/username/things/clientID/cmd/channel

https://mydevices.com/cayenne/docs/bring-your-own-thing-api/#cayenne-mqtt-api-manually-publishing-subscribing-control-a-light-actuator-testing-the-actuator-receive-actuator-command


#3

Hi @ivlachos,

For actuators (like a button press), you’re looking for v1/username/things/clientID/cmd/channel.

Things like our MQTT Python Client abstract this a little bit, so if you’re using that, your button press should be automatically caught by the callback statement’s in that, and you can of course write multiple callbacks to capture presses on different channels and have them behave different.

e: beaten! :smiley: