Node-Red

Overview #

  • based on Node.JS
  • is kind of an orchestrator
  • allows the exchange and adaption (function nodes) of data between different protocols/software
  • based on sources (inject/input node) and sinks (output node)
  • Can be integrated with Compose-ServIoTicy (for instance to act as a datasource)

Installation #

  • Download link on front page
  • Unzip on place
  • Install/upgrade Node.js - this has been tested on the Dell laptop by TIS with Ubuntu 12.04 Precise: the manual update from rel. 0.6 to rel. 0.10 has been necessary
  • installation under the Node-RED directory:
    npm install --production
  • download additional nodes, since the basic version contains only very few:
    • cd to nodes in the Node-RED directory
    • download and expand ZIP or clone repo https://github.com/node-red/node-red-nodes under this location
    • run this command to get a list of all missing Node.JS module dependencies: node red.js -v
    • now make the needed node plugins work by installing the matching Node.JS modules by npm, eg. for mongodb: npm install mongodb
    • concrete example on Dell laptop: sudo npm install mysql pg node-postgres-named sqlite3 serialport arduino-firmata wake_on_lan
  • run it:
    node red.js
  • now Node-RED is available in the webbrowser underhttp://localhost:1880

Deployment/duplication of pre-existing flows #

  • HTTP: It is possible to share JSON flow files (usually located under <node red dir>/flows_<hostname>.json) to other installations in order to simplify deployments. This can be done using a simple POST request to the active target Node-RED instance. Eg.:
  • File system: Otherwise a copy of the respective flow file into the target Node-RED directory is also possible. The file needs to be called flows_<target hostname>.json, else a configuration change is necessary. Node-RED can already be running, in which case it needs to be restarted.

Notices #

  • ServIoTicy (or Compose) is a very powerful Internet of Things (IoT) platform. It can be used as things’ data storage but also for data elaboration. Please find more informations on http://www.servioticy.com/ and http://www.compose-project.eu/. The Node-RED ServIoTicy plugin (nodes) is still maintained in Charalampos Doukas’ own repohttps://github.com/hdoukas/node-red-nodes, so you should use this one instead of the official repo when ServIoTicy is required. Originally written by Charalampos Doukas, Matthias Wallnöfer improved it a lot.
    Of course it is also possible to access the ServIoTicy API directly in JavaScript by using the HTTP module. The API is described here: http://docs.servioticy.com/
  • ServIoTicy actuations can be tracked by MQTT nodes. Here are the respective informations:http://www.servioticy.com/?page_id=273. The node needs to be configured with host localhost:1883, username, password and topic <SOId>/actions. Afterwards the JSON conversion on the message payload needs to be applied.

Plugins #

  • InTeGreen input node (120-integreen)
    • attributes host, port, frontend, call and call parameters
    • frontend, call and call parameters are dynamically assignable (by msg. attributes on input msg)
      • call parameters can be specified in both URI format (param1=value1&param2=value2…) or as JS map ({ param1: value1, param2: value2… })
  • ​​output is JSON-formatted, for get-records for instance:
    msg.payload = [{"timestamp":1409574000000,"value":27.4},{"timestamp":1409574600000,"value":27.6},...]
    msg.req = /MeteoFrontEnd/rest/get-records?station=83200MS&name=LF&seconds=10000

  • InTeGreen ServIoTicy input node which can directly feed the ServIoTicy output node (121-integreen-servioticy)
    • attributes host, port, frontend, station, datatype, seconds
    • frontend, station, datatype and seconds are dynamically assignable (by msg. attributes on input msg)
      • seconds may be typed as number or string, but needs to be a valid positive integer
    • ​​output is JSON-formatted and already in ServIoTicy format, for instance: msg.payload = 27.4, msg.lastUpdate = 1409574000
    • lastUpdate specified in UNIX timestamp format in [s]
    • it is suggested to use the InTeGreen-ServIoTicy service object generator SOgenerator.js to create a fitting schema for the chosen frontend. The tool has been written by me using Node.js and is released under the Apache 2 license compatible to Node-RED. Usage:
      • ./SOgenerator.js - asks for the InTeGreen frontend (eg. MeteoFrontEnd) and writes output on console
      • ./SOgenerator.js <frontend> - writes output on console
      • ./SOgenerator.js <frontend> <output> - writes output to output file
  • a UNIX timestamp to plain date output converter for debugging purposes has been developed. Please append “| ./convTimeInte.js” onto the curl command. Example:
    curl -i "http://ipchannels.integreen-life.bz.it/MeteoFrontEnd/rest/get-records?station=83200MS&name=LF&seconds=10000" | ./convTimeInte.js

The improved ServIoTicy nodes (120-servioticy)

  • input node (data read), returns the latest update
    • attributes host, port, soid (service object ID), stream, channel, auth token (= password)
    • soid, stream, channel are dynamically assignable (by msg. attributes on input msg)
    • output is JSON-formatted, for instance: msg.payload = 27.4,msg.lastUpdate = 1409574000
    • lastUpdate specified in UNIX timestamp format in [s]
  • output node (data write)
    • attributes host, port, soid (service object ID), stream, channel, auth token (= password)
    • soid, stream, channel are dynamically assignable (by msg. attributes on input msg)
    • lastUpdate can be provided as part of the input msg, otherwise “now” will be assumed (UNIX timestamp format in [s])
    • output is JSON-formatted and the confirmation of the correct data acquisition: msg.payload = {“channels”:{“<channel>”:{"current-value":"<value>”}},"lastUpdate":<lastUpdate>}
  • a UNIX timestamp to plain date output converter for debugging purposes has been developed. Please append “| ./convTimeServ.js” onto the curl command. Example:
    curl -i -H "Authorization: M2JhMmRkMDEtZTAwZi00ODM5LThmYTktOGU4NjNjYmJmMjc5N2UzNzYwNWItNTc2ZS00MGVlLTgyNTMtNTgzMmJhZjA0ZmIy"http://localhost:8080/<SO id>/streams/temp1/lastUpdate | ./convTimeServ.js


0 Allegati
3773 Visualizzazioni
Media (0 Voti)
Commenti
Nessun commento. Vuoi essere il primo.