Add semantic to the Node-RED msg payload with JSON-LD

Posted on Updated on

In the NODE-Red ecosystem, many nodes are built and published.
When someone creates a node that produces geo coordinates (this is an example), and another a node that consumes geo coordinates, it is very important that these two nodes can be linked together in NODE-Red. To achieve that, the former should produce a payload that the latter can read.

Using JSON or msg is not enough:

 "latitude" : "40.75",
 "longitude" : "73.98"

Also consider another example:

"temperature" : "40"

What does it refer to? degrees Celsius or Fahrenheit?

We must agree on the content of the JSON object in the payload.

TheThingBox choice

In the ThingBox project ( we decided to use JSON-LD to format the payload.

JSON-LD allows to uniquely define the content of a JSON object.

 "@type" : "",
 "" : "40.75",
 "" : "73.98"

When a node finds an object containing:

"@type" : ""

then the semantic of the object is uniquely defined.

The members are also uniquely defined.

The previous object can be “compacted” by factoring paths into a context:

 "@context": "",
 "@type": "GeoCoordinates",
 "latitude": "40.75",
 "longitude": "73.98"

Many objects are already defined in
Find more about JSON-LD at  and use it in Nodes!


How to : make a node-RED node

Posted on Updated on

A node is composed by two files : a .js and a .html file. They must have the same name.
Nodes are loaded from a folder in alphanumeric order. So you can prefix the name with a number to control a node, e.g 42-example.js an 42-example.js.

We will create a node example which display message in console.
In node-red/nodes, create a folder ‘example’.
Then create in this folder an example.js and an example.html file. Create a folder ‘icons’ and place a picture in it if you want to have one.

JS File

The .js contain the code of the node, that is to say it indicates what the node has to do.

example.js :

red is required for create the node. It’s better to write Require at the top as synchronous function.

var RED = require(process.env.NODE_RED_HOME+"/red/red");

Then, we implement the main function, called at the launch of node-RED, the parameter ‘n’ contains the data filled by the user in the user interface (UI).

function ExampleNode(n) {RED.nodes.createNode(this,n); // Create a RED node this.on("input", function(msg) { // when a message arrive var name =; console.log(name+" receive : "+msg.payload); });

finally, we match the name “example” with the ExampleNode function



The .html file is used to describe the node in the UI.

example.html :

We begin with the form filled by the user

<script type="text/x-red" data-template-name="example">

Add a div for each properties.The for and id attributes identify the corresponding property (with the ‘node-input-‘ prefix)

<div class="form-row">
    <label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
    <input type="text" id="node-input-topic" placeholder="Topic">

By convention, most nodes have a ‘name’ property.

<div class="form-row">
     <label for="node-input-name"><i class="icon-tag"></i> Name</label>
     <input type="text" id="node-input-name" placeholder="Name">

To finish this part of code, close the script tag :


Next, we add the documentation displayed on the right of node-RED

<script type="text/x-red" data-help-name="example">
<!-- The first <p> is used as the pop-up tool tip when hovering over a node in the palette -->
<p>Example Node : display payload in console.</p>

And close again the script tag :


Finally, the node type is registered along with all of its properties

 <script type="text/javascript">
 RED.nodes.registerType('example',{ // match "example" with these properties
     category: 'input',      // the palette category - palette are define in public/index.html
     defaults: {             // defines the editable properties of the node
         name: {value:""},   //  along with default values.
         topic: {value:"", required:true}
     inputs:1,                // set the number of inputs - only 0 or 1
     outputs:0,               // set the number of outputs - 0 to n
     color:"#FFCD45"          // "rgb(231, 231, 174)" can be used too
     icon: "arrow-in.png",    // set the icon (have to be in a icons folder, public/icons is priority)
     label: function() {      // sets the default label contents
     labelStyle: function() { // sets the class to apply to the label


Now, launch or reboot node-RED and you will see the example node on the left. If not, be sure your .js and .html have the same name, and check your .html. A node is displayed if there is a .html and a .js with the same name in the same folder, the .js has to exist but can be empty


Beewall – speech recognition

Video Posted on Updated on

The Bee-Wall can hear you, talk to him!

A Bee-Wall on a computer + Leap Motion Controller

Posted on Updated on

A Bee-Wall on a computer + Leap Motion Controller = a fun video, and maybe a great idea ?

Fundatrix Bee-Gallery

Link Posted on Updated on

Fundatrix Bee-Gallery

Here’s a moment that nothing has been posted here … and for good reasonwe finalized and launched the first version of our Bee-Gallery! You will find applications (we call them Bee-Notes) currently available for a Bee-Wall. To visit our Bee-Gallery :

The next Bee-Wall, Trigona? You will see ;) !

Image Posted on Updated on

The next Bee-Wall, Trigona? You will see ;) !

Bigger, faster, this screen may become the future Bee-Wall Trigona. It is still in development, but I think we approach something …

Times Square is on the Bee-Wall !

Image Posted on Updated on

Times Square is on the Bee-Wall !

New Bee-Note on the Bee-Wall! Connect to the webcam in the city of your choice worldwide. Look, we tried, now Times Square is under our eyes;)