[ { "id": "87454c86.a84978", "type": "mqtt in", "z": "7be57b1.f9b0984", "name": "", "topic": "/90F4AABF713C/siarq/loraData", "qos": "2", "broker": "168238c.51df3c7", "x": 190, "y": 420, "wires": [ [ "c9837e5f.1fb9b", "d5b5c881.6ec26" ] ] }, { "id": "fdbb278f.998808", "type": "function", "z": "7be57b1.f9b0984", "name": "-> SoC,Vbat,Ibat,PL,PPV,VPV,KwhConsumed,KwhGenerated,T,H", "func": "var data = msg.payload;\n\n// Create a buffer\nvar bufSoC = new ArrayBuffer(2);\nvar bufVbat = new ArrayBuffer(2);\nvar bufIbat = new ArrayBuffer(2);\nvar bufPL = new ArrayBuffer(2);\nvar bufPPV = new ArrayBuffer(2);\nvar bufVPV = new ArrayBuffer(2);\nvar bufKwhConsumed = new ArrayBuffer(2);\nvar bufKwhGenerated = new ArrayBuffer(2);\nvar bufT = new ArrayBuffer(2);\nvar bufH = new ArrayBuffer(2);\n\n// Create a data view of it\nvar viewSoC = new DataView(bufSoC);\nvar viewVbat = new DataView(bufVbat);\nvar viewIbat = new DataView(bufIbat);\nvar viewPL = new DataView(bufPL);\nvar viewPPV = new DataView(bufPPV);\nvar viewVPV = new DataView(bufVPV);\nvar viewKwhConsumed = new DataView(bufKwhConsumed);\nvar viewKwhGenerated = new DataView(bufKwhGenerated);\nvar viewT = new DataView(bufT);\nvar viewH = new DataView(bufH);\n\n// set bytes\ndata.forEach(function (b, i) {\n\tif(i === 0){\n\t\tviewSoC.setInt8(1, b);\n\t\tviewSoC.setInt8(0, 0);\n\t}\n\tif(i == 1)\n\t\tviewVbat.setInt8(0, b);\n\tif(i == 2)\n\t\tviewVbat.setInt8(1, b);\n\tif(i == 3)\n\t\tviewIbat.setInt8(0, b);\n\tif(i == 4)\n\t\tviewIbat.setInt8(1, b);\n\tif(i == 5)\n\t\tviewPL.setInt8(0, b);\n\tif(i == 6)\n\t\tviewPL.setInt8(1, b);\n\tif(i == 7)\n\t\tviewPPV.setInt8(0, b);\n\tif(i == 8)\n\t\tviewPPV.setInt8(1, b);\n\tif(i == 9)\n\t\tviewVPV.setInt8(0, b);\n\tif(i == 10)\n\t\tviewVPV.setInt8(1, b);\n\tif(i == 11)\n\t\tviewKwhConsumed.setInt8(0, b);\n\tif(i == 12)\n\t\tviewKwhConsumed.setInt8(1, b);\n\tif(i == 13)\n\t\tviewKwhGenerated.setInt8(0, b);\n\tif(i == 14)\n\t\tviewKwhGenerated.setInt8(1, b);\n\tif(i == 15)\n\t\tviewT.setInt8(0, b);\n\tif(i == 16)\n\t\tviewT.setInt8(1, b);\n\tif(i == 17)\n\t\tviewH.setInt8(0, b);\n\tif(i == 18)\n\t\tviewH.setInt8(1, b);\n});\n\nvar numSoC = viewSoC.getInt16(0);\nvar numVbat = viewVbat.getInt16(0);\nnumVbat = Math.round(numVbat)/100;\nvar numIbat = viewIbat.getInt16(0);\nnumIbat = Math.round(numIbat)/100;\nvar numPL = viewPL.getInt16(0);\nnumPL = Math.round(numPL)/100;\nvar numPPV = viewPPV.getInt16(0);\nnumPPV = Math.round(numPPV)/100;\nvar numVPV = viewVPV.getInt16(0);\nnumVPV = Math.round(numVPV)/100;\nvar numKwhConsumed = viewKwhConsumed.getInt16(0);\nnumKwhConsumed = Math.round(numKwhConsumed)/100;\nvar numKwhGenerated = viewKwhGenerated.getInt16(0);\nnumKwhGenerated = Math.round(numKwhGenerated)/100;\nvar numT = viewT.getInt16(0);\nnumT = Math.round(numT)/100;\nvar numH = viewH.getInt16(0);\nnumH = Math.round(numH)/100;\n// Done\nvar msgSoC = { payload:numSoC };\nvar msgVbat = { payload:numVbat };\nvar msgIbat = { payload:numIbat };\nvar msgPL = { payload:numPL };\nvar msgPPV = { payload:numPPV };\nvar msgVPV = { payload:numVPV };\nvar msgKwhConsumed = { payload:numKwhConsumed };\nvar msgKwhGenerated = { payload:numKwhGenerated };\nvar msgT = { payload:numT };\nvar msgH = { payload:numH };\n\nflow.set(\"numSoC\",numSoC);\nflow.set(\"numVbat\",numVbat);\nflow.set(\"numT\",numT);\nflow.set(\"numH\",numH);\n\nreturn [msgSoC,msgVbat,msgIbat,msgPL,msgPPV,msgVPV,msgKwhConsumed,msgKwhGenerated,msgT,msgH];\n", "outputs": 10, "noerr": 0, "x": 330, "y": 680, "wires": [ [ "87b96217.7b65d" ], [ "d336f3c2.3f829" ], [ "55db593b.3028b" ], [ "2ecac3f1.f8424c" ], [ "7a21f7ec.f70298" ], [ "5dc2b055.bd8a9" ], [ "eb3cd52b.7809c" ], [ "bb015b4b.42347" ], [ "b905381c.1df1e" ], [ "e5780881.7c83d" ] ] }, { "id": "87b96217.7b65d", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_SoC", "precision": "", "retentionPolicy": "", "x": 830, "y": 500, "wires": [] }, { "id": "d336f3c2.3f829", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_vBat", "precision": "", "retentionPolicy": "", "x": 830, "y": 540, "wires": [] }, { "id": "55db593b.3028b", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_iBat", "precision": "", "retentionPolicy": "", "x": 820, "y": 580, "wires": [] }, { "id": "2ecac3f1.f8424c", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_pL", "precision": "", "retentionPolicy": "", "x": 820, "y": 620, "wires": [] }, { "id": "7a21f7ec.f70298", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_pPV", "precision": "", "retentionPolicy": "", "x": 830, "y": 660, "wires": [] }, { "id": "5dc2b055.bd8a9", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_vPV", "precision": "", "retentionPolicy": "", "x": 820, "y": 700, "wires": [] }, { "id": "eb3cd52b.7809c", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_kwhConsumedDay", "precision": "", "retentionPolicy": "", "x": 870, "y": 740, "wires": [] }, { "id": "bb015b4b.42347", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_kwhGeneratedDay", "precision": "", "retentionPolicy": "", "x": 870, "y": 780, "wires": [] }, { "id": "b905381c.1df1e", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_T", "precision": "", "retentionPolicy": "", "x": 820, "y": 820, "wires": [] }, { "id": "e5780881.7c83d", "type": "influxdb out", "z": "7be57b1.f9b0984", "influxdb": "9c957dce.29bf1", "name": "", "measurement": "f04_H", "precision": "", "retentionPolicy": "", "x": 820, "y": 860, "wires": [] }, { "id": "d5b5c881.6ec26", "type": "function", "z": "7be57b1.f9b0984", "name": "From base64", "func": "msg.payload = new Buffer(msg.payload, 'base64');\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 340, "y": 520, "wires": [ [ "fdbb278f.998808" ] ] }, { "id": "ff21e251.2dc96", "type": "mqtt in", "z": "7be57b1.f9b0984", "name": "", "topic": "/30E2AABF713C/siarq/loraData", "qos": "2", "broker": "168238c.51df3c7", "x": 190, "y": 380, "wires": [ [ "d5b5c881.6ec26", "c9837e5f.1fb9b" ] ] }, { "id": "168238c.51df3c7", "type": "mqtt-broker", "z": "", "name": "eCat broker", "broker": "iot.electronics.cat", "port": "8883", "tls": "", "clientid": "", "usetls": true, "compatmode": true, "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "closeTopic": "", "closeQos": "0", "closePayload": "", "willTopic": "", "willQos": "0", "willPayload": "" }, { "id": "9c957dce.29bf1", "type": "influxdb", "z": "", "hostname": "127.0.0.1", "port": "8086", "protocol": "http", "database": "CamalleraMeteo", "name": "InfluxDB_CamalleraMeteo", "usetls": false, "tls": "" } ]