Table of Contents

Node-RED (IoT)

Content Rocrail Server


Setup


In this test setup both the MQTT Broker and the Node-Red are running as service on a Raspberry Pi V3 under Raspbian Stretch.
(For both the packages are in the standard Raspbian repository.)


Sample Flow 1

Overview

The MQTT node on the top left listens to Rocrail info messages, and shows them with help of a debug node on the right pane.
The two inject nodes on the left send at click a string to the function node in the middle. This function node tries to translate the string into a RCP XML message.
The MQTT node on the right receives the output from the function node and publish it at the MQTT broker.


Convert to RCP

The blue Inject nodes do write a string in the message payload at click.
The JavaScript in the function node convert those strings into RCP.


Sample Flow 2

Overview

The first flow is extended with email and RCP evaluation.
If an email comes in, with body text "power on", this will be converted by the RCP function to a system command for global power on.
The MQTT messages are filtered and send by email.


Convert to RCP

This function is extended to support the email body text "power on".


Evaluate RCP

The evaluation of RCP messages is done in two step:

  1. Use the standard Node-RED XML function which converts it into a JSON object.
  2. Evaluate the message and take action if needed.


Cookbook: Setup MQTT and Node-Red in Windows10 Environment

1. Install Visual C++ Redistributable für Visual Studio 2015

VC Redist

2. Install OpenSSL Rev. 1.0.2

Open SSL

3. Install the Mosquitto Broker

Choose the Windows Installation Pack from here
(Example: mosquitto-1.4.14-install-win32.exe (~200 kB) (Native build, Windows Vista and up, built with Visual Studio Community 2015) as of 2018/01/08)
The first installation attempt fails, this is normal behaviour because some DLL are missing (see also prerequisites in readme.txt of MQTT)

4. Configure the MQTT Service in Rocrail

5.Install Node-Red