# Node-red sparkplug b

**URL:** <https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 25, 2022, 5:59am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632 "2022-03-25T05:59:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manthan\_Thakkar](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Manthan\_Thakkar](https://forum.inductiveautomation.com/u/Manthan_Thakkar)\
**Post date:** [March 25, 2022, 5:59am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/1 "2022-03-25T05:59:26Z")

</div>

Hi ALL,

We have an issue with the MQTT store and forward process being implemented within Ignition.

I have currently 299 tags on a test project, using Ignition’s Sample\_SQLiteDatabase. I am using NodeRed to simulate MQTT Sparkplug B module to test out the Store-and-Forward mechanism. I am getting the data displayed in the Perspective session in Designer when I play it. However, when the comms is halted, we just get “No” data. We were expecting the store and forward feature to store the data once the connection is restored but it’s not working.

Can somebody help me with that.

Kind Regards,  
Manthan

---

<div class="post-metadata">

**Author:** ![tordvd](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tordvd/32/11525_2.png) [@tordvd](https://forum.inductiveautomation.com/u/tordvd)\
**Post date:** [March 26, 2022, 5:47am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/2 "2022-03-26T05:47:31Z")

</div>

I don’t think the nodered / Javascript sparkplug B libraries does not support the historian flag. At least not native…

You can try to compare packages received from nodered with another ignition mqtt transmission module.

---

<div class="post-metadata">

**Author:** ![Manthan\_Thakkar](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Manthan\_Thakkar](https://forum.inductiveautomation.com/u/Manthan_Thakkar)\
**Post date:** [July 28, 2022, 7:34am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/3 "2022-07-28T07:34:27Z")

</div>

Thank you for that.

---

<div class="post-metadata">

**Author:** ![Theodorska](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Theodorska](https://forum.inductiveautomation.com/u/Theodorska)\
**Post date:** [July 19, 2023, 11:22am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/4 "2023-07-19T11:22:21Z")

</div>

Hello,  
are there any updates on this store and forward with node-red sparkplug b?

---

<div class="post-metadata">

**Author:** ![Gregor\_Hocevar](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gregor\_Hocevar](https://forum.inductiveautomation.com/u/Gregor_Hocevar)\
**Post date:** [March 3, 2024, 9:24pm UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/5 "2024-03-03T21:24:03Z")

</div>

I am still trying my to do the same. For now this is what I got for test.

[savedata.json](https://forum.inductiveautomation.com/uploads/short-url/5Msj0RDgCkCJElKV4eFbk9HbQY7.json) (4.3 KB)

---

<div class="post-metadata">

**Author:** ![Thomas\_Sorensen](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Thomas\_Sorensen](https://forum.inductiveautomation.com/u/Thomas_Sorensen)\
**Post date:** [March 5, 2024, 2:13am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/6 "2024-03-05T02:13:18Z")

</div>

I can see that you're using the MQTT Sparkplug out node. What is the destination you want to send the data to? If you are publishing data for the MQTT Engine Module in Ignition, then you should use the MQTT Sparkplug Device node.

My second question is; what is the reason why you want to send is\_historical data in the first place? is it because you don't have access to realtime data from Node-Red and are pulling historical data at a fixed interval? or is it because you have created you own store-forward buffer system? or something else?

---

<div class="post-metadata">

**Author:** ![Gregor\_Hocevar](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gregor\_Hocevar](https://forum.inductiveautomation.com/u/Gregor_Hocevar)\
**Post date:** [March 5, 2024, 7:10pm UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/7 "2024-03-05T19:10:50Z")

</div>

"I intend to send data to the MQTT Engine Module in Ignition. My goal is to use  
the Sparkplug Device node, but currently, this node does not recognize the ‘is\_historical’ data property.

In my application, I have an edge PC with a mobile connection (GSM, LTE). When there is poor signal strength, I want to save historical data locally and then transmit it to the MQTT broker once the mobile signal becomes available again. To achieve this, I am developing my own store-forward buffer system.

Could you assist me in understanding why the ‘is\_historical’ property is not functioning as expected with the Device node?

Currently, I have successfully created a working test flow using the ‘mqtt sparkplug out’ node, specifically with the ‘NBIRTH’ message type. However, I encountered difficulties when attempting to use ‘DDATA’ to create a functional ‘DBIRTH’ on Ignition SCADA. Although I can see ‘DBIRTH’ messages in MQTT Explorer, they do not appear in Ignition SCADA. It seems that I might be making an error in my configuration.

My secondary objective is to become proficient in using all the MQTT-Sparkplug-Plus nodes and successfully create message types such as ‘NDEATH,’ ‘DBIRTH,’ ‘DDEATH,’ ‘NDATA,’ ‘DDATA,’ ‘NCMD,’ ‘DCMD,’ and ‘STATE’ that work seamlessly within Ignition SCADA.

As a newcomer to Node-RED and the Sparkplug B protocol, I am still grappling with some concepts. Your assistance is greatly appreciated. Thank you!"

---

<div class="post-metadata">

**Author:** ![Thomas\_Sorensen](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Thomas\_Sorensen](https://forum.inductiveautomation.com/u/Thomas_Sorensen)\
**Post date:** [March 6, 2024, 12:23am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/8 "2024-03-06T00:23:51Z")

</div>

Ok, here is the correct way to set that up:

**Buffer when broker is offline:**

**Step 1** : Make sure that you have the latest version of node-red-contrib-mqtt-sparkplug-plus installed (Version 2.1.0+)

**Step 2** : In Node-Red go to “Import”\>”Examples” and select “node-red-contrib-mqtt-sparkplug-plus” \> “Simple Device” to create a small sample flow with a MQTT Device.

**Step 3** : Double click the MQTT Device and go to Advanced settings and select “Store Forward when not connected”.

Now the device will buffer to memory when MQTT broker is not connected and send messages as the connection gets back online (it will automaticly add the is\_historical flag to buffered metrics).

**Buffer when destination Ignition/MQTT Engine is not connected to the broker:**

Step 1: Double click the MQTT Device and edit the broker configuration.

Step 2: Select the “Sparkplug” tab and check the “Store Forward when primary application is offline” and enter the primary application name/Destination (This needs to match what you defined as Primary Host ID under the MQTT Engine. (See example below)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/0/20b6f957d8682991f2dfda89afb332a05190a607.png)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/f/0f4aed484af97ad389c6810120e79ac1dde5a346.png)

This will setup a memory only store forward. If you want to have a disk backed store forward mechanism, then you need to configure your node-red context store to be disk backed.

There is a guide on how to do that here:

[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Gregor\_Hocevar](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gregor\_Hocevar](https://forum.inductiveautomation.com/u/Gregor_Hocevar)\
**Post date:** [March 6, 2024, 6:36am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/9 "2024-03-06T06:36:54Z")

</div>

![mqttengine](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/a/ba2cb6e6aab8401843da6744695e8703fd8f55f8.png)  
Hello,

I cannot find the “Sets” folder under the MQTT Engine. Could you please guide me on where to locate this folder?  
If you are the author of this node plus is there any possibility that in the future MQTT Device node would just except " is\_historical" flag without reading state of primary application, because this would work only if I am using Ignition. I would just catch state of Device node and if node is not connected .I would store data in to a folder and send it when node is connected again.  
Lastly, I’m interested in learning how to create all MQTT Sparkplug message types using the MQTT Out node. Understanding the Sparkplug specification thoroughly is my goal. If my code encounters any issues, would it be possible to seek advice from you here or in the Node-RED forum?

Thank you!

---

<div class="post-metadata">

**Author:** ![Thomas\_Sorensen](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@Thomas\_Sorensen](https://forum.inductiveautomation.com/u/Thomas_Sorensen)\
**Post date:** [March 6, 2024, 3:14pm UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/10 "2024-03-06T15:14:01Z")

</div>

Sorry, I send a screenshot from the MQTT Transmission module. It's the Primary Host ID in the screenshot you need to set.

You don't need the primary host buffer setup to store forward, it's just an extra "feature" to make sure that you store forward if node-red is connected to the MQTT broker, but the primary application (in this case MQTT Engine) is not. You can just choose to only store forward when node-red is not connected to the broker.

If you want a better understanding of the sparkplug protocol and how the primary application works, then I would recommend that you read the sparkplug specification:

> **[sparkplug\_spec.pdf](https://www.eclipse.org/tahu/spec/sparkplug_spec.pdf)**

You can send is\_historical attribute with all the nodes (but I'm pretty sure you don't want to). It's not really documented anywhere but the attribute needs to be named isHistorical.

---

<div class="post-metadata">

**Author:** ![Gregor\_Hocevar](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gregor\_Hocevar](https://forum.inductiveautomation.com/u/Gregor_Hocevar)\
**Post date:** [March 12, 2024, 10:45am UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/11 "2024-03-12T10:45:27Z")

</div>

Thank you for your answer. I was testing the host buffer setup for store and forward. It is storing data and sending it to the Ignition MQTT server, but Ignition doesn’t recognize the ‘isHistorical’ in your MQTT metric. Did you test that historical metric on Ignition SCADA? If I send my metric with the ‘is\_historical’ flag, the history works on Ignition’s ‘Easy Chart’.”Component of a metric should looke like that :

**name** : Identifier for the metric

**alias** : A numerical alias for the metric, used to reduce the payload size in repetitive messages

**timestamp** : Indicates when the metric was sampled or created

**datatype** : The kind of data the metric holds (e.g., Boolean, Int32, String)

**value** : The actual data

**is\_historical** : A Boolean flag which denotes whether this metric represents a historical value

**is\_transient** : A Boolean flag which denotes if this metric should not be historized

**is\_null** : A Boolean flag which denotes whether this metric has a null value

**metadata** : Metadata object associated with the metric

**properties** : Propertyset object associated with the metrics

In all documentation, even in the Google Protocol Buffer schema, the historical flag is written as ‘is\_historical’.”

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/0/10e3df749faead27e6047c836bb0063de7db413a.png)

This is documented on page 64 in specification that you give me.

Can you please test this historical parameter in Ignition SCADA, I just do not know why "is\_historical" is working and "isHistorical" doesnt.  
[tahu/sparkplug\_b/sparkplug\_b.proto at master · eclipse/tahu · GitHub](https://github.com/eclipse/tahu/blob/5736e404889d4b95910613040a99ba79589ffb13/sparkplug_b/sparkplug_b.proto)

---

<div class="post-metadata">

**Author:** ![Gregor\_Hocevar](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gregor\_Hocevar](https://forum.inductiveautomation.com/u/Gregor_Hocevar)\
**Post date:** [March 19, 2024, 2:54pm UTC](https://forum.inductiveautomation.com/t/node-red-sparkplug-b/57632/12 "2024-03-19T14:54:34Z")

</div>

Hello. Yesterday, I was testing the `isHistorical` flag with your MQTT Sparkplug B device, the Ignition MQTT Transmission module, and my Node-RED `is_historical` flag. I was unable to **create** working historical data with your MQTT Sparkplug Device when forwarding the `isHistorical` flag( in Ignition SCADA). With the **Ignition MQTT Transmission module** , historical data is working, but it’s only because the data is **packaged into a single metric**. However, on the chart, I notice some small gaps. Interestingly, **only when using my test flow with the `is_historical` flag** , the historical data appears perfectly on the Ignition chart.  
I’ve read the standard you provided twice now, and there is no doubt that the correct historical flag is **‘is\_historical’**.  
The only place where I find the attribute **‘isHistorical’** is in an example for JavaScript on GitHub.  
[In the **Sparkplug Specification** , it is **clearly stated** without a doubt that **every metric must include a Sparkplug Datatype** from the \*\*Sparkplug Protobuf Schema.  
I am asking you can you please change attributes based on **specification** , here are the recommended changes:

Change **“isHistorical”** to **“is\_historical”**.

Change **“isTransient”** to **“is\_transient”**.

I am 100% sure that this is what specification are saying and that this changes would work.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cd70345a36e5cd85236b94d4e843943e045e0383.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/0/80d3b5ce17ecd9cb37de6fe950d9e50efd45f7ac.png)
