Spark plug to Mosquitto Broker - Issues

So I'm wondering Node Red can support what I am trying to achieve, or if I should resort to writing this in python. I currently am running Node Red on a BeagleBone, using it for data collection. I am trying to create a generic tag structure in order to connect my device with ignition, but ran into some issues. I am currently using mosquitto as my broker of choice. When having two devices with the same MQTT tag structure, ignition treats it as one device(overwrites in the same tag directory). In order to differentiate my devices, I decided to adhere to Sparkplug B's structure(to add namespace/group_id/message_type/edge_node_id/[device_id] to my tag path), but need some clarification of the functionality of said node, if I can download a javascript library to create this functionality.

I am struggling to find the question in your post..

But if the question is, can Node Red work with MQTT paths like this then the answer is yes.

To summerize, how do I create an MQTT architecture that is generic device side (only have to change parameters on the namespace/group_id/message_type/edge_node_id/[device_id] - sparkplug node) yet has the same generic tag structure in Ignition for quick deployment purposes? If I had many of these devices on the edge of my network, I am trying to cut down on deployment time; it would not be feasible to go into my program and change every MQTT topic structure to something different so Ignition can differentiate the different edge devices. If I can use the Sparkplug module, I'm thinking that this would be a quick fix, adding additional hierarchical layers to my devices, making it fairly simple to make them unique for mass deployment.

So, with the sparkplug node, I was under the impression I could do the following.....

Hope this clarifies it.

edit: Another solution I would also consider is having a pointer within the topic hierarchy that is manually created by the user. The root problem, again, is that I have no way of distinguishing many devices with the same tag structure within Ignition. All these devices overwrite the same tag structure, regardless of IP address or unique client id.

Another update:

Is there a way to use the function node and publish mqtt topics instead of using the MQTT node? I've tried with no luck. I'm using a mosquitto broker, and know how to do it in python, just not node red.

I seem to remember there was a thread about this - or a post in a thread - not too long ago showing how to do this. So if you search hard enouth you might find it. :blush:

Took a gander at your switch solution technique (I think that's what you're referring to).

The issue with this solution, to my knowledge, is that I will be using too many devices for a switching statements. Each device will have about 40~ tags associated with it, running its own broker. If I could do the equivalent of 'mqtt.publish('topic', 'msg.payload');' in node red, that would work as well.

But isn't this "standard" node-red capability ?

function node -> mqtt out node

in function node

msg.topic = 'device/abc'
msg.payload =  myvalue

ie: leave the mqtt-out node empty

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.