Using Node-RED with Domatica Quantum System

This video is to explain how to use Node-RED with Domatica Quantum System. We will use Rest Commands to receive and to send data to the Domatica Quantum Node.

You can find all the code in this video description, below.

The steps:

  1. Open your Node-RED in your browser, and the first thing to do add an Inject Node;
  2. Then, we will need a function node which will define the body of our http request;
  3. Then, we need an http request node.
  4. Next, we need another function to parse the response message, to show only the data we need;
  5. And finally, we need a Gauge node to show our temperature in a dashboard.

In the Inject node, we will have a 5 seconds cyclic injection to trigger the request. The Body Function, is where it’s defined the body of the http request. It is passes as the message payload.

In the Http request node, we will use the POST method and insert the URL. The Parse function is where we parse the response to show only the data, and we divide it by 100, to show correctly the decimal places.

Finally, we use a gauge to show the Temperature value in a dashboard in degrees Celsius. Now, connect all the nodes together and deploy.

To see the dashboard, open a new browser tab and write your node-red address plus slash U I. And you can see the data from the Domatica Quantum System.


[{"id":"1f463d74.759c43","type":"inject","z":"9ab541b1.a0064","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"x":183,"y":45,"wires":[["1cf2de15.3fab42"]]},{"id":"1cf2de15.3fab42","type":"function","z":"9ab541b1.a0064","name":"Body","func":"msg.payload = '{\"gTokens\": [{\"vGatewayId\": 1311768465454927053,\"gToken\": \"39992D9EF2E8928039BA0BAF8D02A8A0\"}],';\nmsg.payload += '\"objects\": [{\"vGatewayId\": 1311768465454927053,\"idname\": \"DCS_TEMPERATURE.instShowValue\",\"data\": \"\"}]}';\nreturn msg;","outputs":1,"noerr":0,"x":361,"y":50,"wires":[["737da89b.6e2b08"]]},{"id":"737da89b.6e2b08","type":"http request","z":"9ab541b1.a0064","name":"","method":"POST","ret":"txt","url":"","tls":"","x":550,"y":54,"wires":[["5b6adfeb.1ab31"]]},{"id":"5b6adfeb.1ab31","type":"function","z":"9ab541b1.a0064","name":"Parse","func":"var obj = JSON.parse(msg.payload);\nmsg.payload = obj.objects[0].data/100;\nreturn msg;","outputs":1,"noerr":0,"x":753,"y":54,"wires":[["222a7c6d.b68a84"]]},{"id":"222a7c6d.b68a84","type":"ui_gauge","z":"9ab541b1.a0064","name":"Temperature","group":"5dff2d3c.a42e44","order":0,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"ºC","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1004,"y":54,"wires":[]},{"id":"5dff2d3c.a42e44","type":"ui_group","z":"","name":"METERING","tab":"a65d5b03.4bd7b8","order":1,"disp":true,"width":"6"},{"id":"a65d5b03.4bd7b8","type":"ui_tab","z":"","name":"DQS","icon":"dashboard"}]

Leave a Reply