Enhancing Your Smart Home With Node-RED

As you dive deeper into your smart home, regardless of which platform you start with, sooner or later you’ll start to encounter edge cases that prove problematic. Whether it’s automations that need more complexity than your platform offers, or devices that simply don’t offer the integration you need, you’ll start to look for home grown solutions to get what you want to work.

There are certainly many different ways to skin this cat, from DIY hardware solutions and firmware hacks to open-source tools that can help to bridge the gap between hardware and software platforms. We’ll be looking at one of the latter, an open-source tool called Node-RED.

Node-RED's goal is to enable anyone to build applications that collect, transform and visualize their data; building flows that can automate their world. Its low-code nature makes it accessible to users of any background, whether for home automation, industrial control systems or anything in between.

What is Node-RED?

Node-RED is intended to be what’s known as a ‘low code’ data transform and automation tool. It uses a visual editor to place and connect nodes that perform specific actions. A completed set of nodes is known as a flow which can take data from multiple sources, process it, and produce an output in various ways. These nodes and flows are modular and extensible, and the community has created over 5000 additional nodes that you can add to expand your installation’s capabilities.

Node-RED is light on hardware requirements, so it can be run on something small and cost-effective like a low-end Raspberry Pi. This enables it to sit in the background receiving data and running your flows like any other smart device. This can be used to create advanced automations, or to create virtual smart devices that can be integrated with other platforms.

What you’ll be able to do with Node-RED does depend quite a bit on what smart home platform you want to use it with. For example, while you can use it with Apple Home (HomeKit), it can’t read data from your existing HomeKit accessories. Instead, it can create new virtual accessories that you can use to run advanced automation tasks or provide integration and control over devices that aren’t HomeKit compatible.

As controlling such devices is dependent on getting data in and out of them, there is a level of technical knowledge required in creating these flows. You’ll need to use things like HTTP or MQTT to provide that data connection, depending on the situation. Node-RED offers a bunch of data integrations to help with this, including structured data types like JSON, YAML, CSV, and HTML More are available as well from the community library if you need something specific.

Some Use Cases for Node-RED

  • Event-driven automated data processing and messaging
  • Advanced automation flows for open smart homes platforms like Home Assistant
  • Logic handling for connected devices, either DIY or with supported data connections
  • Message routing between systems that don't support native integration

A Look At The Editor

Node-RED is simple to use thanks to its clean editor interface. The two main parts of this are the pallete on the left, where the available node types are found, and the central canvas, where you place nodes and connect them with virtual wires. The right side is the sidebar, which is used for accessing debug and configuration information.

Node-red editor with examples

The Node-RED editor

To place nodes you simply drag and drop onto the canvas. You wire nodes together similarly by dragging the output handle of a node to the input of another node. This will automatically create a curved wire between the two which will update if you drag the nodes around to rearrange things.

Editing the specific values and behaviors of a node is done by double-clicking on it. This opens a configuration window with the relevant values depending on the node type. These could be simple data values right up to full blown script editors.

Data is passed between nodes in a msg object. Messages are JavaScript objects that can have any number of properties, with the default being the payload object. A debug node is provided to make it simple to assess the contents of a message at any point in the flow.

A very important step (and one I kept forgetting initially) is to deploy any changes to the flow. Without deploying, the flow only exists in the editor. If you want to it to actually function externally, any change must be deployed first. This is simply a matter of clicking the red ‘Deploy’ button above the sidebar. The editor will remind you by putting a blue dot on both the flow tab and any nodes that have been changed within that flow.

With drag-and-drop, double-click and simple wire connections the editor is actually very simple and largely intuitive. It’s easy to build a flow using the available nodes in a couple of minutes, the tricky part comes with understanding and ensuring the correct message data is passed between them. I found this to be where the learning curve is.

It pays to have a basic understanding of JSON formatting and how to reference specific object parameters. You may also need to convert data between nodes, which can be done using the various conversion nodes, or using JavaScript directly in a function node to strip and pass the required data. Thankfully there is fairly extensive documentation and plenty of community help out there.

A Simple Example

To demonstrate how to create a flow and edit nodes, we’ll use the example of a simple push button. The actual use of this logic would require the use of suitable data integration nodes to both receive the button press from something, and to output the button state. We’ll just focus on the basic button logic for now.

First, we’re going to drag an Inject node from the palette on the left to the canvas in the middle of the editor. Inject nodes are used primarily for testing as they allow you to manually push a message into the flow. They do have a useful automation function though; in that they can also be configured to do this on a time interval.

Double-click on the node and give it a name (ON in this case) and set the msg to payload with the string value {“On”, true}.

This will be our simulated trigger event. Inject nodes have a small button on the left side which can be clicked in the editor to trigger the message injection. By using these nodes, we can force the injection of whatever message data we need to test when debugging a flow. You can have as many as you want and wire them into to anywhere. It’s common to have one for each input a flow might expect.

nodered-adding an inject node

Configuring the Inject node

Next, we’ll add a Trigger node. These nodes allow us to modify the message after a time interval so this will allow us to simulate a momentary button press. Double-click to configure it, then set it to send the existing input message unmodified by select the existing msg object from the Send drop-down menu.

Set the wait time to 1 second, and the then send option to {"On",false}. This will receive the true value from the inject node and pass it through, but 1 second later send another message with the false value. Wire the Inject node to the Trigger node by dragging the output handle on inject to the input handle on trigger.

configuring the trigger node in node-red

Configuring the Trigger node

Finally, we’ll add a debug node to simulate the output of our button.

Drag the debug node onto the canvas and simple wire the trigger output to the debug input. It’s always a good idea to have a debug node wired into your flow at relevant points. You can easily wire nodes to multiple places to send the same message data to multiple other nodes without any negative impact. You can toggle a debug node on or off using the button on it’s right side.

With the debug node wired in, we simply click the Deploy button to make the flow active. Now when we click the button on the inject node, we get the output of the button state in the debug window on the sidebar to the right.

nodered completed example flow

Testing the flow with the Debug node

Installing Node-RED

Node-RED relies on NodeJS to run, so you’ll generally be fine running it on most Linux variants. It is possible to install NodeJS on Windows as well, but it gets a bit fiddly. I prefer to run these tools on dedicated hardware both to prevent losing multiple tools if something goes wrong and to simply organization. The best option for this is to run it on a Raspberry Pi.

This is cheap and simple to maintain, can be kept anywhere convenient that’s out of the way and doesn’t generate a lot of heat or noise you have to worry about. You don’t need anything super new; I’m using a spare Raspberry Pi 3B I had left over from some upgrades.

Installing on a Raspberry Pi is very easy. Set up a fresh MicroSD image with SSH enabled and then jump into the terminal using an SSH client of your choice. If you haven’t set up a Raspberry Pi before, check out my full first time install guide to get you going.

Once you have a fresh image booted up on your Pi, just follow these steps in the terminal:

Prep the install to ensure NPM is able to fetch what it needs:

sudo apt install build-essential git curl

Install Node-RED and its dependencies. This script will ask you a several questions and allow you to set up your initial preferences. These are pretty straightforward.

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

Configure Node-RED to run as a service:

sudo systemctl enable nodered.service

Start your Node-RED instance:

node-red-start

Your Node-RED install should now be running. Access the editor at http://<address>:1880 and get started on your first flow.

Further Reading

Node-RED is well documented and has a host of resources to help you along.

Install guides for other platforms: https://nodered.org/docs/getting-started/local

Core node documentation: https://nodered.org/docs/user-guide/nodes

Node-RED community forum: https://discourse.nodered.org/

Cookbook for flow ideas: https://cookbook.nodered.org/

Node-RED on YouTube: https://www.youtube.com/channel/UCQaB8NXBEPod7Ab8PPCLLAA

Node-RED academy courses: https://node-red-academy.learnworlds.com/

Summary

Node-RED is a powerful tool for DIY integrations, data automation, and smart home enthusiasts, but it’s not necessarily a must have. There are specific use cases where it’s brilliant, but you’ll need to determine if it’s something that will solve whatever problem it is your having. Of course, if you have the hardware sitting around, it’s easy to set up and tinker with, and it’s not bad to have around anyway.

Some scripting and protocol knowledge will go a long way to helping you to get the most out of it and avoid banging your head against the wall, so it’s not really something I’d recommend to non-technical people, but if you have been messing with tech and gadgets for a while, it can also be a great way to start learning more about how connected systems work.

David Mead

David Mead is an IT infrastructure professional with over 20 years of experience across a wide range of hardware and software systems, designing and support technology solutions to help people solve real problems. When not tinkering with technology, David also enjoys science fiction, gaming, and playing drums.

Next
Next

Best No Neutral Smart Switches (2025 Update)