Node-Red Palette: Common Choices

I would argue but I don't have the knowledge to do so. :grinning:

So, would you consider it worth it for me to move my Node Red instance into a docker moving forward or, since it is working fine, don't touch? Base your answer on the fact that I have not used Dockers previously. :grinning:

1 Like

I would run it on a separate machine as a test.. always good to have a dev NR server anyway increases PAF...

Easier to leave it as-is at this point.

If you were to try it sometime it would take (in general):

  1. Install docker
  2. Create directory where you are going to store the node-red data/config - something like /home/pi/node-red
  3. Install node-red container, pointing the data volume to the directory you created.
  4. Shut down original node-red instance, fire up the container
  5. Install all palette additions you need
  6. Shut down container, make any changes to the node-red config you want (like persistent storage settings), fire up original instance
  7. Export all config/nodes
  8. Shut down original node-red instance, fire up the container
  9. Import nodes
  10. Re-do / reconfigure any nodes that had authentication in them (could also possibly just copy the credentials file from original install to container directory).

So it isn't hard, but it is a bunch of work nonetheless. I've done it probably 10 times if I've done it once, so I can do it without much brain interaction at this point.

The good part is that since the container data location and the node-red direct install data location are separate/independent, you can flip back and forth all you want without one breaking the other.

If you have all the right palettes installed on the container, you should technically be able to shut down the container and just copy all the data from old version to new, which would be faster, but I usually just export/import.

1 Like

I created a new Alma Linux VM and installed Docker then added the Node-red container. I struggled with node-red-data/data abstraction. My goal was simply to have an empty but working Node-Red instance. I invested several hours.

I then created another Alma Linux VM and installed NodeJS then Node-Red. Obviously there was no abstraction involved. I invested fewer hours than with Docker.

The first install for each, Docker vs NodeJS, is about the same size. It took about the same time to install as well. The Docker Container is much easier to get/install, but it's bigger than Node-Red. In both cases I achieved my goal of having an empty Node-Red that I could use in place of the rPi that I use for experiments.

I can't say I ever got the Docker /data abstraction right. I got it to start with no complaints, and I counted that as done, but it's still nagging at me that it wasn't right.

:smiley: :smiley:

1 Like

Not sure what to say... There is literally 1 directory that needs to be specified when running node-red in a docker container.

docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red

-v "host machine directory to store the stuff that needs to persist":/data
e.g.
-v /home/pi/my-node-red-files:/data

From the node-red install instructions:

    docker run              - run this container, initially building locally if necessary
    -it                     - attach a terminal session so we can see what is going on
    -p 1880:1880            - connect local port 1880 to the exposed internal port 1880
    -v node_red_data:/data  - mount a docker named volume called `node_red_data` to the container /data directory so any changes made to flows are persisted
    --name mynodered        - give this machine a friendly local name
    nodered/node-red        - the image to base it on - currently Node-RED v1.2.0

I will say that some of the confusion may be from their choice of wording in the instructions "named volume". You can use a named volume, but you can also just use a host path.

I'm an ubuntu guy, but when I install I do this - pretty much all taken from the install guide:

  • Install docker
sudo apt-get update

sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io
  • Add current user to the docker group so that the current user has rights to docker:
sudo usermod -aG docker $USER
  • Make directory to store node-red data:
mkdir /home/user/node-red-data
  • reboot
  • run the container
docker run -d --restart unless-stopped -p 1880:1880 -v /home/user/node-red-data:/data --name mynodered nodered/node-red

I just did it with those steps < 3 minutes after the OS was installed had node-red running.

2 Likes

Thanks.
I'll review my attempts and PM you if I have more puzzlement. :smiley:

1 Like

:boom: bookmarked! Got it to run on Fedora with a few minor tweaks..

Thanks for this... took me about 10 mins.. even more things to play around with sigh. Very easy to spin up.

1 Like

Looking for advice, because I seem to have endless problems with the alexa nodes. I’ve tried several, I’m currently using applestrudel, which seems to be the best maintained.

My problems seems to primarily be an authentication issue. I can get everything working, but then after 24-48 hours it will reset “init with proxy” and re-establish. The nodes will say everything is working, but it no longer works. Restarting node-red fixes the problem for another 24-48 hours. Obviously, I’m using the “proxy” authentication method.

Does this happen to everyone, or is it just me? I’ve never been able to rely on the alexa nodes b/c of this. I use the “virtual-smart-home” skill, which works great and is super reliable, but more limited. The main thing I want to work is text to speech through my echo devices.

thoughts?

I use applestrudel and a cron job to initialize it every day at 3AM. I have a simple sequence that checks if the initialization worked, and if it fails, repeats it every 2.5 minutes until it succeeds.

1 Like

Hmmm. Lot of questions: Is that pretty reliable? You’re just initializing the node? How does that work? Are you running nose-red on bare metal or containerized?

Yes

Yes, and testing for success.

Bare metal.

If initialization works, then msg.payload.deviceSerial (as an output from the Initialize node) will be populated with a value. If it is, then initialization worked. If it didn't, then I repeat the process.

I’m running node red in docker, so it may take some doing. would mind sharing your cron command/script?

Sure.

However, you will need to attach a debug node to your Initialize node to discover the value of "msg.payload.deviceSerial". And then edit the node labeled "msg.payload.deviceSerial" to enter that value.

The sequence looks ugly - but it works!


[{"id":"99a12a7d4f2c2013","type":"switch","z":"b38884adda9157e1","name":"msg.payload.deviceSerial","property":"payload.deviceSerial","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1250,"y":220,"wires":[["797cec2b654fa4c1"],["8c4ac085f6512fce"]]},{"id":"18aa83bdbc4acf00","type":"alexa-remote-init","z":"b38884adda9157e1","name":"","account":"5b3978bd.f4d4e8","option":"initialise","x":1040,"y":220,"wires":[["99a12a7d4f2c2013"]]},{"id":"797cec2b654fa4c1","type":"change","z":"b38884adda9157e1","name":"reset all","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":140,"wires":[["c57ba20e4c2e3491","8c4ac085f6512fce"]]},{"id":"8c4ac085f6512fce","type":"delay","z":"b38884adda9157e1","name":"2.5m","pauseType":"delay","timeout":"150","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":770,"y":300,"wires":[["c155d6985359d764"]]},{"id":"2f6521e44ae3a45b","type":"switch","z":"b38884adda9157e1","name":"count 1-5","property":"count","propertyType":"msg","rules":[{"t":"btwn","v":"1","vt":"num","v2":"4","v2t":"num"},{"t":"eq","v":"5","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":860,"y":220,"wires":[["18aa83bdbc4acf00"],["49cd4767872a494e"]]},{"id":"c57ba20e4c2e3491","type":"counter","z":"b38884adda9157e1","name":"","init":"0","step":"1","lower":"","upper":"5","mode":"increment","outputs":"1","x":660,"y":220,"wires":[["2f6521e44ae3a45b"]]},{"id":"c155d6985359d764","type":"change","z":"b38884adda9157e1","name":"increment=1","rules":[{"t":"set","p":"increment","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":220,"wires":[["c57ba20e4c2e3491"]]},{"id":"49cd4767872a494e","type":"simpletime","z":"b38884adda9157e1","name":"Current Time","x":1070,"y":300,"wires":[["2b34c526a97e15b4"]]},{"id":"9d167757522876c8","type":"cronplus","z":"b38884adda9157e1","name":"2AM","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"topic1","payloadType":"str","payload":"on","expressionType":"cron","expression":"0 0 2 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":270,"y":220,"wires":[["c155d6985359d764"]]},{"id":"2b34c526a97e15b4","type":"template","z":"b38884adda9157e1","name":"SMS","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"AlexaTTS was not initialized after 4 attempts {{mymonthn}}/{{mydom}} {{mytimes}}","output":"str","x":1230,"y":300,"wires":[["4c964d166bea4737"]]},{"id":"4c964d166bea4737","type":"link out","z":"b38884adda9157e1","name":"SMS-out","links":["67fd4532.52d0e4","f90b7520.2bca38"],"x":1335,"y":300,"wires":[]},{"id":"5b3978bd.f4d4e8","type":"alexa-remote-account","name":"Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.4","proxyPort":"3456","cookieFile":"/home/odroid/.node-red/alexa-save","refreshInterval":"1","alexaServiceHost":"pitangui.amazon.com","amazonPage":"amazon.com","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]
3 Likes

cool, thanks. I’ve integrated it, we’ll see how it works. couple more questions to pick your brain:

do you know why this works better for you than the autoinit that is built into the node? is it just the error handling?

what functionality about the cron node do you prefer over the inject node? just flexibility?

thanks for your help

Thank you for posting this!! Was on my todo list but you saved me some dev time.

It's interesting but I am not experiencing the disconnects like @jrau272 is.

1 Like

When it fails, it fails quietly.

flexibility, and a single cron node can initiate lots of sequences at different times (using a switch node).

1 Like

I wonder if you could use a "catch" node to trap the autoinit failure?

1 Like

thats why I think there might be something else going on with my setup.

I’ve been using the alexa-status node to send me a message when it re-initializes and every time it does, it says it is successful.

I’m hopeful @aaiyar’s solution will fix my problem… time will tell!

1 Like

gotcha. that might be useful. I’ll have to play around with it and see if it is worth it. I generally try to stick with the built in nodes as much as possible (less stuff to break with an update), but I may have one or two places this would work well.

2 Likes