Deye Microinverter
This flow read the actual Power via the Modbus Frame from port 8899. Tested with the Deye sun800g3-eu-230
Config:
Add to the Cred Node Serial (from the Logger) and IP. Port should be 8899
Final Payload:
[{"id":"b078469ec2de32d6","type":"tcp in","z":"728d11d73fc23130","name":"","server":"server","host":"","port":"8899","datamode":"stream","datatype":"buffer","newline":"","topic":"","trim":false,"base64":false,"tls":"","x":340,"y":40,"wires":[["8a8e6bf7cf5bfd40"]]},{"id":"8a8e6bf7cf5bfd40","type":"tcp request","z":"728d11d73fc23130","name":"","server":"","port":"","out":"sit","ret":"buffer","splitc":" ","newline":"","trim":false,"tls":"","x":510,"y":80,"wires":[["707fa24f4dce97fe","a880e77672a63149"]]},{"id":"707fa24f4dce97fe","type":"tcp out","z":"728d11d73fc23130","name":"","host":"","port":"8899","beserver":"reply","base64":false,"end":false,"tls":"","x":680,"y":40,"wires":[]},{"id":"3328ef9a06fcc5c3","type":"function","z":"728d11d73fc23130","name":"Request Frame","func":"var status = flow.get(\"status\")\nif (status == \"online\"){\nvar b = Buffer.from([165, 23, 0, 16, 69, 0, 0, msg.payload[0], msg.payload[1], msg.payload[2], msg.payload[3], 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 60, 0, 57, 69, 212, 254, 21]);\nmsg.payload = b\nmsg.Status = \"online\"\nreturn [msg , null];\n}\nif (status == \"offline\") {\n msg.payload = {}\n msg.payload.Status = \"offline\"\n return [null, msg];\n}\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":200,"wires":[["8a8e6bf7cf5bfd40"],["4ff386be1c68b460"],[]]},{"id":"513a0f95ad621eb0","type":"buffer-parser","z":"728d11d73fc23130","name":"","data":"payload","dataType":"msg","specification":"specification","specificationType":"msg","items":[{"type":"buffer","name":"BASE","offset":0,"length":255,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"Start","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"Length","offset":1,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"ControlCode","offset":3,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int8","name":"RequestID","offset":5,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint8","name":"Counter","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"uint32le","name":"LogerSerial","offset":7,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"array","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":950,"y":100,"wires":[["b0083b70fb3c2d39"]]},{"id":"a880e77672a63149","type":"function","z":"728d11d73fc23130","name":"Set Options for Parser","func":"msg.buffer = msg.payload\nif (msg.buffer.length < 50){\n return 0\n}\nvar spec = { \"options\": { \"byteSwap\": [],\n \"resultType\": \"keyvalue\",\n \"singleResult\": true,\n \"msgProperty\": \"payload\",\n \"setTopic\": true },\n \"items\": [\n { \"type\": \"uint32le\", \"name\": \"Serial_Logger\", \"offset\": 7, \"length\": 1, \"scale\": \"1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"Current Power [W]\", \"offset\": 80, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"AC Output Frequency [Hz]\", \"offset\": 66, \"length\": 1, \"scale\": \"0.01\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"AC Current 1 [A]\", \"offset\": 60, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"AC Voltage 1 [V]\", \"offset\": 54, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"DC Voltage 1[V]\", \"offset\": 126, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"DC Current 1[A]\", \"offset\": 128, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"DC Voltage 2[V]\", \"offset\": 130, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"DC Current 2[A]\", \"offset\": 132, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"Total Prod [kWh]\", \"offset\": 34, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" },\n { \"type\": \"int16be\", \"name\": \"Prod Today [kWh]\", \"offset\": 28, \"length\": 1, \"scale\": \"0.1\", \"mask\": \"\" }\n\n ]\n }\n\nmsg.specification = spec\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":100,"wires":[["513a0f95ad621eb0","b5260b56c23d5d1a"]]},{"id":"9e7969498954a70d","type":"debug","z":"728d11d73fc23130","name":"Final Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1280,"y":200,"wires":[]},{"id":"291ccb9de5f1258a","type":"inject","z":"728d11d73fc23130","name":"Request","props":[],"repeat":"60","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":100,"y":200,"wires":[["5380d499e4983038"]]},{"id":"6bd443320799619b","type":"buffer-maker","z":"728d11d73fc23130","name":"","specification":"spec","specificationType":"ui","items":[{"name":"item1","type":"uint32le","length":1,"dataType":"msg","data":"payload"}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","x":430,"y":200,"wires":[["3328ef9a06fcc5c3"]]},{"id":"d6dce4b616253c3a","type":"ping","z":"728d11d73fc23130","protocol":"IPv4","mode":"triggered","name":"","host":"","timer":"20","inputs":1,"x":550,"y":280,"wires":[["00d9b8b6c552c625"]]},{"id":"00d9b8b6c552c625","type":"function","z":"728d11d73fc23130","name":"Set Status","func":"if (msg.payload != false ){\n flow.set(\"status\", \"online\")\n}\nif (msg.payload == false ) {\n flow.set(\"status\", \"offline\")\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":280,"wires":[[]]},{"id":"b0d47230149ea8cb","type":"change","z":"728d11d73fc23130","name":"","rules":[{"t":"move","p":"host","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":280,"wires":[["d6dce4b616253c3a"]]},{"id":"5380d499e4983038","type":"credentials","z":"728d11d73fc23130","name":"Serial","props":[{"value":"payload","type":"msg"},{"value":"host","type":"msg"},{"value":"port","type":"msg"}],"x":250,"y":200,"wires":[["6bd443320799619b","b0d47230149ea8cb"]]},{"id":"b5260b56c23d5d1a","type":"debug","z":"728d11d73fc23130","name":"Raw Buffer Response","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":980,"y":140,"wires":[]},{"id":"b0083b70fb3c2d39","type":"function","z":"728d11d73fc23130","name":"Pretty Payload","func":"msg.payload.Status = msg.Status\nmsg.payload[\"AC Current 1 [A]\"] = Number(msg.payload[\"AC Current 1 [A]\"].toFixed(3))\nmsg.payload[\"Total Prod [kWh]\"] = Number(msg.payload[\"Total Prod [kWh]\"].toFixed(2))\nmsg.payload[\"Prod Today [kWh]\"] = Number(msg.payload[\"Prod Today [kWh]\"].toFixed(2))\nmsg.payload[\"DC Current 2[A]\"] = Number(msg.payload[\"DC Current 2[A]\"].toFixed(2))\nmsg.payload[\"DC Voltage 2[V]\"] = Number(msg.payload[\"DC Voltage 2[V]\"].toFixed(2))\nmsg.payload[\"DC Current 1[A]\"] = Number(msg.payload[\"DC Current 1[A]\"].toFixed(2))\nmsg.payload[\"DC Voltage 1[V]\"] = Number(msg.payload[\"DC Voltage 1[V]\"].toFixed(2))\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":100,"wires":[["4ff386be1c68b460"]]},{"id":"4ff386be1c68b460","type":"junction","z":"728d11d73fc23130","x":1160,"y":200,"wires":[["9e7969498954a70d"]]}]