Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kostal Pico 3.0 Hinzugefügt #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Symcon Kostal Modul
Modul um Kostal Wechselrichter abzufragen.
Unterstützte Modelle:
- Piko 3.0
- Piko 5.5
- Piko 8.3
- Piko 12

Für die Modelle Piko 5.5 und 8.3 sind Teile aus [hermanthegerman2's Modul](https://github.com/hermanthegerman2/KostalPiko) benutzt worden.
Das Original modul wurde von [emtek-at] (https://github.com/emtek-at/Kostal-Symcon) bezogen und geforked.


### Inhaltverzeichnis
Expand All @@ -28,7 +30,7 @@ Für die Modelle Piko 5.5 und 8.3 sind Teile aus [hermanthegerman2's Modul](http
### 3. Software-Installation

Über das Modul-Control folgende URL hinzufügen.
`https://github.com/emtek-at/Kostal-Symcon`
`https://github.com/crazy-sonic/Kostal-Symcon`


### 4. Einrichten der Instanzen in IP-Symcon
Expand Down
1 change: 1 addition & 0 deletions kostal-piko/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[
{ "type": "Select", "name": "model", "caption": "formModel",
"options": [
{ "caption": "Piko 3.0", "value": "p30" },
{ "caption": "Piko 5.5", "value": "p55" },
{ "caption": "Piko 8.3", "value": "p83" },
{ "caption": "Piko 12", "value": "p12" }
Expand Down
2 changes: 1 addition & 1 deletion kostal-piko/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "kostalPico",
"type": 3,
"vendor": "Kostal",
"aliases": [ "Piko 5.5", "Piko 8.3", "Piko 12"],
"aliases": [ "Piko 3.0", "Piko 5.5", "Piko 8.3", "Piko 12"],
"parentRequirements": [],
"childRequirements": [],
"implemented": [],
Expand Down
78 changes: 73 additions & 5 deletions kostal-piko/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function Create() {
// Diese Zeile nicht löschen.
parent::Create();

$this->RegisterPropertyString("model", "p55");
$this->RegisterPropertyString("model", "p30");
$this->RegisterPropertyString("host", "");
$this->RegisterPropertyString("user", "");
$this->RegisterPropertyString("password", "");
$this->RegisterPropertyString("user", "pvserver");
$this->RegisterPropertyString("password", "pvwr");
$this->RegisterPropertyInteger("statusTimer", 15);

$this->RegisterTimer("status_UpdateTimer", 0, 'KostalP_getStatus($_IPS[\'TARGET\']);');
Expand All @@ -58,9 +58,9 @@ public function ApplyChanges() {
$this->SetStatus(201);
}else if(strlen($host) == 0){
$this->SetStatus(202);
}else if(strlen($user) == 0 && ($model == 'p55' || $model == 'p83')){
}else if(strlen($user) == 0 && ($model == 'p55' || $model == 'p83' || $model == 'p30')){
$this->SetStatus(203);
}else if(strlen($password) == 0 && ($model == 'p55' || $model == 'p83')){
}else if(strlen($password) == 0 && ($model == 'p55' || $model == 'p83' || $model == 'p30')){
$this->SetStatus(204);
}else{
$this->RegisterVariableString("powerStatus", $this->Translate("varPowerStatus"), '', 1);
Expand Down Expand Up @@ -114,6 +114,9 @@ public function getStatus()
$model = $this->ReadPropertyString("model");

switch($model){
case 'p30':
$this->parsePiko30();
break;
case 'p55':
$this->parsePiko55();
break;
Expand Down Expand Up @@ -162,6 +165,65 @@ public function getStatus()
}
}

private function parsePiko30(){
/*
* function is from https://github.com/hermanthegerman2/KostalPiko
*/
$host = $this->ReadPropertyString("host");
$user = $this->ReadPropertyString("user");
$password = $this->ReadPropertyString("password");
$url = 'http://'.$user.':'.$password.'@'.$host;

$output = file_get_contents($url, "r");

//AC-Leistung_Aktuell
$pos1 = strpos($output, "aktuell</td>");
$pos2 = strpos($output, "&nbsp;</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 61), $pos2 - $pos1 - 61);
SetValue($this->GetIDForIdent("powerActual"), $data=="x x x" ? 0 : (float)$data);

//AC_Leistung_Status
$pos1 = strpos($output, "Status</td>");
$pos2 = strpos($output, "</td>", $pos1 + 17);
$data = substr($output, ($pos1 + 29), $pos2 - $pos1 - 29);
SetValue($this->GetIDForIdent("powerStatus"), $data=="x x x" ? 0 : $data);

//Energie_Gesamtertrag
$pos1 = strpos($output, "Gesamtenergie</td>");
$pos2 = strpos($output, "</td>", $pos1 + 30);
$data = substr($output, ($pos1 + 67), $pos2 - $pos1 - 67);
SetValue($this->GetIDForIdent("outputAll"), $data=="x x x" ? 0 : (float)$data);

//Energie_Tagesertrag_Aktuell
$pos1 = strpos($output, "Tagesenergie</td>");
$pos2 = strpos($output, "</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 66), $pos2 - $pos1 - 66);
SetValue($this->GetIDForIdent("outputDay"), $data=="x x x" ? 0 : (float)$data);

//PV_Generator_String1_Spannung
$pos1 = strpos($output, "Spannung</td>", $pos2);
$pos2 = strpos($output, "</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 64), $pos2 - $pos1 - 64);
SetValue($this->GetIDForIdent("s1Voltage"), $data=="x x x" ? 0 : (float)$data);

//Ausgangsleistung_L1_Spannung
$pos1 = strpos($output, "Spannung</td>", $pos2);
$pos2 = strpos($output, "</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 64), $pos2 - $pos1 - 64);
SetValue($this->GetIDForIdent("l1Voltage"), $data=="x x x" ? 0 : (float)$data);

//PV_Generator_String1_Strom
$pos1 = strpos($output, "Strom</td>", $pos2);
$pos2 = strpos($output, "</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 61), $pos2 - $pos1 - 61);
SetValue($this->GetIDForIdent("s1Current"), $data=="x x x" ? 0 : (float)$data);

//Ausgangsleistung_L1_Leistung
$pos1 = strpos($output, "Leistung</td>", $pos2);
$pos2 = strpos($output, "</td>", $pos1 + 20);
$data = substr($output, ($pos1 + 64), $pos2 - $pos1 - 64);
SetValue($this->GetIDForIdent("l1Power"), $data=="x x x" ? 0 : (float)$data);
}
private function parsePiko55(){
/*
* function is from https://github.com/hermanthegerman2/KostalPiko
Expand Down Expand Up @@ -451,6 +513,9 @@ private function getModelLineCount(){
$val = 0;

switch($model = $this->ReadPropertyString("model")){
case 'p30':
$val = 1;
break;
case 'p55':
$val = 3;
break;
Expand All @@ -468,6 +533,9 @@ private function getModelStringCount(){
$val = 0;

switch($model = $this->ReadPropertyString("model")){
case 'p30':
$val = 1;
break;
case 'p55':
$val = 3;
break;
Expand Down