Precise and Complete Requirements? An Elusive Goal
ICS INtegration with Node-RED and Open Source
1. Berlin, October 16-17 2018
ICS Integration with
Node-RED and Open Source
Stefano Pogliani - @stefanopog
Paul Withers - @paulswithers
2. Social Connections 14 Berlin, October 16-17 2018
Node-RED makes it easy to wire together the Internet of Things.
It provides a browser-based drag-drop UI for creating flows of events and deploying them to the runtime.
The light-weight runtime, built in node.js, is
ideal for edge-of-network environments or
running in the cloud.
It can be easily expanded to take add new
nodes to the palette – taking full advantage
of the node package manager (npm)
ecosystem
Introducing Node-RED
3. Social Connections 14 Berlin, October 16-17 2018
• Released on GitHub September 2013
• Apache 2 License
• 3rd party pull-requests accepted under
Contributor License Agreement
• Most contributions direct via NPM
• Active Google Group and Slack channel
• http://nodered.org
• http://flows.nodered.org
• Online flow library for examples
• Encourages sharing and reuse of flows
within the community
Open Source Development
4. Social Connections 14 Berlin, October 16-17 2018
From the edge to the cloud
Pre-installed on the default Raspberry Pi
image, Node-RED can be used out of the
box to begin creating IoT applications.
Available in the Bluemix catalog as a
Quick Start application, it takes moments
to create cloud applications that combine
services from across the platform.
9. Social Connections 14 Berlin, October 16-17 2018
• Invented by J. Paul Morrison at IBM in the early 1970’s
• A network of asynchronous processes communicating by means of
streams of structured data chunks
• Each process is a black box – it doesn’t know what has come before
it, or what comes after it; it just acts on the data it receives and
passes the result on
Flow-based Programming
https://en.wikipedia.org/wiki/Flow-based_programming
11. Social Connections 14 Berlin, October 16-17 2018
topic:
“weather/uk”
payload: “sunny!”
…
…
12. Social Connections 14 Berlin, October 16-17 2018
payload: “Jedi are totally amazing!”
payload: “Jedi are totally amazing!”
sentiment: { score: 4 }
13. Social Connections 14 Berlin, October 16-17 2018
[{"id":"8065eed5.5b7da","type":"inject","z":"a5
1f24b1.60b968","name":"","topic":"","payload":"
","payloadType":"date","repeat":"","crontab":""
,"once":false,"x":140,"y":120,"wires":[["8a1a82
96.1a05f"]]},{"id":"8a1a8296.1a05f","type":"deb
ug","z":"a51f24b1.60b968","name":"","active":tr
ue,"console":"false","complete":"false","x":350
,"y":140,"wires":[]}]
What is a Node-RED flow ?
14. Social Connections 14 Berlin, October 16-17 2018
What is a Node-RED Node ?
.js
.html
Defines the runtime behavior of the node.
Defines the node’s appearance, edit template
and help text
.json
The package.json file associated to any
nodejs package
16. Social Connections 14 Berlin, October 16-17 2018
• Index of all available nodes
• Collection of user-contributed
flows
• 500+ modules available
flows.nodered.org
17. Social Connections 14 Berlin, October 16-17 2018
ICS ready to use packages
Node-red-contrib-ibmconnections Node-red-contrib-wws Node-red-contrib-domino-rest
20. Social Connections 14 Berlin, October 16-17 2018
1. Connections Profiles
2. Connections ActivityStream (Read and Post)
3. Connections Forums
4. Create an intelligent webhook
5. Modifying a space based on a template
6. Add custom Focus to a message
7. Post a message into a space
List of demo Scenarios
22. Social Connections 14 Berlin, October 16-17 2018
On Prem
• See https://nodered.org/docs/getting-started/
• Quirks for Windows – npm global installs in
current user’s appdata. See documentation
• Docker images available, see
https://nodered.org/docs/platforms/docker
23. Social Connections 14 Berlin, October 16-17 2018
$ sudo npm install -g --unsafe-perm node-red
$ node-red
Install it locally and get wiring
Recommend: node.js 4.x & npm 2.x
24. Social Connections 14 Berlin, October 16-17 2018
IBM Cloud
• Create resource
• Node-RED Starter
• Choose name
https://github.com/node-red/node-red-bluemix-starter
27. Social Connections 14 Berlin, October 16-17 2018
Community contributed options
$ sudo docker run -dp 1880:1880 cpswan/node-red
$ git clone https://github.com/natcl/electron-node-red.git
$ cd electron-node-red
$ npm install
$ npm start
docker container
- see - https://hub.docker.com/r/cpswan/node-red/
- (others are available)
electron standalone application
- pre-reqs node.js and git
- see https://github.com/natcl/electron-node-red for details
28. Social Connections 14 Berlin, October 16-17 2018
Docker
• Problems storing data outside Docker on
Windows
• docker run -it -p 1880:1880 -v
~/node-red-data:/data --name
mynodered nodered/node-red-docker
doesn’t work
29. Social Connections 14 Berlin, October 16-17 2018
Docker – Persisting data outside container
docker volume create VOLUME_NAME
docker run -it -p 1880:1880 -v
VOLUME_NAME:/data --name CONTAINER_NAME
nodered/node-red-docker
30. Social Connections 14 Berlin, October 16-17 2018
Docker – Editing Files in Persisted Volume
• Easiest method is copy out and copy in
docker cp CONTAINER_NAME:/VOLUME_LOC HOST_LOC
docker cp HOST_LOC CONTAINER_NAME:/VOLUME_LOC
32. Social Connections 14 Berlin, October 16-17 2018
Securing Node-RED
• Add adminAuth JSON object to settings.js
• Can be credentials or Oauth/OpenID
• See https://nodered.org/docs/security
33. Social Connections 14 Berlin, October 16-17 2018
Securing Node-RED with Custom Strategy
• Create a custom files <node-red>/user-
authentication.js
• In settings.js set:
adminAuth: require("./user-authentication")
34. Social Connections 14 Berlin, October 16-17 2018
Node-RED – Adding Nodes
• In the palette, search for the nodes to add
36. Social Connections 14 Berlin, October 16-17 2018
Learn about IoT and
Node-RED over a 4
week online course
Coursera – A developer’s guide to the IoT
https://www.coursera.org/learn/developer-iot
37. Social Connections 14 Berlin, October 16-17 2018
Get hands-on experience and
learn how to convert speech to
text, analyze tone, translate
text into different languages,
send tweets through Twitter,
add audio and video
capabilities, and set up a chat
bot using the IBM Watson
Conversation service and
Facebook Messenger. And
you don’t even need any
programming experience!
https://developer.ibm.com/courses/all-courses/node-red-basics-bots/
IBM developerWorks courses
38. Social Connections 14 Berlin, October 16-17 2018
Lots of contributed
recipes for connecting
things to Watson IOT
platform - many using
Node-RED
IBM developerWorks Recipes
https://developer.ibm.com/recipes/
39. Social Connections 14 Berlin, October 16-17 2018
Collection of examples on
how to use the Watson nodes
in Node-RED (Basic and
advanced labs). The basic
labs are simple standalone
examples of how to call each
individual Watson Node-RED
nodes and the advanced labs
are where different Watson
Node-RED nodes are
combined to create more
complex applications.
GitHub courses
https://github.com/watson-developer-cloud/node-red-labs
40. Social Connections 14 Berlin, October 16-17 2018
• Good Samples
https://github.com/johnwalic
ki/TJBot-Node-RED
• Excellent Primer :
https://medium.com/@jeanc
arlbisson/how-to-train-your-
tjbot-in-node-red-
88bfb3bbe0ab
It also works on a TJBot
TJBot : https://github.com/ibmtjbot/tjbot/blob/master/README.md
41. Social Connections 14 Berlin, October 16-17 2018
Official Site : http://nodered.org
Twitter : @NodeRED
Mailing List : https://groups.google.com/forum/#!forum/node-red
Slack Channel : http://nodered.org/slack/
http://noderedguide.com/
https://medium.com/node-red
Other tutorials and guides