Installing Node-RED on a Wiren Board controller manually
This is an outdated installation method. Starting with the testing release (based on Debian Trixie), Node-RED is installed on the controller as a ready-made wb-node-red package with a single command — see the main instruction.
Description
This page describes manual installation of Node-RED on the controller via npm. The wb-node-red package works only on releases based on Debian Trixie, so on earlier releases install Node-RED following this instruction.
If you need a newer version of Node-RED than the one installed via npm, use installation in Docker.
Installation
To avoid losing installed software and its data, update the controller software only using the apt package manager. For details, see Wiren Board Software.
The controller's built-in flash storage is divided into partitions, and the largest one, mounted at /mnt/data, is reserved for the user. Keep this in mind when installing software and when updating the controller firmware.
Copy the commands from the instructions, paste them into controller console using the Shift+Insert keys and run with the Enter key. In case of errors, carefully read the output, there will be instructions and hints.
Install the required components:
apt update && apt install -y nodejs git make g++ gcc build-essential
Start the Node-RED installation:
npm install -g --unsafe-perm node-red
If you need to update the Node-RED version, run the installation command again.
Creating a service
To start Node-RED automatically, you need to set up a service. To do this, create a nodered.service file in the /etc/systemd/system/ folder:
nano /etc/systemd/system/nodered.service
Then paste the following lines into this file:
[Unit] Description=Node-RED graphical event wiring tool Wants=network.target [Service] Type=simple User=root Group=root WorkingDirectory=/home Nice=5 Environment="NODE_OPTIONS=--max_old_space_size=256" ExecStart=/usr/bin/env node-red $NODE_OPTIONS $NODE_RED_OPTIONS KillSignal=SIGINT Restart=on-failure SyslogIdentifier=Node-RED [Install] WantedBy=multi-user.target
Save the changes and close the file. Now enable the service and start it with the command:
systemctl enable nodered && systemctl start nodered
Check the service status with the command; the output should contain the line Active: active (running):
# systemctl status nodered
● nodered.service - Node-RED graphical event wiring tool
Loaded: loaded (/etc/systemd/system/nodered.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-12-03 06:32:25 UTC; 24s ago
Main PID: 2757 (node)
CGroup: /system.slice/nodered.service
└─2757 node /usr/bin/node-red --max_old_space_size=256
Dec 03 06:32:25 wirenboard-AWQBNTYP systemd[1]: Started Node-RED graphical event wiring tool.
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: 3 Dec 06:32:36 - [info]
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: Welcome to Node-RED
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: ===================
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: 3 Dec 06:32:36 - [info] Node-RED version: v2.1.4
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: 3 Dec 06:32:36 - [info] Node.js version: v12.19.0
Dec 03 06:32:36 wirenboard-AWQBNTYP Node-RED[2757]: 3 Dec 06:32:36 - [info] Linux 5.10.35-wb6 arm LE
Dec 03 06:32:41 wirenboard-AWQBNTYP Node-RED[2757]: 3 Dec 06:32:41 - [info] Loading palette nodes
Node-RED web interface
After starting the service, open a browser and enter the address of your controller on the network and port 1880. For example: http://192.168.42.1:1880
Configuring access to the Node-RED interface
When Node-RED is started for the first time, access to the web interface is not restricted. If you need to control which actions users can perform in the Node-RED interface, configure the access level as follows:
- Run the command in the controller console
node-red admin hash-pw
- Then enter a password and press Enter. The system will output a hash of the entered password. Copy it and use it later.
- Run the command in the controller console
nano /root/.node-red/settings.js- A text editor will open.
- Find the
adminAuthblock:
//adminAuth: {
// type: "credentials",
// users: [{
// username: "admin",
// password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcx>
// permissions: "*"
// }]
//},
- Uncomment it.
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcx>
permissions: "*"
}]
},
- Enter a user name in the
usernamefield. Enter the previously copied password hash in thepasswordfield.- Configuration example:
adminAuth: { type: "credentials", users: [{ username: "wirenboard", password: "$2y$08$EODPHZ9o5pXn2uOj8EPyTOxfpKbdmJWSZupINKuQZAz/pZ1v0lay6", permissions: "*" }] },
- If the
permissionsvalue is set to"*", it means the user has full access to all functions and features of the Node-RED interface.
- Save the changes with Ctrl+O.
- Restart Node-RED with the command
systemctl restart nodered
If you need to configure one more access level, repeat steps 1 — 3. Then add parameters for one more user with the required access rights to the same block. Save the changes and restart Node-RED.
Configuration example:
adminAuth: {
type: "credentials",
users: [{
username: "wirenboard",
password: "$2y$08$EODPHZ9o5pXn2uOj8EPyTOxfpKbdmJWSZupINKuQZAz/pZ1v0lay6",
permissions: "*"
},
{
username: "user",
password: "$2y$08$xaV6PiE0Pq5tRzZPndY7wOOY0ybBdK9aygscSxiu4qoLAA7Tc8yza",
permissions: "read"
}]
},
The permissions values can be as follows:
"read": allows read-only access;"write": allows writing (for example, changing flows);"delete": allows deletion;"deploy": allows deploying changes;"*": full access to all functions and features.
Troubleshooting
Sometimes, if there is an error in a flow, the Node-RED web interface may stop loading; in this case, check the nodered service logs.
If the logs show an error in a flow:
- Connect to the controller via SSH.
- Stop the service if it is running:
systemctl stop nodered
- Start Node-RED in safe mode:
node-red --safe
- Identify the problem and stop the Node-RED instance running in safe mode.
- Start the service again:
systemctl start nodered
If you installed Node-RED in Docker, use the instructions on the Installing Node-RED in Docker page.
Removal
If you are migrating to the wb-node-red package, do not delete the ~/.node-red directory until you have moved your flows following the instructions.
If you no longer need Node-RED, you can remove it:
- Stop, disable and remove the service:
systemctl stop nodered && systemctl disable nodered && rm /etc/systemd/system/nodered.service
- Remove Node-RED itself:
npm -g remove node-red && npm -g remove node-red-admin && rm -R ~/.node-red
Node.js can also be removed, but make sure you do not have other installed programs that use it, for example, zigbee2mqtt. To remove node.js, run the command:
apt remove nodejs