# How to specify NBIRTH content for a Sparkplug node

**URL:** <https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986>\
**Category:** General\
**Tags:** mqtt\
**Created:** [17 March 2022 12:57 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986 "2022-03-17T12:57:22Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [17 March 2022 12:57 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/1 "2022-03-17T12:57:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 March 2022 15:54 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/2 "2022-03-17T15:54:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [18 March 2022 10:06 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/3 "2022-03-18T10:06:36Z")

</div>

> [@Colin](#):
>
> node-red-contrib-sparkplug-plus

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2022 10:21 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/4 "2022-03-18T10:21:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [18 March 2022 11:43 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/5 "2022-03-18T11:43:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2022 11:50 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/6 "2022-03-18T11:50:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [18 March 2022 11:59 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/7 "2022-03-18T11:59:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2022 12:03 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/8 "2022-03-18T12:03:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [18 March 2022 12:14 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/9 "2022-03-18T12:14:37Z")

</div>

The debug object shows nothing.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2022 12:19 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/10 "2022-03-18T12:19:07Z")

</div>

> [@ciderglider](#):
>
> 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.

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1138c1b8138441d41836e9bce1459c7a8952f8b.png)

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.

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [18 March 2022 13:05 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/11 "2022-03-18T13:05:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thomassorensen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomassorensen/32/45692_2.png) [@Thomassorensen](https://discourse.nodered.org/u/Thomassorensen)\
**Post date:** [19 March 2022 15:29 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/12 "2022-03-19T15:29:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ciderglider](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ciderglider/32/58614_2.png) [@ciderglider](https://discourse.nodered.org/u/ciderglider)\
**Post date:** [21 March 2022 10:41 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/13 "2022-03-21T10:41:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Thomassorensen](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thomassorensen/32/45692_2.png) [@Thomassorensen](https://discourse.nodered.org/u/Thomassorensen)\
**Post date:** [21 March 2022 14:35 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/14 "2022-03-21T14:35:22Z")

</div>

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".

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 May 2022 14:35 UTC](https://discourse.nodered.org/t/how-to-specify-nbirth-content-for-a-sparkplug-node/59986/15 "2022-05-20T14:35:49Z")

</div>

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