Node-Redby fredd


Posted on April 8, 2017 at 11:00 PM


Node Red -A node language for dowsing and twikering IoT

Node-RED is a flow-based programming tool, original developed by IBM’s Emerging Technology Services team and now a part of the JS Foundation. Original concept by Nick O’Leary and Dave Conway-Jones of IBM’s Emerging Technology Services group.

Node Red is open-source and is now a project founding projects of the JS Foundation in October 2016.

To say it very easy, Node-RED consists of a Node.js-based runtime. You point a web browser at to access the flow editor. Within the browser you can create an application by dragging nodes from your palette into a workspace, like you would do with PD or some other node based patcher like Quartz Composer. A Node Red program results a series of nodes wired together. When you have done you click on "Deploy" and the application is sent back to the runtime where it is run.

As simple as that. And yet very powerfull. Specially because it has been conceived to operate with MQTT flows as the one coming from Dowse own Mosquitto. Everything that is necessary for complex IoT integration is then either already in node-red or easily integrable using javascript

This because the palette of nodes can be easily extended by installing new elements created by the community. The flows you create can be easily shared as JSON files, and as such many ideas come to ming about how to integrate dowse flows and coding control flows for shaping your network once you start to see what is happening upon it.

This, in extreme synthesis, how it works.


As soon as I have got news of node red I set myself to test it with Dowse.

Setting up Node-Red on Mac Os X

There is a installation guide here: http://nodered.org/docs/getting-started/installation.html

For mac os x is suggested to install node using the binaries. I personally prefer to brew:

to install brew open your terminal and:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
export PATH="/usr/local/bin:$PATH"

to be sure it runs properly run

brew doctor

then:

brew install node
sudo npm install -g --unsafe-perm node-red
node-red

At this point you are ready to run node red typing in your termnal a simple command:

MBP-fredd:media fredd$ node-red
8 Apr 22:25:03 - [info]
Welcome to Node-RED
===================
8 Apr 22:25:03 - [info] Node-RED version: v0.16.2
8 Apr 22:25:03 - [info] Node.js  version: v7.5.0
8 Apr 22:25:03 - [info] Darwin 16.5.0 x64 LE
8 Apr 22:25:03 - [info] Loading palette nodes
8 Apr 22:25:06 - [info] UI started at /ui
8 Apr 22:25:07 - [warn] ------------------------------------------------------
8 Apr 22:25:07 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
8 Apr 22:25:07 - [warn] ------------------------------------------------------
8 Apr 22:25:07 - [info] Settings file  : /Users/fredd/.node-red/settings.js
8 Apr 22:25:07 - [info] User directory : /Users/fredd/.node-red
8 Apr 22:25:07 - [info] Flows file     : /Users/fredd/.node-red/flows_192.168.2.3.json
8 Apr 22:25:07 - [info] Creating new flow file
8 Apr 22:25:07 - [info] Starting flows
8 Apr 22:25:07 - [info] Started flows
8 Apr 22:25:07 - [info] Server now running at http://127.0.0.1:1880/

if more information are necessary please refer to the well made documentation site of node-red here: http://nodered.org/docs/getting-started/running

Running Node-Red with dowse

To start parsing messages from your Dowse box is very simple: get MQTT flow from your box pointing a MQTT node to it. The node can be dragged into the patch bay and tested at once with a debug node. MQTT node can be configured easily enough as in the picture (double click)

Press "deploy" and oyu should start to see dowse messages on the right n the "debug" tab. If in doubt follow the node-red tutorial first. Is very simple anyway. In the patch here below I added to blocks to transform the css dowse values in a more handy JSON data flow. Eventually you can import the following example cut and paste. You should start seeing the dowse messages in JSON flow on your messages intto the node-red browser

[{"id":"58cd70f7.edc7d8","type":"mqtt in","z":"55e8be08.f481a","name":"Dowse.it flow","topic":"#","qos":"2","broker":"2bc4d773.485868","x":287.5,"y":241.25,"wires":[["be96b1e.eeadf5"]]},{"id":"be96b1e.eeadf5","type":"csv","z":"55e8be08.f481a","name":"","sep":",","hdrin":"","hdrout":"","multi":"one","ret":"\\n","temp":"","x":446.5,"y":241.25,"wires":[["3d89a74e.45d628"]]},{"id":"3d89a74e.45d628","type":"json","z":"55e8be08.f481a","name":"","x":598.5000076293945,"y":240.25000381469727,"wires":[["c481ff4b.d62da8"]]},{"id":"c481ff4b.d62da8","type":"debug","z":"55e8be08.f481a","name":"","active":true,"console":"false","complete":"false","x":765.625,"y":240,"wires":[]},{"id":"2bc4d773.485868","type":"mqtt-broker","z":"","broker":"dowse.it","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":""}]

(end of part one...)