Remote deployment of Node-RED flows with Sofia2

As we have already mentioned in other post, Node-RED is a visual tool that provides a light flow engine capable of running on devices with reduce capacities, such as a Raspberry Pi.

In this post we will show how it is possible to edit centrally, from the Sofia2 admin console, Node-RED flows, which will subsequently be deployed remotely in devices. As an example of device and video demonstrator we will use a Raspberry Pi model A.

The remote deployment of flows will be performed on the device by a fairly light ThinKP, whose mission will be to receive new flows edited in the platform through the SSAP messaging protocol of Sofia2 and deploy them to the local Node-RED instance of the device.

video1

The freedom provided by the subscription SSAP message to execute queries, as well as the Sofia2 concepts of ThinKP and ThinKP instance, allow the remote deployment capability to be perfomed at the device group level, it can be considered a ThinKP as a group, with different instances in execution, each with its own identifier.

video2

The ThinKP running on the device, connects to the platform that opens an SSAP session and subscribes to receive notifications of flows edited in the Sofia2 admin console. To do so, the subscription query indicates that you are subscribing  to your group (in this case Raspberry Group), and within that group, to the notifications that are addressed to your specific identifier (RaspberryXX) or to the entire group (*).

These subscritions are registered in the Semantic Broker of Sofia2, to make the notifications in the future, when the new flow are deployed from the administration console.

video3

Once each device is subscribed to notifications of new flows deployment from the platform, a user with appropriate permissions can edit and test a flow in the management console.

video4

So, when the user finishes editing and testing the flow, it proceeds to deploy it to remote devices. To do this, you must select the ones in which you want the deploy to be made.

The management console, transparently to the user, constructs a message, which includes in addition to the deploy flow, the selected group and devices.

This message is sent to the Semantic Broker and processed as an SSAP – INSERT message, which triggering notifications to the subscribed ThinKPs, which will include the json code of the flow that have to be deploy in the Node-RED.

video5

So that in the device, once the ThinKP of each Raspberry Pi is notified, it proceeds to deploy in Node-RED the flow received in the notification message SSAP, using the API REST of Node-RED, so that the flow will start executing on the device.

video6

We can see the process in the following demonstrator video:

 

Remote deployment of Node-RED flows with Sofia2

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s