Raspberry PI Image for Homebridge + Node-Red

I've created an image that starts with Homebridge-Raspian-Image then layers on, a Node-Red installation including a dozen Hubitat common Palettes.

In other words, it's a very good place to start if you're new to Hubitat, Node-Red or Homebridge.

[Note: I happened to choose Homebridge-Raspian-Image over HOOBS because I personally have had better luck with that image. It's just a personal preference.]

Upon boot, as with Homebridge-Raspian-Image or HOOBS, there's a wifi-direct SSID that you join with a phone or similar device and select your home's WiFi and password. It takes at least a minute perhaps two, for the SSID to appear... be patient.

SSID--> Homebridge WiFi Setup

After selecting your WiFi and entering your Wifi password, the pair of NodeJS servers will start and you can browse to them as usual:

http://<your rPi IP address>/ <-- Homebridge
http://<your rPi IP address>:1880 <-- Node-Red

Both Homebridge plugins for Hubitat are preloaded. Use either HubConnect or MakerAPI.

The following Node-Red palettes are preloaded:

  • node-red-contrib-bigtimer
  • node-red-contrib-boolean-logic-ultimate
  • node-red-contrib-castv2
  • node-red-contrib-hubitat
  • node-red-contrib-noop
  • node-red-contrib-pushover
  • node-red-contrib-state-machine
  • node-red-contrib-stoptimer2
  • node-red-contrib-string
  • node-red-contrib-time-range-switch
  • node-red-contrib-unsafe-function
  • ttb-node-red-counter

Raspbian-Homebridge-Node-Red
Note that this qualifies as the world's ugliest page. I spent no time on it... yet. :smiley:

How the Image was built

=== Create a Homebridge image and boot to it.
=== Install both Hubitat plugins and update the UI and Homebridge if needed.

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

=== and install the set of Palettes via cmd line:
cd $HOME/.node-red
npm install node-red-contrib-bigtimer
npm install node-red-contrib-boolean-logic-ultimate
npm install node-red-contrib-castv2
npm install node-red-contrib-hubitat
npm install node-red-contrib-noop
npm install node-red-contrib-pushover
npm install node-red-contrib-state-machine
npm install node-red-contrib-stoptimer2
npm install node-red-contrib-string
npm install node-red-contrib-time-range-switch
npm install node-red-contrib-unsafe-function
npm install ttb-node-red-counter

sudo systemctl enable nodered.service
node-red-start

11 Likes

Hi, I assume this Is not limited to WiFi only...and it will work via Ethernet as well, as I’d probably want a wired connection rather then wireless.

Very interested in this thanks for putting it together.

Yea, it does. At least on my RaspberryPi 3B+

Excellent thanks, just a quick question what is your recommended way of connecting HE to homebridge?

Node red is via Maker Api I believe.

If you use HubConnect already, then use the HubConnect version. Otherwise, use the MakerAPI version.

As far as I can tell the two are not significantly different. They both need to perform the same overall tasks. In my head, it's similar to Date format between the US and Europe. The information is the same, the order is different.

The HubConnect version has some additional reporting, consistent with HubConnect, while a MakerAPI version has no where to send such data. :smiley:

1 Like

One item I forgot to mention is that this Image can be JUST a Node-Red solution. You don't HAVE to use the Homebridge portion. It can sit there unused and not affect performance.

It's certainly a 'better way' of experimenting with Node-Red. As far as I know, there's no other pre-built rPi image for Node-Red, and certainly none with Hubitat centered pre-installed palettes. :slight_smile:

5 Likes

Quick question - I already have Homebridge (RPi image) and I think you told me that I could use the "curl" command in your document (How the image was built) by selecting "Terminal" from the Homebridge menu and then running the command.

On the palletes - is there a reason to install them using npm or can I just install them once I have node-red up by using the "Manage Pallete"?

Thanks.

Either works. Manage Palette is generally easier.

2 Likes

I didn't really WANT to be pedantic but at the same time, I know that Some People (and they know who they are :slight_smile: ) would like to 'bulk load' via npm, or simply feel more comfortable. I'd go with the GUI (Manage Palette) personally. All the 'goodness' is there for reading about the node and then installing, updating, deleting.

2 Likes

Thanks - I already have a version configured and working (connected to Homebridge and Hubitat) on my Mac, but I wanted to use that as a “dev” instance and have a “prod” version on the RPi. I’d installed the palettes using the GUI so I was wondering if there was a reason (permissions, default location etc.) to install via command line. Good to know that I can just use what I’ve done before.

2 Likes

@csteele - I tried the command to install node-red and it did not work. I just copied the command from your instructions - did I miss something? (I'm not Linux literate, so apologies in advance). This is the error message I get.


Thanks for your help
UPDATE: Looks like there is an extra forward slash before "<" in the command. I was able to run it without the "/" [bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)] but then got this error:

UPDATE2: I guess when the node-red installation started, it removed Node.js but could not re-install it :anguished:, and essentially bricked the Homebridge install. All turned out OK as I downloaded the pre-built Homebridge+Node-red image, flashed it to another SD card, restored by Homebridge back up (I did make one just before I started this process :grinning:) and it's back up with both running :+1:t3: :+1:t3:)

1 Like

Thanks.. yes the \ is a 'left over'. I've removed it from the webpage.

1 Like

Well - one more thing before I call it a "success"!

The pre-built image has v1.0.6 of node-red and my flows are on v1.1.1. How do I update node-red from the Homebridge+Node-Red image? I'm a little reluctant to run the install script as that apparently removes node.js (not sure why since the notes say that if node version is 8.0 or later it should leave it alone).

Will update-node-red do it? I'm assuming that I will have to run "node-red-stop", "update-node-red", "node-red-start" but looking for the correct way. Also, will I need to change to the node-red directory (I could not find the node-red directory at the root level, so not sure if it is a "hidden" directory)?

I thought I had run the upgrade to v1.1.1 myself to test it out on Thursday.. so.. I'm trying it again right now. :smiley:

It's not done yet BUT it is saying:

Leave existing Node.js - Node v12.18.0 Npm 6.14.5

Ok, it completed... no problem BUT that may be against the SD Card that already got updated. I'll build another image. (This SD Card is the one I used to create the 9 min Node-Red video, so maybe it needs rebuilding.)

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ‚úî
  Remove old version of Node-RED      ‚úî
  Remove old version of Node.js       -
  Leave existing Node.js              -   Node v12.18.0   Npm 6.14.5
  Clean npm cache                     -
   Install Node-RED core               ‚úî   1.1.0 
  Move global nodes to local          -
  Install extra Pi nodes              -
  Npm rebuild existing nodes          -
  Add shortcut commands               ‚úî
  Update systemd script               ‚úî

(I guess the Check marks don't copy/paste well.)

2 Likes

Starting from a new install of my rPi Image, I ran the script to upgrade Node-Red and got the same result 1.1.0 and no need to replace NodeJS

(Because the check marks don't copy/paste, I won't paste in a duplicate :smiley: )

1 Like

Did you run the script from your webpage or was it through npm (sudo npm install -g --unsafe-perm node-red). If from the script, should I stop both HB and NR before running the script?

It's the advice from the Node-Red website:

1 Like

Worked like a charm. Thanks a ton for your help.

@csteele - quick question. Have you installed/updated any HB plug-ins after installing node-red? I'm getting a strange error when updating the Homebridge Ring plug-in from the UI. I've posted on HB discourse and reddit but no response so far (the developer of the ring plug-in has never seen this). I have updated the ring plug in before (current version is 9.4.0, was trying to update to 9.4.1), and it has worked. Thanks.

Error

USER: pi
DIR: /usr/local/lib
CMD: sudo -E -n npm install homebridge-ring@latest

npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name "node_modules": node_modules is a blacklisted name

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2020-07-08T22_02_08_114Z-debug.log

Command failed. Please review log for details.

Detailed Log

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli 'homebridge-ring@latest'
1 verbose cli ]
2 info using npm@6.14.5
3 info using node@v12.18.0
4 verbose npm-session 15f95a8658716d8b
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/homebridge-ring 233ms
8 http fetch GET 200 https://registry.npmjs.org/homebridge-ring/-/homebridge-ring-9.4.1.tgz 176ms
9 silly pacote tag manifest for homebridge-ring@latest fetched in 443ms
10 verbose stack Error: Invalid package name "node_modules": node_modules is a blacklisted name
10 verbose stack at invalidPackageName (/usr/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:86:15)
10 verbose stack at Result.setName (/usr/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:121:11)
10 verbose stack at new Result (/usr/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:111:23)
10 verbose stack at Function.resolve (/usr/lib/node_modules/npm/node_modules/npm-package-arg/npa.js:58:15)
10 verbose stack at computeVersionSpec (/usr/lib/node_modules/npm/lib/install/deps.js:320:21)
10 verbose stack at Installer.normalizeCurrentTree (/usr/lib/node_modules/npm/lib/install.js:410:68)
10 verbose stack at Array. (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
10 verbose stack at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
10 verbose stack at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
10 verbose stack at /usr/lib/node_modules/npm/lib/install.js:368:5
10 verbose stack at /usr/lib/node_modules/npm/node_modules/iferr/iferr.js:3:64
10 verbose stack at cb (/usr/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
10 verbose stack at /usr/lib/node_modules/npm/node_modules/call-limit/call-limit.js:28:43
10 verbose stack at processTicksAndRejections (internal/process/task_queues.js:79:11)
11 verbose cwd /usr/local/lib
12 verbose Linux 4.19.97-v7l+
13 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "homebridge-ring@latest"
14 verbose node v12.18.0
15 verbose npm v6.14.5
16 error code EINVALIDPACKAGENAME
17 error Invalid package name "node_modules": node_modules is a blacklisted name
18 verbose exit [ 1, true ]

If you watched the video I created for Node-Red, you'll see I did add to the Palette.

Looking at the directory, I see:

drwxr-xr-x   3 pi pi 4096 Jun 14 22:09 node-red-contrib-bigtimer
drwxr-xr-x   4 pi pi 4096 Jun 14 22:09 node-red-contrib-boolean-logic-ultimate
drwxr-xr-x   2 pi pi 4096 Jun 14 22:09 node-red-contrib-castv2
drwxr-xr-x   6 pi pi 4096 Jun 14 22:09 node-red-contrib-hubitat
drwxr-xr-x   3 pi pi 4096 Jun 14 22:09 node-red-contrib-noop
drwxr-xr-x   4 pi pi 4096 Jun 14 22:09 node-red-contrib-pushover
drwxr-xr-x   2 pi pi 4096 Jun 14 22:09 node-red-contrib-state-machine
drwxr-xr-x   4 pi pi 4096 Jun 14 22:09 node-red-contrib-stoptimer2
drwxr-xr-x   3 pi pi 4096 Jun 14 22:09 node-red-contrib-string
drwxr-xr-x   4 pi pi 4096 Jun 14 22:09 node-red-contrib-time-range-switch
drwxr-xr-x   2 pi pi 4096 Jun 14 22:09 node-red-contrib-unsafe-function

Which looks vanilla enough...

Looking at Palette Manager, I see two need updating.. let me start there...

BooleanLogic-Ultimate & Hubitat. Says I need to reboot, but before I do, I'll install something all new...

I installed Stoptimer-Varidelay.. that worked too.. time to restart NR. Even that worked :slight_smile: