gcgarner / IOTstack

docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.52k stars 582 forks source link

How to add addtional nodes to node-red? #120

Closed PapaLooser closed 4 years ago

PapaLooser commented 4 years ago

First of all great job you did, this made me looking much deeper into IOT and docker as topics!

My intention is to extend node-red with addtional nodes to the dashboard, as e.g. node-red-node-twitter and a couple of others, but I couldn't find any instructions.

Digging throught the files I saw some packages in ~/IOTstack/.templates/nodered/build.sh and in ~/IOTstack/services/nodered/Dockerfile where I added them manually, but none of them showed up finally in the dashboard.

Is there some kind of best practice on how to approach it?

Paraphraser commented 4 years ago

I don't pretend to have a full understanding of "best practice" but I also did not want to leave you hanging too long waiting for a reply so please take this advice with a few grains of salt.

Other than the SQLite node which I select in the IOTstack menu, I have added all the nodes I need via the Node-Red GUI:

  1. Open the main menu (three horizontal bars "≡" at the top, right of the Node-Red window) and choose "Manage Palette".
  2. Select the "Install" tab.
  3. Search for the node you want and click its "Install" button.

Nothing up my sleeve - Twitter nodes not installed:

TwitterNotInstalled

> Manage Palette » Install » search for node-red-node-twitter:

SearchTwitterNode

Click "Install" button. Twitter nodes now installed:

TwitterInstalled

Under the hood:

$ ls -ld ~/IOTstack/volumes/nodered/data/node_modules/node-red-node-twitter
drwxr-xr-x+ 4 root root 4096 Dec 29 09:53 /home/pi/IOTstack/volumes/nodered/data/node_modules/node-red-node-twitter

Graham said that the SQLite node could not be installed via the Palette Manager but did not explain why. SQLite is the installation that chucks out numerous compiler warnings. I have not tried omitting SQLite from the IOTstack menu and installing it via the Palette Manager. I have just (a) accepted that it is necessary for SQLite, (b) assumed that SQLite is a member of a subset of add-on nodes that must be installed this way, (c) presumed that the other node types that I have added thus far via the Palette Manager are not members of that subset, but (d) planned that should I ever encounter a node type which can't be installed via the Palette Manager, I'll propose a PR to include it in the menu.

If you're wondering whether there are any behavioural differences between node types installed via the menu vs those installed via the Palette Manager, the answer is "not that I've noticed". Both add-on nodes and flows seem to exist in the shared part of the filing system common to both Raspbian and the container so they persist across updates and get included in backups, etc. All just works.

I have not tried it but my guess is that dropping into the container to run "npm install ..." would work too.

PapaLooser commented 4 years ago

I was so focused on the command line that I didn't see the obvious!

Thanks for opening my eyes, this is just straight forward. SQlite is not yet a topic, maybe in the future. So I'm absolutely fine for now Thanks for providing this detailed explanation, I'm now 'ready to rumble' :-)