Templating Group ID in Sparkplug Plus 'In' Node

I was looking to see if there’s a way to template the Group ID (or anything in the topic space really) in the topic of the ‘mqtt sparkplug in’ node (node-redcontrib-mqtt-sparkplug-plus) for the purpose of making my project more scalable. Is it possible to set part of the topic to a variable referencing an MMP address or something similar?


Hey Aaron, welcome to the forums!

The best way I can think to deal with this would be to use a single-level wildcard like spBv1.0/+/DCMD/RIO1/AI1/# and then use a check statement in a function node.
That way you could save the GroupID (or anything else) in the string scratchpad area, read it into flow context storage with a groov input node via the MMP address, then reference that in the function node to see if the current topic contains that group string.

I don’t believe there’s any way to dynamically change the topic in the Sparkplug “in” node, but this is one way you could make the flow more flexible without having much additional overhead.

1 Like

Thanks for the feedback Terry! I gave your idea shot and it works great! However, I think at scale this would possibly add a lot of traffic to the network if every RIO is subscribed to that wildcard - each RIO would pull in a command issued to a single specific RIO (if I’m wrong in my understanding don’t hesitate to correct me lol).
I may try moving back to the single Input node and wild carding the Device ID and using this flow/logic to hit the correct item - this way we’d just have to make that single change in the Topic per deployment.

1 Like