How is Node-RED embedded?

We follow the documentation here:

http://nodered.org/docs/embedding.html

Where do I find the NodeRED settings ?

In the file root\thethingbox\thethingbox.js

The settings are there:

var userDir="/root/userdir/";
var flowDir=userDir;
var settings_nodered_ext = {
	httpAdminRoot:"/",
	httpNodeRoot: "/",
	httpNodeCors: {
		origin: "*",
		methods: "GET,PUT,POST,DELETE"
	},
	SKIP_BUILD_CHECK:true,
	userDir: userDir,
	flowDir: flowDir,
	flowFile: flowDir + "flows.json",
	secondFlowDir: "/root/thethingbox/node_modules/node-red/flow/",
	verbose: true,
	flowFilePretty: true,
	otherPropToSave: ['origin', 'extra'],
	paletteCategories:['basic', 'subflows', 'input', 'output', 'function', 'social', 'storage', 'analysis', 'advanced'],
	hiddenWorkspaces: ['system'],
	functionGlobalContext: {
		settings: settings_ttb
		,userDir: userDirc
		,settingslib: require('/root/thethingbox/settingsttb.js')
		,wpi: require('node-red/node_modules/wiring-pi') // https://www.npmjs.com/package/wiring-pi
		,CryptoJS: require('node-red/node_modules/crypto-js') // https://www.npmjs.com/package/cryptojs
		,HID: require('node-red/node_modules/node-hid') // https://www.npmjs.com/package/node-hid
	}
};
Note: the code above is the settings use for the version 2.1.0

The Node-RED settings are loaded too (since version 2.1.0) This file is located in root\thethingbox\node_modules\node-red\settings.js (http://nodered.org/docs/configuration.html) But those settings are overwritten by thethingbox :

  • uiPort
  • flowFile
  • flowFilePretty
  • userDir
  • httpAdminRoot
  • httpNodeRoot
  • httpNodeCors
  • functionGlobalContext
  • paletteCategories

How can I find its IP address ?

Connect via SSH on your thethingbox. Enter : ifconfig and the ip will be written like that :

eth0 
inet addr: 192.168.0.21

How to launch NodeRED manually from the console?

From SSH:

systemctl stop thethingbox.service
cd thethingbox
node thethingbox.js

The Thingbox expands the SDCard at first boot

At first boot, a Thingbox expands to the whole SDCard with resize2fs Script is in root\thethingbox\.auto-expand-scripts (deleted at first boot)

how to ‘npm install’ new nodes

Many nodes can be install with the “import / node” UI.

But you can add by yourself, preferably in /root/userdir to avoid erasing them with the updater.

Where are my datas?

Flows and settings are stored outside in /root/userdir Be aware that if you install additional nodes yourself, they may store their data elsewhere.

How Node-RED is integrated

NodeRED is run following the “Embedding into an existing app” as described in the Node-RED documentation here.

Where is the flow stored?

Starting with the version 1.8.0, the used flow is the dynamic merge of

  • The user flow in \root\userdir\flows.json
  • The Thingbox flows in \root\thethingbox\node_modules\node-red\flow\
  • flows in nodes

How does the menu “import / Node” work?

See here.

The log is sent to the console.

The console log is sent to console.txt in the public folder so it can be read by the client browser. There is a menu item in the NodeRED right menu that opens it.

/root/thethingbox/node_modules/node-red/public/console.txt

At boot, before starting a new console, a backup is done in a file named “previousConsole.txt”. That allows to get an error when the device freezes.

Access it using Samba from your PC:

\youDeviceName\TheThingBox\root\thethingbox\node_modules\node-red\public\previousConsole.txt

How to use the 1880 port?

Edit the PORT var in \root\thethingbox\thethingbox.js

How to add login/password?

Have a look to alexander blog: “Login for Node-Red on TheThingBox” http://www.vdsar.net/login-for-thethingbox/

I want to use HTTPS to access the Thingbox

Refer to “Use HTTPs”.

How can I access the files in the Thingbox?

The easiest way to access the files is to use your own computer: files are published on the network (using a protocol named Samba).

  • From Windows: Open a file browser and use

    \NameOfmyDevice.local

Windows 10 asks you for credentials? Follow the following tutorial to fix your network: https://tinkertry.com/how-to-change-windows-10-network-type-from-public-to-private

and you should see the files.

  • From Macintosh: In the Finder, choose “all” and you should see the device.

How to create a web server beside TheThingBox

See here.

Access the userdir (non Docker version)

\\youDeviceName\TheThingBox\root\userdir

Access the userdir (Docker version)

\\youDeviceName\TheThingBox\root\container_thethingbox\userdir

How to write Node-RED nodes for the Thingbox?

Look here: How to write a Node-RED node for the Thingbox

And here: How to make NPM Packages for The Thingbox

Back to top