Node-RED¶
Info
Node-RED is used to control automations that require more settings/control than HomeKit or HomeBridge can provide natively.
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
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."
Installation¶
Prerequisites:
-
npm installed
-
Open a terminal and run
sudo npm install -g --unsafe-perm node-red
- Once you see a message from the terminal similar to
Node-RED has been successfully installed!
Welcome to Node-RED =================== 2 Oct 23:26:06 - [info] Node-RED version: v3.0.2 2 Oct 23:26:06 - [info] Node.js version: v16.16.0 ... 2 Oct 23:26:07 - [info] Started flows
- Exit Node-RED by pressing Ctrl + C (will be restarted later using pm2 to run in the background)
More information available at: https://nodered.org/docs/getting-started/local
Enabling Node-RED to start on computer boot¶
- Install PM2: In a terminal, run:
sudo npm install -g pm2
- Determine the exact location of the
node-red
command: runwhich node-red
in a terminal - Tell PM2 to run Node-Red: run
pm2 start /path/to/node-red -- -v
in a terminal, replacing/path/to/node-red
with the result ofwhich node-red
from above - Temm PM2 to run on boot: Run these commands in a terminal, and follow the instructions provided
pm2 save
pm2 startup
- Reboot the machine, and verify that PM2 has started NodeRED
More information: https://nodered.org/docs/faq/starting-node-red-on-boot
Additional Palette items¶
Once Node-RED is running and you can access via a web browser, install these additional items by clicking the three lines hamburger button in the top right, and selecting ‘Manage Palette’, then move to the ‘Install’ tab
- node-red
- node-red-contrib-cron
- node-red-contrib-homebridge-automation
- node-red-contrib-slack-files
- node-red-contrib-stoptimer
Importing Flows¶
- Go to https://github.com/AndrewBreyen/Node-RED-flows/ and pick which flow you want to start importing
- Copy the contents of desired flows’ (use the button for ease of use)
- Click the three lines hamburger button in the top right, and selecting ‘Import’
- Paste in value copied to clipboard
- Go to https://api.slack.com/apps/A03JPNEBPC4/incoming-webhooks to retrieve the Webhook URL, copy to clipboard
- Double click on the node(s)
- Paste in the Webhook URL copied to clipboard
- Double click on the and nodes, ensure that the correct device and Homebridge Pin are selected
- Repeat with the other flows you want to import
- Test it out!