Node-RED » IoT automation based on the modular principle
Published: 21.04.2022 | Reading Time: 6 Minuten
This text is machine translated.
With Node-RED, you can bring many IoT and smart home devices together harmoniously under one roof. Controlling shutters and blinds depending on the sun, weather and presence of residents, regulating heat as required and raising the alarm in good time in dangerous situations: building automation is all about greater living comfort by automating processes, increasing security and improving energy efficiency. To achieve this, various systems and services must be linked together and connected to form a uniform smart home system. There are various solutions for this - one of which is Node-RED.
The free open-source software connects smart devices and services that are inherently incompatible or only partially compatible. In the development environment, you can design complex IoT applications - without writing a single line of code. The modular principle makes it easy to get started. By modeling processes in the tool, you can achieve comprehensive automation results.
In Node-RED, you create connections between devices, internet services and networked data sources - even if they are not related to each other and use different protocols. The automation software can connect almost everything in the IoT area by creating and executing flowcharts. You are no longer reliant on the availability of interfaces between manufacturers' sensors and actuators for interaction.
With Node-RED as the platform for the Internet of Things, the individual devices communicate with each other in a standardized way. Simply tell the tool which data source you want to tap into, what exactly should happen and where you want to forward the result.
Example: Controlling the room climate with Node-RED
A flow in Node-RED can, for example:
1. the humidity of the sensor installed in
the bathroom
query
2. the corresponding value
(humidity in the bathroom)
check
3. Turn on the wall fan and heater until the room air has
normalized
In Node-RED, a few drag & drop actions with the mouse are sufficient. Programming skills are not normally required to create the flowcharts.
The IoT connection platform originally developed by IBM is now available under the free Apache 2.0 license. This allows it to be used free of charge for private and commercial purposes.
Node-RED is based on the concept of data flow programming. Instead of entering programming commands in a text editor, you work with a visual flow editor as a graphical environment. Here you create a network consisting of smaller building blocks with ready-made code, the eponymous “nodes”.
You can use ready-made node modules for most applications, hardware and services. A basic configuration is available to you after installation in the Node palette on the left-hand side of the Flow Editor. If you want to use a node, simply drag it with the mouse from the left-hand column into the workspace. Additional nodes can be collected from the package storage in the personal library and inserted from there. The ready-to-use nodes are contributed by a growing user base. In return, you have the opportunity to share your own modules with the community.
Connecting the nodes creates a line following the principle of input, processing and output. The data flow is from left to right. Messages are transmitted between the nodes to transfer information. A node has at least one input and one or more outputs. The Inject nodes can be used to generate your own data. The notification node triggers a user alert in the form of a pop-up notification.
Nodes can process, change and convert the information they receive. The properties window shows the individual setting options of a node. An integrated help system provides information on how the individual nodes work. Experienced users use the function node to fill it with their own JavaScript code.
The Node-RED system distinguishes between input nodes, output nodes, processing nodes and social nodes:
Input nodes such as “Catch In”, “Http In” or “Tcp In” access data from sensors, services and other external sources. The information flows into the flow.
Output nodes such as “Debug”, “Http Out” or “Mqtt Out” send data from the flow to other devices, services or social networks. Example “File” node: The node saves results from the flow as a file or attaches information to an existing file.
Processing nodes take care of data processing. The “Change”, “Switch”, “Trigger” and “Html” nodes are frequently used. Elements can be extracted from retrieved HTML documents via the “HTTP request” node.
Social nodes support the sending and receiving of e-mails and messages via Twitter.
Node-RED is a server and browser-based development environment. The software is based on the Node.js web server and runs as a cross-platform server service. It is operated in the browser. You can start the server component either locally on your own computer or another PC in the network - or via the cloud. Once set up, open the flow editor by entering the IP address with port 1880 appended or via http://localhost:1880/ in the browser.
Other options for running Node-RED are a Docker container on a NAS storage device in the local network or an installation on the Raspberry Pi. A variant independent of your own computer is recommended so that the work computer does not have to be switched on all the time to run the flows.
Tip: The Node-RED developers provide scripts and installation instructions for common platforms on their website.
Running on the Raspberry Pi for initial trials offers advantages: The setup is done quickly thanks to prepared images for the Raspberry Pi. Thanks to its energy-saving operation, the Raspberry Pi is also a good choice for the energy-efficient execution of Node-RED flows.
Tip: After setting up your Node-RED server environment, check the security settings and access rights to the backend.
Almost all common home and industrial automation solutions can be controlled via the flows generated with Node-RED. All you need to do is connect the API functions via a corresponding flow - direct access to the hardware is not required.
This makes the development platform interesting for makers, hobbyists and demanding users who want to implement customized IoT automation.
As an add-on, Node-RED supports popular automation applications such as Home-Assistant, FHEM, openHAB, Homebridge, ioBroker or Homematic CCU3.
An overview of the available Node-RED functions can be found online in the project library at flows.nodered.org. Enter the device name, manufacturer or a keyword for which you want to see ready-made flows and nodes in the search field on the page.
For example, if you want to find out which automation options are available for an AVM Fritzbox, type fritzbox under “Search library”, for functions related to Amazon Alexa type alexa.
Smart home software - How to network different manufacturer systems
As soon as several systems are to be used in your rooms, such as one for smart lighting control and one for intelligent heat regulation, smart home control becomes more complicated.
We have explained various options for networking different smart home systems in more detail in our Smart home software guide.
The dashboard is an additional module for live monitoring. In the dashboard interface, you can view the results of your visual wiring and monitor the IoT configuration processes. You can access the dashboard in the browser by entering the IP address with the suffix “:1880/ui/” or via http://localhost:1880/ui/.