Skip to main content

Using Clarify nodes

Configuring the Insert node

The only thing you need for configuring the Clarify Insert Node is the credentials file belonging to the integration you want the signals to belong to. Download the file from the Credentials tab for the current integration.

The content of the downloaded credentials will be in the same format as shown below.

clarify-credentials.json
{
"credentials": {
"type": "client-credentials",
"clientId": "....",
"clientSecret": "....."
},
"integration": "....",
"apiUrl": "https://api.clfy.io/v1/"
}

In Node-RED add a Clarify Insert node, double click to bring up the edit tab. Under Credentials choose Add new clarify_api and click the pencil icon. The next tab gives you the option to upload the credentials file by clicking Choose file.

After successfully uploading the credentials file you have to save the node, finish the edit dialog and publish the flow. After that, you can bring up the Edit clarify_api node dialogue again and test that your credentials are valid by clicking the Check Credentials button. The response should be the token expiration timestamp.

Check Credentials - Token valid until...

When clicking the Check Credentials button in the edit panel the node will show you how long the current access token is valid, but you don't have to worry about this expiration as the node will automatically renew the token upon expiry. The date just shows to validate that your credentials are correct and a valid access token was received from the Clarify API.

Data format & message passing

Updated Node-RED version

The descriptions below are updated to match changes made in node-red-contrib-clarify version 1.0.0-beta.4 and later. Make sure to update the Clarify node from the palette if you have an older version.

Since Node-RED is a message-passing framework the Clarify Insert node expects one message per signal. Each message must contain an input ID in the msg.topic field and either only meta-data or a combination of meta-data and time series values.

Sending the message below would create a signal with input ID id1234 and write the values to that signal. Without any metadata, the signal would get a name equal to the inputID. Adding meta-data (name, etc.) could be done later by updating/adding the signal object for the same inputID.

msg without signal meta-data
{
"topic": "id1234",
"payload": {
"times": ["2021-09-06T17:00:00"],
"values": [1]
}
}

On the other hand, the example below would create a new signal with the given metadata, without adding any time-series data.

msg with only meta-data
{
"topic": "id4321",
"signal": {
"name": "my first signal"
}
}

The insert node will keep track of the signals it has seen before in its internal state so that it will only create or patch metadata when there is an unknown input ID or changes to the metadata.

A full description of the different signal meta-data parameters can be found in the documtation for the integration.saveSignals method.

The following message would create, (or update), a signal with input ID id100 and add three values to that signal:

{
"topic": "id100",
"signal": {
"name": "Temperatures"
},
"payload": {
"times": [
"2020-01-01T00:00:00Z",
"2020-01-01T00:01:00Z",
"2020-01-01T00:02:00Z"
],
"values": [9, 9.4, 10.3]
}
}

Example flow

This flow can be copied and imported into your Node-RED instance to get a working example that will generate random data for a signal with the id your-first-signal-id. Try adding and changing some meta-data and observe how the data changes in the Clarify Admin Panel.