Sending MQTT Sparkplug B control messages from Node-RED

This is such an incredibly important aspect to making all this work that I want to just expand on it for a moment.

The SPB spec states that the alias can freely change. So you can NOT write your code with a fixed alias number and always expect it to be tied to that I/O point over time.
The whole point of the alias is to shrink the message payload by not including the point (tag) name in each published message to the broker.
As Terry points out, you only see the point name and alias in one message, the DBIRTH message.

Again, as Terry points out, you only get the DBIRTH message when you make the first connection or when ever you reconnect with the broker after a disconnect. So your alias can change quite a bit if you are on a flaky network connection for example.

What does all this really mean then? It means that you the programmer need to keep very careful track of DBIRTH messages. You might build a table, or even have a database that links the tag name with the alias number and that way you can be sure you are controlling the correct I/O point when you publish on the topic. Keep in mind that if you have more than one device publishing SPB messages, you may well have the same alias numbers floating around in the system. Obviously they will be on different topics, but they could very well have the same alias number. All the more reason for you to keep very careful track of those DBIRTH messages.

Of course Ignition does a great job of doing all this for you.
Your tag really does become a single source of truth and as a human, you can just focus on your job and automate/collect data from the real world tag name and never know (or care) about what an alias is.

Long story short, before you go down the rabbit hole of building your own SPB end-to-end system, hopefully this post and Terry’s will give you reason to pause and deeply consider if its worth your time rolling your own custom system.

3 Likes