How to specify NBIRTH content for a Sparkplug node

I have installed the node-red-contrib-sparkplug palette, and have created a sparkplug node.
I have a separate Sparkplug B client that subscribes to the node I have created in node-red.
When the node connects to the MQTT broker, my Sparkplug client sees the NBIRTH from the node-red node. How do I go about configuring the content of the NBIRTH message, e.g. if I want to add some metrics to it? When I edit the node, there aren't any options for NBIRTH content.

I have generated a DBIRTH message by using an inject and a function node, which feed into my sparkplug object. But this doesn't seem like the way I should deal with NBIRTH.

I am using version 2.2.2 of node-red.

Welcome to the forum @ciderglider

I don't use sparkplug, but looking briefly at the spec, it appears that the NBIRTH contents consist of the set of metrics that have been setup prior to the message being sent. The node node-red-contrib-sparkplug doesn't go into that, but if you look at node-red-contrib-sparkplug-plus it tells you how to setup the metrics.

Thanks for your reply. I understand how to write the message that will contain the metrics. What I can't figure out is how to use those metrics when the sparkplug node sends its NBIRTH message.

What do you mean 'how to use them'? The node should send the metrics automatically, according to the spec.

Edit: Did you read the section "Dynamic metric definitions" in the sparkplug-plus readme?

I have read the "Dynamic metric definitions" section. I don't understand how to hook the message definition into the UI for mqtt sparkplug device node.

I have copied the example mqtt sparkplug device node from node-red-contrib-mqtt-sparkplug-plus, and got it to connect to a broker. When It connects, it sends an NBIRTH, which is nice, but the NBIRTH doesn't contain the testing/test1 and testing/test2 metrics.

What message are you sending to the node to give it the metrics?

I have used the Send Metrics inject node from the node-red-contrib-mqtt-sparkplug-plus example code. When I inject this, the metrics appear in the DDATA message, which is all good.

I see these metrics are configured in the UI for the mqtt sparkplug device node.So I hoped that when it sends its NBIRTH it would contain this data.

I didn't ask how you generated the message, I asked what is in it. Connect a debug node to show what you are giving to the node. Set it to Output Complete Message and see what appears in the debug pane. Expand any objects there and post it here.

The debug object shows nothing.

This is the first time you have mentioned that you are doing that. Do you mean that you have configured metrics in this field

image

The help text suggests that if you do that then you don't need to do anything else, they should automatically be sent when the node connects, without the need to send it a message. If that is not happening then I suggest you ask on the node's github page.

Yes, there are two metrics configured in that field.

I will ask the node-red-contrib-mqtt-sparkplug-plus developer a question about the metric no-show.

Thank you very much for your help

Hi,

The NBIRTH is birth of the EoN Node (Node-Red) and would normally be reserved for system function (e.g rebirth or reboot, node-red version etc.), Your metrics should be defined in the birth (DBIRTH) of one or more device(s) (a device is a "MQTT Sparkplug Device" node in Node-Red).

If you inject the input to the device in the example then it will send a DBIRTH with the metrics and the metrics. It's not sending DBIRTH until it has a value for all the metrics on the device because value is a required attribute of the DBIRTH message.

Put in another way, by design there are no way to add custom metrics at the EoN node level. is there a good reason why you don't want to define your metrics on device birth?

Thanks for your reply. I am working on a Sparkplug B "primary application", and want to exercise its handling of both NBIRTH and DBIRTH messages. The Sparkplug spec allows for metrics to belong to either an EoN Node or a Device, and that's why I wanted to be able to manipulate what metrics appear in an NBIRTH.

Ok, then I don't think the mqtt sparkplug device node is the right node for your testing. As you are only using it for testing then you could simply encode a few Sparkplug messages and send them via a standard inject node.

If you want to test with a full compliant EoN client, then you should consider downloading a free trial version of "Ignition Edge". The MQTT Sparkplug modules in Ignition are developed by the same company (cirrus-link) that wrote the Sparkplug B specification, so I would consider it a "reference implementation".

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