wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

Adventures with Node-RED


Node-RED is a project that succesfully escaped "ET" - not the alien but IBM's Emerging Technology group. Build on top of node.js, Node-RED runs in many places, including the Rasberry PI and IBM Bluemix.
In Node-RED the flow between nodes is graphically represented by lines you drag between them, requiring just a little scripting to get them going.
The interesting part are the nodes that are available (unless you fancy to write your own): A large array of ready made flows with nodes and sample applications makes Node-RED extremly flexible (I wonder if it would make sense to build a workflow engine with it). In case you don't find a node you fancy, you can build your own. Not all nodes are created equal, so you need to check what works. When you run Node-RED on Bluemix, you won't get access to hardware like serial port or Bluetooth, but you gain a DNS addressable IP endpoint (you are not limited to http(s)). Furthermore, IBM provides direct access to the IBM IoT cloud, that takes the headache out of device configuration by providing an extensive library of device libraries.
So how to get additional nodes, own or others, onto Bluemix? Here are the steps:
  1. create a new application with the IoT Boilerplate
  2. link that application to version control on hub.jazz.net
  3. clone the repository locally git clone ...
  4. edit the package.json and add the item you would like to add
  5. commit and push the changes back to jazzhub and let "build and deploy" sort it out
Unfortunately, that didn't work for some of the modules and I hade to resort to the command line in my machine: npm install name-of-module --save. This updated the package.json and saved the node into the local directory. git add --all would add the files to version control and git commit -m 'Installed name of module' together with git push origin master then makes that module available in Bluemix.
You don't have node.js on your local machine? That's like a carpenter without a hammer, go get it!
The cycle time after pushing can take a few minutes. Here are the modules I tried to install:
  • Spark Core (now known as Particle): Module to talk to the Particle Cloud to interact with sensors and particle powered devices. Didn't install with a simple package.json update. Had to use npm. Once closer to home, I'll configure the sparks and run some tests.
  • Google libraries: Installing by changing the package.json only, failed for both. I had to use npm.
    • Google Services: This adds a series of nodes scattered over multiple categories: Google plus, Google places, Google calendar, Google geocoding and Google directions
    • Google Charts: Provides a chart request and response object. To be seen how that can be used
  • Base64 encoder/decoder: A great tool to turn file uploads back into binaries or add images where Base64 rules
  • Geofence: Provides a map (with search) to create geo fences to trigger flows based on fence crossing
  • Mapper: Switch values based on a map (e.g. 0=Sunday,1=Monday)
  • Swagger: Using the Swagger client, easily call Swagger compliant (a.k.a: standard web services described in Swagger) APIs. Unfortunately after installing the swagger node, node-red, in my latency challenged environment, would not load the list of nodes anymore, failing with a 502 loading swagger.js. I had to uninstall it - which seems tricky. I deleted the application and redeployed, but the swagger module was still loaded. I ended up wiping application and version control and start over.
There are a few more modules to look at, but I ran out of time, so there will be a part 2. Deployment took anything between 90 sec and well into 6 minutes.
I haven't tested the usefulness of that nodes, that's a story for another time. As usual: YMMV

Posted by on 02 June 2015 | Comments (0) | categories: Bluemix

Comments

  1. No comments yet, be the first to comment