How is Node-RED embedded?

NodeRED used following the “Embedding into an existing app” as described in the Node-RED documentation http://nodered.org/docs/embedding.html.

Where do I find the NodeRED settings ?

on the ThingBox, Node-RED is installed in /root/thethingbox/node_modules/node-red/

You can update the file /root/thethingbox/node_modules/node-red/settings.js

You can also update the javascript object settings_nodered_ext into the file /root/thethingbox/thethingbox.js that expand the settings.js of Node-RED

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 ?

Do a Avahi scan (see later)

Or for tech guys:

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 do a avahi scan for devices on the local network?

If your device has the network name home1, use the following address in a browser: http://home1.local/avahi/scan

Find your devices in the list:

{
    "Freebox-Player.local": {
        address: "192.168.0.13",
        port: "24322"
    },
    "Freebox-Server.local": {
        address: "192.168.0.254",
        port: "445"
    },
    "SEC001599D37A46.local": {
        address: "192.168.0.192",
        port: "80"
    },
    "8b92cbf4-66a6-b585-7d95-42dfe20f3b1f.local": {
        address: "192.168.0.41",
        port: "8009",
        txt: {
            rs: "YouTube",
            nf: "1",
            bs: "FA8FCA68D963",
            st: "1",
            ca: "4101",
            fn: "Chromecast TV",
            ic: "/setup/icon.png",
            md: "Chromecast",
            ve: "05",
            rm: "9FC52B50D8684F1C",
            cd: "495E077770B2FE6FA3B7928C07402729",
            id: "8b92cbf466a6b5857d9542dfe20f3b1f"
        }
    },
    "home1.local": {
        address: "192.168.0.48",
        port: "9"
    },
    "Musique.local": {
        address: "fe80::2062:2f04:b9c1:a26b",
        port: "2020",
        txt: {
            UUID: "a30e8496-5fae-4cb2-a925-b0adc7d5b803",
            Token: "cacYIvbGk4MCffZk",
            DyngateID: "673678089"
        }
    },
    "tsabed.local": {
        address: "192.168.0.5",
        port: "9"
    },
    "musicttb.local": {
        address: "192.168.0.31",
        port: "9"
    },
    "MacBook-Pro-de-Alice.local": {
        address: "192.168.0.44",
        port: "54145",
        txt: {
            rpHA: "1a2fe580b87d",
            rpVr: "120.48",
            rpHN: "90634785a3b4",
            rpHI: "959ffa6d8822",
            rpFl: "0x0",
            rpBA: "2B:07:64:5F:FF:D0"
        }
    },
    "iPhone-de-Coline.local": {
        address: "192.168.0.32",
        port: "32498"
    }
}

Where I can find the Node-RED logs ?

  • On the non docker version From samba: ~~~ \youDeviceName\TheThingBox\root\thethingbox\node_modules\node-red\public\console.txt ~~~
  • On the docker version From samba: ~~~ \youDeviceName\TheThingBox\var\log\thethingbox\console.txt ~~~

How to launch NodeRED manually from the console?

  • On the non docker version From SSH as root: ~~~ service thethingbox restart ~~~
  • On the docker version From SSH as root: ~~~ docker restart thethingbox ~~~

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 manually ‘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.

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

Set your WiFi manually

To set your WiFi manually on TheThingBox, it must be plugged into ethernet. At boot, TheThingBox display its ethernet IP address. In a web browser, enter this address to have the web interface of your TheThingBox.

Via the menu on the top right, click on the ‘settings’ button, then click on the ‘TheThingBox’ tab. On the panel ‘Static IP’, select the interface to ‘WiFi’ and click on the ‘OK’ button. On the panel ‘WiFi’, select the Wi-Fi’s network you want to use and fill its password, then click on the ‘OK’ button.

On the next boot, your TheThingBox should be connected to your WiFi’s network.

Security

As a developement tool for end users, there is no activated security.

Here are the points to be closed if a end user product is built on top.

  • Samba allows access to files from the network
  • SSH is open with root/raspberry credentials
  • NodeRED UI is not protected with credentials
  • [Not yet implemented] The MQTT command tool (should be ok since it uses a double private/public key encryption)
  • The Linux OS login available with root/raspberry credentials
  • The SDCard can be mounted and acceded as a disque in a virtual machine.

Back to top