[ { "id": "16727c89.d17923", "type": "tab", "label": "Push via http", "disabled": false, "info": "" }, { "id": "bf1f2d12.63a9c", "type": "inject", "z": "16727c89.d17923", "name": "", "topic": "", "payload": "", "payloadType": "date", "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "x": 130, "y": 60, "wires": [ [ "8c79aa29.d2c7c8" ] ] }, { "id": "8c79aa29.d2c7c8", "type": "function", "z": "16727c89.d17923", "name": "Random number generator", "func": "const randomValue = Math.round(Math.random() * 100);\n\nmsg.firstValue = randomValue;\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 400, "y": 60, "wires": [ [ "dd4687cd.ffd3e8" ] ] }, { "id": "b1020c3e.31963", "type": "http request", "z": "16727c89.d17923", "name": "push-to-databoom", "method": "POST", "ret": "obj", "url": "https://api.databoom.com/v1/signals/push", "tls": "", "x": 950, "y": 60, "wires": [ [ "4e35b83a.18af28" ] ] }, { "id": "dd4687cd.ffd3e8", "type": "function", "z": "16727c89.d17923", "name": "prepare-data-to-push", "func": "const now = new Date(), \nbody = () => {\n const signals = [];\n\n if (msg.firstValue) {\n\n signals.push({\n 'name': '',\n 'value': msg.firstValue\n });\n }\n \n if (msg.secondValue) {\n signals.push({\n 'name': '',\n 'value': msg.secondValue\n });\n }\n\n return {\n 'device': '',\n 'date': now.toISOString(),\n signals\n };\n},\nheaders = {\n 'Authorization': 'Bearer '\n};\n\nmsg.payload = body();\nmsg.headers = headers;\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 720, "y": 100, "wires": [ [ "b1020c3e.31963", "88ca543c.5283d8" ] ] }, { "id": "4e35b83a.18af28", "type": "debug", "z": "16727c89.d17923", "name": "log push result", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "x": 1160, "y": 60, "wires": [] }, { "id": "b8e2f726.a7aa18", "type": "inject", "z": "16727c89.d17923", "name": "timestamp-2", "topic": "", "payload": "", "payloadType": "date", "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "x": 120, "y": 140, "wires": [ [ "f3337306.3626e" ] ] }, { "id": "f3337306.3626e", "type": "function", "z": "16727c89.d17923", "name": "Random number generator", "func": "const randomValue = Math.round(Math.random() * 100);\n\nmsg.secondValue = randomValue;\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 400, "y": 140, "wires": [ [ "dd4687cd.ffd3e8" ] ] }, { "id": "88ca543c.5283d8", "type": "debug", "z": "16727c89.d17923", "name": "log-prepared-payload", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "x": 960, "y": 140, "wires": [] } ]