MQTT Topic Path Depth

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
sdyoung
 
Posts: 2
Joined: Sat Oct 23, 2021 11:49 pm

MQTT Topic Path Depth

Post by sdyoung »

I'm using a software package that has an API that more or less doubles as the MQTT topic path. So in a browser to get a value the URL would be <server>/state/circuit/get/6 and to set it <server>/state/circuit/set/6/true. The MQTT it generates wants to write to that same path structure. I can't see how to build feeds in AIO with that path depth. I can see AIO transforming the slash delimiters into hyphens. Do I need to somehow accommodate that transformation or is there a way in AIO to build deeper paths? I thought about trying to somehow shorten the path in AIO to <username>/feed/6 but on the source side, there is a /6 in /circuits, /pumps, /lights and so on.

Of course maybe I'm just missing something obvious.

Thanks

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: MQTT Topic Path Depth

Post by jwcooper »

Here is our detailed documentation on our MQTT broker:
https://io.adafruit.com/api/docs/mqtt.h ... o-mqtt-api

And specifically, here is how we expect mqtt topics to be formatted:
https://io.adafruit.com/api/docs/mqtt.html#mqtt-topics

User avatar
sdyoung
 
Posts: 2
Joined: Sat Oct 23, 2021 11:49 pm

Re: MQTT Topic Path Depth

Post by sdyoung »

Thanks for posting that, and yes, I've read that info. It seems somebody else had this same question in 2017 viewtopic.php?t=118664

Can you confirm the only way to have two similar path elements with different upstream elements to separate with hyphens?
Like this:

Code: Select all

<username>/feeds/state/circuit/6 and <username>/feeds/states/pump/6
would have to be represented as

Code: Select all

<username>/feeds/state-circuit-6 and <username>/feeds/states-pump-6
That's all we can do on AIO?

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: MQTT Topic Path Depth

Post by jwcooper »

That's correct. We have to map the topic to your username and the feed that you would like to save the data.

We also support groups, which adds one more level, but the topic changes only slightly:
https://io.adafruit.com/api/docs/mqtt.html#group-topics

Groups allow you to publish multiple feeds in a single publish, but you'd still need to modify your topic paths.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”