-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodeRED
More file actions
1 lines (1 loc) · 1.01 KB
/
nodeRED
File metadata and controls
1 lines (1 loc) · 1.01 KB
1
[{"id":"c1aa339b.e595","type":"function","z":"19f59565.faffdb","name":"Combined T, H, PM2.5","func":"var newmsg = {};\n\ncontext.data = context.data || {};\n\n\nswitch(msg.topic){\n case \"nodeREDmanisa/sensorC/PM25\":\n context.data.PM25 = parseInt(msg.payload);\n msg = null;\n break;\n case \"nodeREDmanisa/sensorC/temperature\":\n context.data.temperature = parseFloat(msg.payload);\n msg = null;\n break;\n case \"nodeREDmanisa/sensorC/humidity\":\n context.data.humidity = parseFloat(msg.payload);\n msg = null;\n break;\n default:\n msg = null;\n break;\n}\n\nif (context.data.PM25 != null &&\n context.data.temperature != null &&\n context.data.humidity != null) {\n var time = Date(); \n context.data.time = time.toString();\n newmsg = { payload: context.data,\n topic: 'SensorA' };\n return newmsg;\n} else\n return msg;\n\n\n","outputs":1,"noerr":0,"x":600,"y":280,"wires":[["8e5a5df0.cd031"]]}]