Please find below the final Node Red flow in order to scrape data from AP Systems ECU-3 Home page and the realtimedata page.
This flow is made for 6 inverters, each containing 2 solar panels. So 12 solar panels.
In case you have more or less inverters and/or panels you should modify the function node marked "Solar Production Inverters to Domoticz".
Each block of code contains the sensors available from one inverter.
1. Node marked : "5 Min Tick":
- Tick de box, before "Inject once after".
- Select "Repeat" as "Interval".
- Select the interval, you want to poll the ECU-3 (The ECU-3 is updated every 5 minutes, so a faster time is useless).
2. Node marked: "Day Time switch":
- Insert your own "Latitude"and "Longitude" co-ordinates.
3. Node marked: "HTTP AP Systems Overview Request":
- Insert your own ECU-3 URL: http://<IP Address>/index.php/home.
4. Node marked: "HTTP AP Systems Production Request":
- Insert your own ECU-3 URL: http://<IP Address>/index.php/realtimedata.
5. Node marked: "Solar Overview to Domoticz":
- Insert your own Domoticz IDX for the applicable sensors.
6. Node marked: "Solar Environmental to Domoticz":
- Insert your own Domoticz IDX for the applicable sensors.
7. Node marked: "Solar Production Inverters to Domoticz":
- Insert your own Domoticz IDX for the applicable sensors.
- if you have more than 6 inverters, copy line 6 and insert as many as needed. Number them accordingly. 7, 8, etc.
- if you have more than 6 inverters, copy line 9 - 17 and paste them in line 63. Repeat it as much as you need.
- if you have more than 6 inverters, insert msg7, msg8, etc in line 65 (straight after msg6, seperated by comma's).
- if you have less than 6 inverters, delete line 6, 5 etc.
- if you have less than 6 inverters, delete line 54-62, etc. As much as you need.
- if you have less than 6 inverters, delete msg 6, msg5, etc in line 65.
8. Node marked: "Domoticz In":
- In the Connection Tab configure the IP address of the MQTT Broker. If it runs on the same device as Node Red you can use "localhost".
- In the Security Tab configure Username/Password (if you have your MQTT broker protected with a username and password. (Recommended).
All used nodes are core Node Red nodes, except the "Day Time Switch". this node has to be installed, using the palette or from the command line;
Node name: node-red-contrib-time-switch. From the cli install the node with "npm install node-red-contrib-time-switch".
Code: Select all
[{"id":"d243b84a.4ac438","type":"tab","label":"AP Systems","disabled":false,"info":""},{"id":"63bcbc31.eb708c","type":"http request","z":"d243b84a.4ac438","name":"HTTP AP Systems Production Request","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.1.50/index.php/realtimedata","tls":"","proxy":"","x":420,"y":440,"wires":[["c3df4a05.c383"]]},{"id":"d5e45a3a.244e5","type":"debug","z":"d243b84a.4ac438","name":"HTML Output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":720,"y":500,"wires":[]},{"id":"8501a12b.61eb4","type":"inject","z":"d243b84a.4ac438","name":"5 Min Tick","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":360,"wires":[["d1c96d07.95888"]]},{"id":"c3df4a05.c383","type":"html","z":"d243b84a.4ac438","name":"Scrape inverter","property":"payload","outproperty":"payload","tag":"td","ret":"html","as":"single","x":720,"y":440,"wires":[["d5e45a3a.244e5","80391cd8.5820d8"]]},{"id":"80391cd8.5820d8","type":"function","z":"d243b84a.4ac438","name":"Create Inverter Array","func":"var i;\nfor (i = 0; i < msg.payload.length/9; i++) {\nvar InverterIDA = msg.payload[9*i+0];\nvar CurrentPowerA = msg.payload[9*i+1];\nvar GridFreq = msg.payload[9*i+2];\nvar GridVoltageA = msg.payload[9*i+3];\nvar GridTemp = msg.payload[9*i+4];\nvar GridReportTime = msg.payload[9*i+5];\nvar InverterIDB = msg.payload[9*i+6];\nvar CurrentPowerB = msg.payload[9*i+7];\nvar GridVoltageB = msg.payload[9*i+8];\nnewMsg = {payload: ([InverterIDA.substr(0,12),CurrentPowerA.slice(0,-2),GridVoltageA.slice(0,-2),CurrentPowerB.slice(0,-2),GridVoltageB.slice(0,-2),GridFreq.slice(0,-3),GridTemp.slice(0,-8)])}\nnode.send(newMsg);\n}","outputs":1,"noerr":0,"x":960,"y":440,"wires":[["7d148fd5.6837a8","752a8421.e09cf4"]]},{"id":"7d148fd5.6837a8","type":"debug","z":"d243b84a.4ac438","name":"Output APS Array","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":440,"wires":[]},{"id":"752a8421.e09cf4","type":"function","z":"d243b84a.4ac438","name":"Solar Production Inverters to Domoticz","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nvar msg4 = {};\nvar msg5 = {};\nvar msg6 = {};\n\nswitch (msg.payload[0]) {\n\n case \"404000191265\": //Inverter 1\n msg1.payload = {\"command\":\"udevice\",\"idx\":1001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":1002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":1003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":1004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":1005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":1006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n case \"404000191123\": //Inverter 2\n msg1.payload = {\"command\":\"udevice\",\"idx\":2001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":2002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":2003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":2004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":2005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":2006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n case \"404000193004\": //Inverter 3\n msg1.payload = {\"command\":\"udevice\",\"idx\":3001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":3002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":3003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":3004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":3005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":3006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n case \"404000191257\": //Inverter 4\n msg1.payload = {\"command\":\"udevice\",\"idx\":4001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":4002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":4003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":4004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":4005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":4006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n case \"404000192992\": //Inverter 5\n msg1.payload = {\"command\":\"udevice\",\"idx\":5001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":5002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":5003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":5004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":5005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":5006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n case \"404000191779\": //Inverter 6\n msg1.payload = {\"command\":\"udevice\",\"idx\":6001,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Current Power A\n msg2.payload = {\"command\":\"udevice\",\"idx\":6002,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Voltage A\n msg3.payload = {\"command\":\"udevice\",\"idx\":6003,\"nvalue\":0,\"svalue\":(msg.payload[3] + \";0\")}; //Current Power B\n msg4.payload = {\"command\":\"udevice\",\"idx\":6004,\"nvalue\":0,\"svalue\":(msg.payload[4])}; //Voltage B\n msg5.payload = {\"command\":\"udevice\",\"idx\":6005,\"nvalue\":0,\"svalue\":(msg.payload[5])}; //Frequency\n msg6.payload = {\"command\":\"udevice\",\"idx\":6006,\"nvalue\":0,\"svalue\":(msg.payload[6])}; //Temperature\n break;\n\n}\nreturn [[msg1,msg2,msg3,msg4,msg5,msg6]];","outputs":1,"noerr":0,"x":1020,"y":500,"wires":[["5bea947.a4ba1ec","fdfef99c.3962f8"]]},{"id":"5bea947.a4ba1ec","type":"debug","z":"d243b84a.4ac438","name":"Domoticz In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":500,"wires":[]},{"id":"fdfef99c.3962f8","type":"mqtt out","z":"d243b84a.4ac438","name":"Domoticz In","topic":"domoticz/in","qos":"2","retain":"false","broker":"f9f13036.e28b58","x":1530,"y":360,"wires":[]},{"id":"a1776ce7.3be728","type":"http request","z":"d243b84a.4ac438","name":"HTTP AP Systems Overview Request","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.2.88/index.php/home","tls":"","proxy":"","x":420,"y":280,"wires":[["f9cd660b.5528c","9da26ffb.4f20e"]]},{"id":"f9cd660b.5528c","type":"html","z":"d243b84a.4ac438","name":"Scrape overview","property":"payload","outproperty":"payload","tag":"td","ret":"html","as":"single","x":730,"y":260,"wires":[["f3c1c3d6.06c7b"]]},{"id":"4f709cae.43ea9c","type":"debug","z":"d243b84a.4ac438","name":"Output Overview Array","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1270,"y":260,"wires":[]},{"id":"d1c96d07.95888","type":"time-switch","z":"d243b84a.4ac438","name":"Day Time switch","lat":"52.000000","lon":"5.000000","startTime":"sunrise","endTime":"sunset","startOffset":"-30","endOffset":"+30","x":350,"y":360,"wires":[["63bcbc31.eb708c","a1776ce7.3be728"],[]]},{"id":"f3c1c3d6.06c7b","type":"function","z":"d243b84a.4ac438","name":"Create Overview Array","func":"var LifeTimeGen = msg.payload[1];\nvar LastSystemPower = msg.payload[2];\nvar CurDayGen = msg.payload[3];\nnewMsg = {payload: ([LifeTimeGen.slice(0,-4),LastSystemPower.slice(0,-2),CurDayGen.slice(0,-4)])};\nreturn newMsg;\n","outputs":1,"noerr":0,"x":970,"y":260,"wires":[["364dfbb1.e2d524","4f709cae.43ea9c"]]},{"id":"9da26ffb.4f20e","type":"html","z":"d243b84a.4ac438","name":"Scrape environment","property":"payload","outproperty":"payload","tag":"center","ret":"html","as":"single","x":740,"y":300,"wires":[["dadfb540.a207a"]]},{"id":"fed6502.196f5b","type":"debug","z":"d243b84a.4ac438","name":"Output Environmental Array","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1260,"y":300,"wires":[]},{"id":"364dfbb1.e2d524","type":"function","z":"d243b84a.4ac438","name":"Solar Overview to Domoticz","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.payload = {\"command\":\"udevice\",\"idx\":7001,\"nvalue\":0,\"svalue\":(msg.payload[0])}; //Lifetime generation\nmsg2.payload = {\"command\":\"udevice\",\"idx\":7002,\"nvalue\":0,\"svalue\":(msg.payload[1] + \";0\")}; //Last System Power\nmsg3.payload = {\"command\":\"udevice\",\"idx\":7003,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //Generation of Current Day\n\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"x":980,"y":200,"wires":[["d97e6cb5.c7c25","fdfef99c.3962f8"]]},{"id":"d97e6cb5.c7c25","type":"debug","z":"d243b84a.4ac438","name":"Domoticz In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":160,"wires":[]},{"id":"8321d666.fac028","type":"function","z":"d243b84a.4ac438","name":"Solar Environmental to Domoticz","func":"var msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\n\nmsg1.payload = {\"command\":\"udevice\",\"idx\":8001,\"nvalue\":0,\"svalue\":parseFloat((msg.payload[0]) * 3.78541178).toFixed(1)}; //CO2 Car (L)\nmsg2.payload = {\"command\":\"udevice\",\"idx\":8002,\"nvalue\":0,\"svalue\":(msg.payload[1])}; //CO2 Tree\nmsg3.payload = {\"command\":\"udevice\",\"idx\":8003,\"nvalue\":0,\"svalue\":(msg.payload[2])}; //CO2 Factory (Kg)\n\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"x":1000,"y":360,"wires":[["93b122ab.4b1ae","fdfef99c.3962f8"]]},{"id":"dadfb540.a207a","type":"function","z":"d243b84a.4ac438","name":"Create Environmental Array","func":"var CO2Car = msg.payload[0];\nvar CO2Tree = msg.payload[1];\nvar CO2Factory = msg.payload[2];\nnewMsg = {payload: ([CO2Car.slice(0,-12),CO2Tree.slice(0,-10),CO2Factory.slice(0,-7)])};\nreturn newMsg;\n","outputs":1,"noerr":0,"x":980,"y":300,"wires":[["8321d666.fac028","fed6502.196f5b"]]},{"id":"93b122ab.4b1ae","type":"debug","z":"d243b84a.4ac438","name":"Domoticz In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1290,"y":400,"wires":[]},{"id":"b0d7a44d.92a2b8","type":"comment","z":"d243b84a.4ac438","name":"Poll Home Page","info":"This node polls http://<ip address>/index.php/home","x":340,"y":220,"wires":[]},{"id":"bce11b22.56815","type":"comment","z":"d243b84a.4ac438","name":"Poll Inverter Page","info":"This node polls http://<ip address>/index.php/realtimedata","x":350,"y":500,"wires":[]},{"id":"f9f13036.e28b58","type":"mqtt-broker","z":"","name":"RPI1_ MQTT_Broker","broker":"192.168.1.10","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Success with your implementations.
In case of problems or questions, do not hesitate to ask.
Credits are also going to Bernhard (Benneton), because without his help in providing screenshots, access to the web page and the support in debugging by giving valuable feedback, the development of this flow, would not have been possible.