diff --git a/Readme.md b/Readme.md index f251c65..7fda8f8 100644 --- a/Readme.md +++ b/Readme.md @@ -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 @@ -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 diff --git a/kostal-piko/form.json b/kostal-piko/form.json index 8306d32..23b51b6 100644 --- a/kostal-piko/form.json +++ b/kostal-piko/form.json @@ -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" } diff --git a/kostal-piko/module.json b/kostal-piko/module.json index fce79bc..a58eeb1 100644 --- a/kostal-piko/module.json +++ b/kostal-piko/module.json @@ -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": [], diff --git a/kostal-piko/module.php b/kostal-piko/module.php index ab3880b..f36e80a 100644 --- a/kostal-piko/module.php +++ b/kostal-piko/module.php @@ -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\']);'); @@ -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); @@ -114,6 +114,9 @@ public function getStatus() $model = $this->ReadPropertyString("model"); switch($model){ + case 'p30': + $this->parsePiko30(); + break; case 'p55': $this->parsePiko55(); break; @@ -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"); + $pos2 = strpos($output, " ", $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"); + $pos2 = strpos($output, "", $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"); + $pos2 = strpos($output, "", $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"); + $pos2 = strpos($output, "", $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", $pos2); + $pos2 = strpos($output, "", $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", $pos2); + $pos2 = strpos($output, "", $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", $pos2); + $pos2 = strpos($output, "", $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", $pos2); + $pos2 = strpos($output, "", $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 @@ -451,6 +513,9 @@ private function getModelLineCount(){ $val = 0; switch($model = $this->ReadPropertyString("model")){ + case 'p30': + $val = 1; + break; case 'p55': $val = 3; break; @@ -468,6 +533,9 @@ private function getModelStringCount(){ $val = 0; switch($model = $this->ReadPropertyString("model")){ + case 'p30': + $val = 1; + break; case 'p55': $val = 3; break;