Node-RED container with authentication and Home Assistant nodes setup
Introduction
Node-RED is a programming tool. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
Setup
-
Create the folders needed by the container
Run the following commands inside your home folder:
-
Create the script needed to run the container
Save the following script as
nodered_run.sh
:Instructions:
- Optional Replace
docker
withpodman
if needed - Optional Replace
--net=host
with ports to pass through if you want to expose ports. Here is described how to check if ports are available. Make sure port1880
is available - Optional Replace
$PWD/data
with the location of your data if needed. This can be a fileserver mount - Optional Replace
<key>
with your own key which you can specify insettings.js
. Otherwise a key will be automatically generated - Required Replace
Europe/Amsterdam
with your own timezone
- Optional Replace
-
Run the script to create the container
Run the following command:
The image
nodered/node-red
is automatically pulled and the container is created. -
Enable authentication (optional)
Because I use Home Assistant nodes within Node-RED but also, for example, an SSH node, I have set up authentication to make it a bit more secure.
Make sure the Node-RED container is running and generate a hash for the password you want to use:
Enter the password you want to use for Node-RED and copy the hash to memory.
Now adjust the following in the
nodered/data/settings.js
file:Instructions:
- Required Replace
<username>
with your username,admin
for example - Required Replace
<hash>
with the hash you generated earlier. Copy the hash from memory - Optional Replace
*
if needed to change the permissions
Restart the Node-RED container. Run the following command:
- Required Replace
-
Install additional nodes (optional)
The container uses the
/data
directory as the user configuration directory. To add additional nodes you can open the shell into the container and run the appropriate npm install commands. Here are a few examples of nodes I always install:Instructions:
- Optional
node-red-node-wol
is a node to send Wake-On-LAN (WOL) magic packets - Optional
node-red-contrib-bigssh
(Big SSH) is an input node to execute a command over SSH to a remote host - Optional
node-red-contrib-home-assistant-websocket
are various nodes to assist in setting up automation using Node-RED communicating with Home Assistant
Restart the Node-RED container. Run the following command:
- Optional
-
Check the results
If needed you can check if the container is running properly.
Now you can use Node-RED by opening a web browser and going to:
http://localhost:1880
. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.