Example of usage narodmon.ru service

Note: node-red-node-narodmon must be installed with bash npm install mdef/node-narodmon

Example of usage narodmon.ru service.

"Single test sensor" will inject data directly to service. For testing purposes only. resulting payload is T4=10

"narodmon.ru function and delay."

As narodmon.ru limits posting interval to 5 minutes we should implement this in node-red flow.

In following example "narodmon.ru function" will wait until all 4 sensors sent data and after that it pushes all the data in one request to Narodmon.ru. resulting payload is T1=11&T2=23&P1=743&H1=83

[{"id":"d7c36964.283c98","type":"narodmon-server","server":"http://narodmon.ru","name":""},{"id":"e7daef40.18251","type":"function","name":"narodmon.ru","func":"context.data = context.data || new Object();\n\nswitch (msg.topic) {\n\n    case \"28.F9ECF2010000/temperature\":{\n        if (msg.payload !== \"85\"){\n        context.data.t = msg.payload;}\n        msg = null;\n        break;}\n    case \"/dev/A1Cn12_2C/Ta0/BMP180_P\":\n        norm_p = msg.payload* 0.75006 /100; \n        if (norm_p > \"650\"){\n        context.data.p = norm_p;}\n        msg = null;\n        break;\n    case \"/dev/NDUP20_48/TW16384\":\n        context.data.t2 = msg.payload * 175.72/65536-46.85;\n        msg = null;\n        break;\n    case \"/dev/NDUP20_48/TW16385\":\n        context.data.h = msg.payload *125/65536-6;\n        msg = null;\n        break;\n        \n    default:\n        msg = null;\n    \tbreak;\n\n}\n\nif(context.data.t != null && context.data.t2 != null && context.data.p != null && context.data.h != null) {\n\tmsg2 = new Object();\n    msg2 = context.data;\n    \n    msg2.payload = \"T1=\"+context.data.t+\"&T2=\"+context.data.t2+\"&P1=\"+context.data.p+\"&H1=\"+context.data.h;\n\tcontext.data=null;\n\treturn msg2;\n} else return msg;","outputs":"1","valid":true,"x":248,"y":705,"z":"fe405ad8.01bfa8","wires":[["7e984474.8167bc"]]},{"id":"7e984474.8167bc","type":"delay","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"10","rateUnits":"hour","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":443,"y":731,"z":"fe405ad8.01bfa8","wires":[["3519da8a.cae626"]]},{"id":"3519da8a.cae626","type":"narodmon","name":"Narodmon","narodmonServer":"d7c36964.283c98","nodegroup":"","x":480,"y":800,"z":"fe405ad8.01bfa8","wires":[]},{"id":"c9926937.366d98","type":"inject","name":"Single test sensor","topic":"","payload":"T4=10","payloadType":"string","repeat":"","crontab":"","once":false,"x":219,"y":805,"z":"fe405ad8.01bfa8","wires":[["3519da8a.cae626"]]}]
mdef

Flow Info

created 2 years, 1 month ago

Node Types

Core
  • delay (x1)
  • function (x1)
  • inject (x1)
Other
  • narodmon (x1)
  • narodmon-server (x1)

Tags

  • narodmon
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option