diff --git a/Batterie/module.php b/Batterie/module.php index 83dee34..6f018ef 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -32,22 +32,27 @@ class Batterie extends IPSModule public function ApplyChanges() { parent::ApplyChanges(); - $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); - $array_powersteps = []; - //Schrittgrösse - $stepSize = 250; - - - for ($i = 0; $i <= $maxleistung * 2; $i += $stepSize) { - $array_powersteps[] = $i; - } + } + private function GeneratePowerSteps() +{ + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + $array_powersteps = []; + $stepSize = 250; // Schrittgröße + // Erstellen der PowerSteps + for ($i = 0; $i <= $maxleistung * 2; $i += $stepSize) { + $array_powersteps[] = $i; + } + + return $array_powersteps; +} public function RequestAction($Ident, $Value) { + switch ($Ident) { case "SetAktuelle_Leistung": $this->SetAktuelle_Leistung($Value); @@ -60,11 +65,11 @@ class Batterie extends IPSModule } public function SetAktuelle_Leistung(int $power) - { + { // Batterie-spezifische Eigenschaften abrufen $spannung = $this->ReadPropertyInteger("Batteriespannung"); - $entladestrom = $this->ReadPropertyInteger("Entladestrom")); - $ladestrom = $this->ReadPropertyInteger("Ladestrom")); + $entladestrom = $this->ReadPropertyInteger("Entladestrom"); + $ladestrom = $this->ReadPropertyInteger("Ladestrom"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Batterie entladen oder laden basierend auf der Leistung @@ -97,9 +102,10 @@ class Batterie extends IPSModule public function GetCurrentData(bool $Peak) { // Werte der registrierten Variablen abrufen und in Variablen speichern - $aufdasnachladen =$this->ReadPropertyInteger("AufdasNachladen")); - $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen")); - $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand")); + $array_powersteps = $this->GeneratePowerSteps(); + $aufdasnachladen =$this->ReadPropertyInteger("AufdasNachladen"); + $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen"); + $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); if ($Peak) { diff --git a/library.json b/library.json index f8745cc..16660ab 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.185", + "version": "0.186", "build": 0, "date": 0 } \ No newline at end of file