Skip to content

Instantly share code, notes, and snippets.

@tinywiz
Last active November 6, 2022 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinywiz/2d3bf12a43a6c2505179fa20d16f754d to your computer and use it in GitHub Desktop.
Save tinywiz/2d3bf12a43a6c2505179fa20d16f754d to your computer and use it in GitHub Desktop.
Kostal Piko inverter - reader and data parser

##** For Kostal Piko inverters **##

You need to set the ip, username and password in the request node.

The flow reads data every 5 seconds (changable in first node) and then parses the data into msg.payload. A global variable is also set to the name "kostal" that contains an object with all data.

The following data is read and returned to msg.payload:

  • acPowerCurrent // Current power ex. "596" (= 596 W)
  • totalEnergy // Totalt energy from start, ex. "10596" (= 10596 kWh)
  • dailyEnergy // Totalt energy generated today, ex. "3415" (= 3.415 kWh)
  • status // Status of inverter ex. "off", "standby"...
  • string1voltage // Voltage on string 1, ex. "695" (= 695 V)
  • string1current // Current on string 1, ex. "5.12" (= 5.12 A)
  • string2voltage // Voltage on string 2, ex. "755" (= 755 V)
  • string2current // Current on string 2, ex. "2.42" (= 2.42 A)
  • line1voltage // Voltage of L1, ex. "231" (= 231 V)
  • line1power // Energy on L1, ex. "1354" (= 1.354 kW)
  • line2voltage // Voltage of L2, ex. "235" (= 235 V)
  • line2power // Energy on L2, ex. "854" (= 0.854 kW)
  • line3voltage // Voltage of L3, ex. "230" (= 230 V)
  • line3power // Energy on L3, ex. "2198" (= 2.198 kW)
  • efficiency // Efficiency of inverter ex. "87" (= 87%) // Soon to be implemented

You can also read the data from any node/flow by reading the global variable: "kostal" msg.payload = global.get("kostal")

[{"id":"4ad0e46.7796d1c","type":"function","z":"298e6055.ffac3","name":"parse http","func":"acPowerCurrent = parseInt(msg.payload[14].replace(/([^a-z0-9]+)/gi, ''));\ntotalEnergy = parseInt(msg.payload[17].replace(/([^A-Z0-9]+)/gi, ''));\ndailyEnergy = parseInt(msg.payload[26].replace(/([^a-z0-9]+)/gi, ''))/100;\nstring1voltage = parseInt(msg.payload[56].replace(/([^a-z0-9]+)/gi, ''));\nstring1current = parseInt(msg.payload[65].replace(/([^a-z0-9]+)/gi, ''))/100;\nstring2voltage = parseInt(msg.payload[82].replace(/([^a-z0-9]+)/gi, ''));\nstring2current = parseInt(msg.payload[91].replace(/([^a-z0-9]+)/gi, ''))/100;\nline1voltage = parseInt(msg.payload[59].replace(/([^a-z0-9]+)/gi, ''));\nline1power = parseInt(msg.payload[68].replace(/([^a-z0-9]+)/gi, ''));\nline2voltage = parseInt(msg.payload[85].replace(/([^a-z0-9]+)/gi, ''));\nline2power = parseInt(msg.payload[94].replace(/([^a-z0-9]+)/gi, ''));\nline3voltage = parseInt(msg.payload[111].replace(/([^a-z0-9]+)/gi, ''));\nline3power = parseInt(msg.payload[120].replace(/([^a-z0-9]+)/gi, ''));\nstatus = msg.payload[32].replace(/\\r?\\n|\\r/g, '').replace(/\\s/g, \"\");\n\n\nif (Number.isNaN(acPowerCurrent) === true){\n acPowerCurrent = 0;\n}\nif (Number.isNaN(totalEnergy) === true){\n totalEnergy = -1;\n}\nif (Number.isNaN(dailyEnergy) === true){\n dailyEnergy = 0;\n}\nif (Number.isNaN(string1voltage) === true){\n string1voltage = 0;\n}\nif (Number.isNaN(string1current) === true){\n string1current = 0;\n}\nif (Number.isNaN(string2voltage) === true){\n string2voltage = 0;\n}\nif (Number.isNaN(string2current) === true){\n string2current = 0;\n}\nif (Number.isNaN(line1voltage) === true){\n line1voltage = 0;\n}\nif (Number.isNaN(line1power) === true){\n line1power = 0;\n}\nif (Number.isNaN(line2voltage) === true){\n line2voltage = 0;\n}\nif (Number.isNaN(line2power) === true){\n line2power = 0;\n}\nif (Number.isNaN(line3voltage) === true){\n line3voltage = 0;\n}\nif (Number.isNaN(line3power) === true){\n line3power = 0;\n}\n\nmsg.payload = {\n \"acPowerCurrent\" : acPowerCurrent,\n \"totalEnergy\" : totalEnergy,\n \"dailyEnergy\" : dailyEnergy,\n \"status\" : status,\n \"string1voltage\" : string1voltage,\n \"string1current\" : string1current,\n \"string2voltage\" : string2voltage,\n \"string2current\" : string2current,\n \"line1voltage\" : line1voltage,\n \"line1power\" : line1power,\n \"line2voltage\" : line2voltage,\n \"line2power\" : line2power,\n \"line3voltage\" : line3voltage,\n \"line3power\" : line3power\n}\n\nglobal.set(\"kostal\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":70,"wires":[["c4a0537.01675b"]]},{"id":"fd1711f2.7e7b4","type":"http request","z":"298e6055.ffac3","name":"kostal","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.1.99/index.fhtml","tls":"","persist":false,"proxy":"","authType":"basic","x":550,"y":70,"wires":[["3f445786.6a93b8"]]},{"id":"3f445786.6a93b8","type":"html","z":"298e6055.ffac3","name":"","property":"payload","outproperty":"payload","tag":"td","ret":"text","as":"single","x":700,"y":70,"wires":[["4ad0e46.7796d1c"]]},{"id":"b32e7821.c1dc78","type":"inject","z":"298e6055.ffac3","name":"5 sec","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":400,"y":70,"wires":[["fd1711f2.7e7b4"]]}]
@Larnak23
Copy link

Dear all
I have the following errors :
TypeError: Cannot read property 'replace' of undefined"

@Larnak23
Copy link

Dear All

the previous issue is no more generated
I had another one, in fact the information seems not to be reported to my mosquitto system in Hassio
Could you help me
best regards

@tinywiz
Copy link
Author

tinywiz commented Mar 24, 2020

Hi.

I'm not using Hassio so I can't help you there.
Do you know in what format Hassio wants to get the data?

@Larnak23
Copy link

No unfortunately I have no idea.

@Larnak23
Copy link

red

@Larnak23
Copy link

The system is connected to the PIKO, but no data is available in the MQTT

@Eraser-1
Copy link

Eraser-1 commented Oct 8, 2020

Hi
I have tried this flow with my Piko 4.2, but I also get the message "TypeError: Cannot read property 'replace' of undefined".
The IP is set to the inverter address, user and password also.

From the HTTP request node I get the following:

"<HTML><HEAD><TITLE>SEVENSTAX webserver</TITLE></HEAD><DIV ALIGN=CENTER><FONT SIZE=+4><BR><BR><BR>Sorry, the requested file does not exist on this server.</FONT></DIV></HTML>"

If i change the Http-Url to index.html instead of index.fhtml, I get the following:

8.10.2020, 10:10:57node: 3f6d3ab4.441996 msg.payload : string[3878] "<!DOCTYPE html>↵<html ng-app="kbApp" ng-controller="kbAppCtrl">↵<head>↵ <link rel="icon" href="/assets/favicon.ico">↵ <title ng-bind="inverterTypeName + ' <> ' + inverterName"></title>↵ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>↵ <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>↵ <!--Deaktivate Chaching to avoid problems-->↵ <meta http-equiv="cache-control: private, max-age=0, no-cache" content="no-store" />↵ <meta http-equiv="expires" content="0" />↵ <meta http-equiv="pragma" content="no-cache" />↵↵ <!-- compiled CSS -->↵ <link rel="stylesheet" type="text/css" href="assets/kbApp-1.1.4.css"/>↵ ↵</head>↵<body>↵<!-- Loading -->↵<div kb-Hide-After-Init class = "loader" style="z-index: 3000">↵ <div class="loader-inner-big">↵ <i class="icon-spinner animate-spin"></i>↵ <div id="errorMsg"></div>↵ </div>↵</div>↵<!-- Page -->↵<div class="kbContainer">↵ <div class="kbBanner">↵ <div class="kbLogoP..."

I think the html-page of the Piko has changed from the past and is now not only a simple http-file.

Can someone help me please?

Greeting
Wolfgang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment