For anyone looking in for the first time – I have a home control system based around ESP8266 boards and the odd Arduino. They talk MQTT to a Raspberry Pi which acts as a central controller – using Node-Red – the greatest thing since sliced bread. I’m in the process of putting together a (Linux) script to replicate my Raspberry Pi setup – as this is now central to controlling my various ESP8266 and Arduino gadgets around the place. I’ve learned a lot in the past few days but one last thing that was niggling me was Node-Red.

So installing Node-Red is easy enough and restoring nodes is easy enough – even specials like mine are a couple of simple operations to retrieve… for example my duskdawn node which in turn needs the sunrise node.….

cd /usr/lib/node_modules

npm install suncalc

wget –no-verbose https://bitbucket.org/scargill/duskdawn/get/0305d8365c4b.zip -O node-red-contrib-duskdawn.zip

unzip -q node-red-contrib-duskdawn.zip

mv scargill-duskdawn* node-red-contrib-duskdawn

npm install node-red-contrib-duskdawn

Looks complicated but you don’t need to understand it because it can be put in a batch file (or run a line at a time).

So all of that is “easy” enough (I put easy in quotes as it is bloody hard when you are first faced with Linux). So to install you should be in the right directory, pull in suncalc, grab my code, unzip it, move it and install it. Doddle.

What’s not so obvious are the actual flows you use in Node-Red – if you’ve seen mine you’ll see I have several pages of them – items feeding websocket to mqtt, http to mysql, experiments, comments – there is no way you’d want to manually recreate this stuff – thankfully within node-red there is the ability to select a page full of flows (or a single one) and copy and paste them – but that doesn’t help if you have many pages and you want to recreate your work in another machine.

Well, it turns out (certainly in my case) that the info is all stored in 2 files – and it also explains why all my work disappears temporarily if I log in as someone else!!!

in your user home page (might be root, might be /home/pi there is a node red directory – or maybe a hidden .node-red directory (the dot hides directories – I have winSCP set to show them all) there are a couple of files…and in the file name is embedded your hostname – so they’re not the same on all machines – and copying them won’t work unless you change the name.

SO on my main Pi2 there are files in /home/pi/.node-red called flows_OtherPi.json and flows_otherPi_cred.json – yes you guessed it – the second file contains all the login details etc you you put into your nodes. My target machine is called raspnas and in my /root/.node-red directory there were a couple of files called…. as you might suspect now, flows_raspnas.json and flows_raspnas_cred.json.

With Node-Red STOPPED, I wiped the latter, copied the files form OtherPi over and renamed them. Started Node-Red and LO – all my flows and pages work with credentials intact.

If only life in general were so easy…