[ { "id": "e7a96cbb.cc45d", "type": "tab", "label": "2JCIE-BU01", "disabled": false, "info": "" }, { "id": "212c80a8.b7889", "type": "group", "z": "e7a96cbb.cc45d", "style": { "stroke": "#999999", "stroke-opacity": "1", "fill": "none", "fill-opacity": "1", "label": true, "label-position": "nw", "color": "#a4a4a4" }, "nodes": [ "81a80984.74c6f8", "548236f2.ab56c8", "17db4798.1c2278", "27f59ed9.470f92", "72805a85.eab744", "4981423a.9fd83c", "ce69d1eb.033fb", "974d71e.2e9939", "8d32f294.d1fce", "791ff00f.7ae2f" ], "x": 74, "y": 19, "w": 892, "h": 282 }, { "id": "87f0dfc0.b2bbe", "type": "group", "z": "e7a96cbb.cc45d", "style": { "stroke": "#999999", "stroke-opacity": "1", "fill": "none", "fill-opacity": "1", "label": true, "label-position": "nw", "color": "#a4a4a4" }, "nodes": [ "254db817.9cd1f8", "27065ed8.255d02", "93c3c779.9604f8", "60e40bef.ccf054", "82131f83.6c0e5", "18bdb1f5.7cebce", "cf9a18aa.9a5cf8", "23d9b208.a6533e", "b53fa163.a0935" ], "x": 74, "y": 339, "w": 872, "h": 422 }, { "id": "27065ed8.255d02", "type": "http response", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "", "statusCode": "", "headers": {}, "x": 810, "y": 660, "wires": [] }, { "id": "93c3c779.9604f8", "type": "http in", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "", "url": "/2jciebu", "method": "get", "upload": false, "swaggerDoc": "", "x": 180, "y": 440, "wires": [ [ "cf9a18aa.9a5cf8" ] ] }, { "id": "60e40bef.ccf054", "type": "Cache in", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "2JCIE-BU Historian", "cache": "54f7e7.f037b818", "keyType": "msg", "keyProperty": "topic", "valueType": "msg", "valueProperty": "payload", "useString": false, "outputs": 1, "x": 530, "y": 440, "wires": [ [ "82131f83.6c0e5" ] ] }, { "id": "82131f83.6c0e5", "type": "function", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "Convert dict to array", "func": "const values = [];\nconst data = msg.payload;\n\nfor (let key in data) {\n values.push(data[key]);\n}\nmsg.payload = values;\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "x": 540, "y": 520, "wires": [ [ "18bdb1f5.7cebce" ] ] }, { "id": "18bdb1f5.7cebce", "type": "function", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "Down Sampling", "func": "const items = [\n \"temperature\",\n \"humidity\",\n \"barometricPressure\",\n \"illuminance\",\n \"soundNoise\",\n \"etvoc\",\n \"eco2\",\n \"discomfortIndex\",\n \"heatStroke\",\n \"spectralIntensity\",\n \"seismicIntensity\"];\n\nlet data = {};\nitems.forEach(function(elem, index) {\n const list = msg.payload.map(obj => obj[elem]);\n data[elem] = {\n \"mean\": Math.round((list.reduce((acc, cur) => acc + cur) / list.length * 100)) / 100,\n \"max\": list.reduce((a,b) => Math.max(a,b)),\n \"min\": list.reduce((a,b) => Math.min(a,b)),\n }\n});\n\n\nmsg.payload = data;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "x": 520, "y": 600, "wires": [ [ "254db817.9cd1f8" ] ] }, { "id": "cf9a18aa.9a5cf8", "type": "change", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "dump", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "{\"dump\":true}", "tot": "json" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 350, "y": 440, "wires": [ [ "60e40bef.ccf054" ] ] }, { "id": "17db4798.1c2278", "type": "2JCIE-BU in", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "messageFormat": "standard", "ttl": "10000", "x": 370, "y": 200, "wires": [ [ "ce69d1eb.033fb" ] ] }, { "id": "27f59ed9.470f92", "type": "2JCIE-BU out", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "x": 500, "y": 120, "wires": [ [ "974d71e.2e9939" ] ] }, { "id": "72805a85.eab744", "type": "inject", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "10", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "getLatestSensorData", "payload": "", "payloadType": "str", "x": 230, "y": 120, "wires": [ [ "27f59ed9.470f92" ] ] }, { "id": "4981423a.9fd83c", "type": "Cache out", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "2JCIE-BU Historian", "cache": "54f7e7.f037b818", "keyType": "msg", "keyProperty": "topic", "valueType": "msg", "valueProperty": "payload", "ttlType": "msg", "ttlProperty": "", "useString": false, "x": 850, "y": 200, "wires": [] }, { "id": "ce69d1eb.033fb", "type": "change", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "Delete unused properties", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "payload.timestamp", "tot": "msg" }, { "t": "set", "p": "payload.data.timestamp", "pt": "msg", "to": "payload.timestamp", "tot": "msg" }, { "t": "set", "p": "payload", "pt": "msg", "to": "payload.data", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 590, "y": 200, "wires": [ [ "4981423a.9fd83c", "791ff00f.7ae2f" ] ] }, { "id": "974d71e.2e9939", "type": "serial out", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "serial": "6e3108f2.8e92d8", "x": 730, "y": 120, "wires": [] }, { "id": "8d32f294.d1fce", "type": "serial in", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "serial": "6e3108f2.8e92d8", "x": 170, "y": 200, "wires": [ [ "17db4798.1c2278", "548236f2.ab56c8" ] ] }, { "id": "548236f2.ab56c8", "type": "debug", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 370, "y": 260, "wires": [] }, { "id": "81a80984.74c6f8", "type": "comment", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "Get last senosr data every 10 sec", "info": "", "x": 230, "y": 60, "wires": [] }, { "id": "254db817.9cd1f8", "type": "change", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "Add sensor code", "rules": [ { "t": "set", "p": "payload.sensorCode", "pt": "msg", "to": "2JCIE-BU01", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 530, "y": 660, "wires": [ [ "27065ed8.255d02", "b53fa163.a0935" ] ] }, { "id": "23d9b208.a6533e", "type": "comment", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "Responsd down-sampling data within last 10 min", "info": "", "x": 280, "y": 380, "wires": [] }, { "id": "b53fa163.a0935", "type": "debug", "z": "e7a96cbb.cc45d", "g": "87f0dfc0.b2bbe", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 830, "y": 720, "wires": [] }, { "id": "791ff00f.7ae2f", "type": "debug", "z": "e7a96cbb.cc45d", "g": "212c80a8.b7889", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 830, "y": 260, "wires": [] }, { "id": "54f7e7.f037b818", "type": "Cache", "z": "", "name": "2JCIE-BU", "defaultTtl": "600", "checkPeriod": "1" }, { "id": "6e3108f2.8e92d8", "type": "serial-port", "z": "", "serialport": "/dev/ttyUSB0", "serialbaud": "115200", "databits": "8", "parity": "none", "stopbits": "1", "waitfor": "", "dtr": "none", "rts": "none", "cts": "none", "dsr": "none", "newline": "0", "bin": "bin", "out": "time", "addchar": "", "responsetimeout": "10000" } ]