Technical Documentation: NodeRed
The Proficloud NodeRed library is a simple way to bring your data from different data sources and display it on Proficloud.io. It provides a ProficloudDevice-Node, which represents the Cloud-Device in NodeRED with all its capabilities.
Getting started
You can install the library with the manage palette dialog. Just search node-red-contrib-proficloud and install it.
You can also use the proficloud/node-red (https://hub.docker.com/repository/docker/proficloud/node-red) docker with the ProficloudNode preinstalled.
Start Docker (Docker installation required)
First you need to pull the lastest image from Docker hub:
docker pull proficloud/node-red
After pulling you are ready for the first start. The container will create a volume to store flow configs and settings persistent. To make management easier, the container should be named. So run the following command to start it:
docker run -d -it -p 1880:1880 --name <container-name> proficloud/node-red
Usage of the ProficloudDevice-Node
You can now visit NodeRED via <<ip of your host>>/node-red.
Connection
Double-Click the Connection Node. Enter the UUID of your device (Add your device to the Device Management Service of your staging account, if you haven’t already).
When AutoConnect is enabled, the Node will connect to the Proficloud.io after the configured delay. The connection state is reported in the Node-Status.
TimeSeriesData
Send a msg.payload.data object to the. It will send the data to the cloud to visualize it on a dashboard in the Time Series Data Service.
example payload:
msg = {};
msg.payload = {};
msg.payload.data = {"humidity": 12.0, "temp": 2.0};
return msg;
StateOfHealth
You can also send logs or a traffilight state to the Proficloud.io.
To send a log, the node needs a msg.payload.log object with the message and the level of the log to be displayed in the “Logs”-Panel of the Device Management Service. Neither one of them shall be missing.
example payload:
msg = {};
msg.payload = {"log": {"level": 2, "tag":"Node-RED","msg": "System started"}};
return msg;
The trafficlight of the device can be seen on the Device Management Service. The node needs a msg.payload.trafficlight object with a value for the trafficlight that represents the color (0 = Green, 1 = Orange, 2 = Red) and a message to be displayed as the device status. Neither one of them shall be missing.
example payload:
msg = {};
msg.payload = {"trafficlight": {"color": 0, "msg": "Everything is okay"}};
return msg;
Reference implementation
You can import the following flow as a reference implementation.
[{"id":"e73dae77.7b465","type":"tab","label":"Proficloud Reference","disabled":false,"info":""},{"id":"c386f827.16eb38","type":"ProficloudDevice","z":"e73dae77.7b465","uuid":"","deviceType":"NodeRED-Node","env":"Production","autostart":true,"autodelay":0,"meta_by_payload":false,"serialnumber":"","hardwareVersion":"","x":650,"y":500,"wires":[[]]},{"id":"2f7723f2.906d24","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"data\" : {\"humidity\": 12.0, \"temp\": 2.0}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":280,"wires":[["c386f827.16eb38"]]},{"id":"788d6d09.2e35ec","type":"inject","z":"e73dae77.7b465","name":"","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":220,"y":280,"wires":[["2f7723f2.906d24"]]},{"id":"60b2ef0a.8aed9","type":"comment","z":"e73dae77.7b465","name":"TimeSeriesData","info":"","x":180,"y":240,"wires":[]},{"id":"ee768abb.14ce08","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 0, \"msg\": \"Everything is okay\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":420,"wires":[["c386f827.16eb38"]]},{"id":"11d12be5.0a1a34","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":420,"wires":[["ee768abb.14ce08"]]},{"id":"ded8d7ba.28c2f","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Green","info":"","x":190,"y":380,"wires":[]},{"id":"c17f2af0.f833b8","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"log\": {\"level\": 2, \"tag\":\"Node-RED\",\"msg\": \"System started\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":720,"wires":[["c386f827.16eb38"]]},{"id":"8a321346.644d7","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":720,"wires":[["c17f2af0.f833b8"]]},{"id":"6f96f6c8.4315f8","type":"comment","z":"e73dae77.7b465","name":"Log","info":"","x":150,"y":680,"wires":[]},{"id":"726085a2.7b897c","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 1, \"msg\": \"Some warning\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":500,"wires":[["c386f827.16eb38"]]},{"id":"36dbfce5.50a28c","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":500,"wires":[["726085a2.7b897c"]]},{"id":"b2e339a0.6f9588","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Orange","info":"","x":190,"y":460,"wires":[]},{"id":"a86c7275.a4358","type":"function","z":"e73dae77.7b465","name":"","func":"msg = {};\nmsg.payload = {\"trafficlight\": {\"color\": 2, \"msg\": \"Fatal error\"}};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":440,"y":580,"wires":[["c386f827.16eb38"]]},{"id":"2f33ea50.4da396","type":"inject","z":"e73dae77.7b465","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":580,"wires":[["a86c7275.a4358"]]},{"id":"4a0ad995.ab5d6","type":"comment","z":"e73dae77.7b465","name":"TrafficLight - Red","info":"","x":180,"y":540,"wires":[]},{"id":"6a408571.4f517c","type":"comment","z":"e73dae77.7b465","name":"Reference implementation","info":"This is an example flow to show the capabilities of the ProficloudDevice-Node.\nThe inject->function combination can be replaced by the way you like to connect your application. You can also use one of the pre configured Nodes for PxC devices. Just install [this](https://www.npmjs.com/package/node-red-contrib-phoenix-contact).","x":150,"y":180,"wires":[]}]
Other data sources
Of cause it is possible to send data from any data source of node red to the Proficloud.
If you are using the preinstalled docker, nodes like OPC UA and Modbus are already installed. To get data of a PLCnext controller to node red take a look at https://www.youtube.com/watch?v=PhM6ot3CtB8&list=PLTLcz6IpeLYLidXE0y6bIwD5cBRZp7dMt&index=11.