- Print
Sending Data from Node-RED to Tulip with Tulip Nodes
Overview
Three main methods exist to send data from Node-RED (such as device or external-system data) to Tulip:
- via the Tulip Machine API
- via the Tulip Tables API
- via a Connector Response
*Note: Requires a Connector first, originating from Tulip.
To streamline communications over methods 1 and 2, Tulip has created three first-party Nodes:
tulip-tag
: Send data to Machine Attributes API with advanced functionality - Tulip Edge Device Onlymachine-attribute
: Send data to Machine Attributes API from any devicetables
: Send & receive data to/from the Tables API from any device
All three nodes listed above are pre-installed on Tulip Edge Devices. Additionally, Nodes 2 and 3 above are published to the Node-RED Library for download to any device. They can be found here.
Sending Data to a Tulip Machine Attribute
Note: This section assumes a Tulip Machine Attribute has been created. For more information, refer to this guide.
From a Tulip Edge Device: the tulip-tag
Node
The tulip-tag Node is compatible with Tulip Edge Devices running software version 51 or higher.
- To use the
tulip-tag
Node, first drag it onto the editor pane from the Palette. Double-click the node to open its configuration pane. - Click the pencil to add a new Tag List:
Only one active Tag List is supported per Edge Device. Be sure to disable any Flows running other Tag Lists before beginning.
<put in the photo from the existing article here>
- Click +add to add a new Tag. Each tag has three parts: an ID, label, and type.
- Tag ID: a unique code-like identifier for the tag. Once created, it should not change. Valid characters are letters, digits (cannot start with a digit), and underscores. Examples:
part_count
,myState1
. - Tag Label: the human-readable label for the tag. To rename the tag, simply update the label - not the ID. Example: "Part Count".
- Type: The data type - String, Integer, Float, or Boolean. Must match the type of the mapped Machine Attribute.
A sample Tag List configuration can be found below:
Once all tags are added, click Add to save all changes.
Note that all tags will show Unmapped - this is to be expected, as the tags do not yet have an associated Tulip Machine Attribute.Once the Tag List is created, there are two methods to associate Flow contents with List entries. Both depend on the Tag Config checkbox in the
tulip-tag
node:
If Tag Config is checked (true), one Tag Node is needed for each Machine Attribute. Connect the Node to the
tulip-tag
node, and select the relevant Machine Attribute with the Tag Node's Select Tag drop-down. Note that the Tag Node will take whatever is found inmsg.payload
as the intended input.
For example, the flow below uses twoinject
nodes to input eitherhello
orworld
. Each has its owntulip-tag
node, with the Select Tag field mapped appropriately:
If Tag Config is unchecked (false), one Tag Node is needed for all Machine Attributes. The node will take a full Object of all Tag values and map them automatically to their respective Machine Attribute. Note that the input Object must match the Tag List exactly, or the Node will throw an error.
For example, the flow below uses oneinject
Node. The Node passes the Object shown to the Tag Node, which then mapshelloworld1
to the Tag List itemhello
, andhelloworld2
to the Tag List itemworld
:
Data is now being sent successfully to Tulip. Tags can be found as Machine Data Sources - to associate with a Machine Attribute, find each one under the Edge Device as a Machine Data Source.
The image below shows three Tags present on an Edge Device:
From any device with Node-RED: the machine-attr
Node
To use the
machine-attr
Node, first navigate to the Machine Attribute in Tulip.Click to open possible Data Sources, and select "Tulip API". Copy the information shown:
In Node-RED, add a Tulip
machine-attr
node. If not previously configured, configure a new Tulip Authentication (link needed - copy from here: https://support.tulip.co/docs/using-node-red-with-the-tulip-api).Paste the Machine Attribute data from Tulip in the Device Info field.
The Machine Attribute Node is now configured. Any data (of the same type as the Machine Attribute) present in msg.payload
once input to the Node will appear at the Machine Attribute in Tulip.