-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathperisist-inverter-stats.flow
1 lines (1 loc) · 2.92 KB
/
perisist-inverter-stats.flow
1
[{"id":"f957c703.0e6da","type":"mqtt in","z":"c0d188c2.4166b","name":"","topic":"modems/+/inverters/+/temperature","qos":"2","broker":"3256e0e9.783578","x":190,"y":180,"wires":[["3b010c58.7bf15c"]]},{"id":"b59dbd4b.2a2dd8","type":"mqtt in","z":"c0d188c2.4166b","name":"","topic":"modems/+/inverters/+/acPower","qos":"2","broker":"3256e0e9.783578","x":180,"y":240,"wires":[["3b010c58.7bf15c"]]},{"id":"3b010c58.7bf15c","type":"function","z":"c0d188c2.4166b","name":"Add fields and tags","func":"const parts = msg.topic.split(\"/\")\nconst value = parseFloat(msg.payload)\nif(!isNaN(value) && parts.length==5){\n msg.measurement = parts[4]\n const data = [\n {\n value: value\n },\n {\n modem: parts[1],\n inverter: parts[3]\n }\n ];\n msg.payload = data\n return msg;\n}\n","outputs":1,"noerr":0,"x":500,"y":180,"wires":[["149fcf72.dd52a1","f2dacf2e.50f2e8"]]},{"id":"f2dacf2e.50f2e8","type":"debug","z":"c0d188c2.4166b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":760,"y":120,"wires":[]},{"id":"cba885e6.c1302","type":"mqtt in","z":"c0d188c2.4166b","name":"","topic":"modems/+/inverters/+/dcPower","qos":"2","broker":"3256e0e9.783578","x":180,"y":320,"wires":[["4eb5f9e8.910a8"]]},{"id":"4eb5f9e8.910a8","type":"function","z":"c0d188c2.4166b","name":"Calculate efficiency","func":"const nominalPower = {\n \"c587\": 1060,\n \"c588\": 1200\n}\nconst parts = msg.topic.split(\"/\")\nconst value = parseFloat(msg.payload)\nif(!isNaN(value) && parts.length==5){\n const inverter = parts[3]\n const nominal = nominalPower[inverter] || 0\n const efficiency = value/nominal * 100\n const roundedEfficiency = Math.round(efficiency*10)/10\n msg.payload = roundedEfficiency\n msg.topic = `${parts[0]}/${parts[1]}/${parts[2]}/${parts[3]}/efficiency`\n return msg;\n}\n","outputs":1,"noerr":0,"x":500,"y":320,"wires":[["3b010c58.7bf15c"]]},{"id":"149fcf72.dd52a1","type":"influxdb out","z":"c0d188c2.4166b","influxdb":"75d9eb01.7ed724","name":"","measurement":"","precision":"","retentionPolicy":"","x":810,"y":180,"wires":[]},{"id":"3256e0e9.783578","type":"mqtt-broker","z":"","name":"local_mqtt","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""},{"id":"75d9eb01.7ed724","type":"influxdb","z":"c0d188c2.4166b","hostname":"insert.your.influx.server.com","port":"8443","protocol":"http","database":"solar_system","name":"Gateway Cloud Solar Sys","usetls":true,"tls":"3fca94fc.e432b4"},{"id":"3fca94fc.e432b4","type":"tls-config","z":"","name":"insert.your.influx.server.com","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","verifyservercert":false}]