NodeRED/en

Aus expecco Wiki (Version 25.x)
Zur Navigation springen Zur Suche springen

Introduction

Node-RED is a graphical development tool. With Node-RED, use cases for the Internet of Things can be implemented according to a simple modular principle. In Node-RED there are so-called "nodes" which look like as follows. Each node fulfills a certain function e.g. making a HTTP-request.

Preparations

  • Use the command line to verify that Nodejs has been installed correctly.
    • To open the command line type "cmd" in the Windows search bar and press the enter key.


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • After you have opened the command line type "node --version" in.


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Also type "npm --version" in the command line.
    • Hint: npm usually comes with Node.js


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Internet connection available?

Installing Node-RED

  • Open command line


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Enter "npm install -g --unsafe-perm node-red" and press the enter key


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Enter "npm install node-red-node-test-helper node-red --save-dev" and press the enter key


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Enter "node-red" and press the enter key to start Node-RED


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • After you have started Node-RED open your browser (Chrome, Firefox, Internet Explorer, ...)
    • Enter "localhost:1880" into the search bar of your browser and press the enter key



  • Close the browser and the command line now


Node-RED Tutorial - Part 1

The following tutorial shows how to import nodes of Node-RED into expecco and how to use them.

Specify necessary paths

  • Open a new testsuite in expecco



  • Now you should have the following view in front of you



  • Click the undo-button to remove the existing demos



  • Click on ExtrasSettings



  • Click on ExecutionExternal Script InterpretersNode



  • Specify at Node.js Path the path to the Node.js interpreter



  • Click on the question mark next to Node.js Path to verify the node path
    • If the path is correct you will see the version of Node.js in the lower field



  • Specify at Node-REDModule Path the path to the node_modules folder
    • Click on the three points next to the field



  • A small window opens
    • Click on the little house icon
    • Click on the user directory of the current user
    • Navigate in the user directory to the .node-red folder
    • Navigate to the node_modules folder
    • Select this folder and click OK
    • Your path in the field of Filename should look like C:\Users\YOUR_USERNAME\.node-red\node_modules



  • Specify at Node-REDExecution Directory the path to the .node-red folder
    • Click on the three points next to the field



  • A small window opens
    • Click on the little house icon
    • Click on the user directory of the current user
    • Navigate to the .node-red folder
    • Select this folder and click OK
    • Your path in the field of Filename should look like C:\Users\YOUR_USERNAME\.node-red



  • Click on Apply and then on Close



  • Click YES to save the entered paths


Importing a Node

  • Click on OperationsNode-REDImporting Nodes



  • A small window opens
    • Click on the little house icon
    • Click on the user directory of the current user
    • Navigate to .node-red → node_modules → @node-red → nodes → core → network
    • In this folder is a file called 21-httprequest.html
    • Select this file and click on OK



  • A new folder should have been created
    • Open this folder and click on the elementary block to get the view which is shown in the picture


Using a Node in expecco

  • Click on the tab Test/Demo



  • Click on the elementary block keep the left mouse button pressed and drag the block a little further to the middle of the editor




Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden


  • Click on the green arrow to execute the block



  • After you have executed the block, it takes a few seconds until you see a result
    • When you see a result click on Run



  • Click on PinsmsgOut



  • Scroll in the field Keys to statusCode
    • Click on statusCode
    • If the HTTP request were successful the number 200 should be in the field next to it



Hint: Keep this testsuite open if you want to continue with the second part of the tutorial

Node-RED Tutorial - Part 2

This tutorial will show you how to import Nodes from the Node-RED library into expecco

Preconditions

  • Open the testsuite from tutorial - part 1
  • Make sure you did the step Specify necessary paths from the first part of the tutorial before you make this part.

Collect Nodes from the Node-RED library

  • Click on OperationsCollect List of Nodes in Attachment
    • The Node-RED library gets opened in a browser and the names of each node of the library get extracted and saved in the attatchment listOfNodes
    • Hint: Collecting the node names take a few minutes and offers the opportunity for a short coffee break



  • Node-RED library



Installing Nodes

  • Click on OperationsInstall Nodes



  • A window opens
    • Enter here the node name node-red-contrib-speedtest-updated



  • The entered node gets installed now
    • Information about the installation can be found at the bottom left of the window


Fehler beim Erstellen des Vorschaubildes: Die Miniaturansicht konnte nicht am vorgesehenen Ort gespeichert werden



Copyright © 2014-2024 eXept Software AG