diff --git a/Verbraucher_extern/module.php b/Verbraucher_extern/module.php index 8a01271..d47a867 100644 --- a/Verbraucher_extern/module.php +++ b/Verbraucher_extern/module.php @@ -67,37 +67,6 @@ class Verbraucher_extern extends IPSModule } - - - - // Methode zum Setzen des aktuellen Stromverbrauchs - - public function SetAktuelle_Leistung(float $power) { - $this->CheckIdle($power); - - $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); - $kombinationen = $this->kombinationenRekursiv($verbraucherListe, $power); - -         // Setze die Werte in Write_Var - foreach ($verbraucherListe as $verbraucher) { - $writeVarID = $verbraucher['Write_Var']; - $pNenn = $verbraucher['P_Nenn']; - $this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0); - } - $this->SetValue("Leistung_Delta", $power - array_sum($kombinationen)); - } - -     // Methode zum Abrufen der aktuellen Daten - public function GetCurrentData(bool $Peak) - { -         // Setze die Is_Peak_Shaving Variable - $this->SetValue("Is_Peak_Shaving", $Peak); - - $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); - $kombinationen = $this->berechneKombinationen($verbraucherListe); - $this->SetValue("PowerSteps", implode(", ", $kombinationen)); - } - private function berechneKombinationen(array $verbraucherListe, float $power = null) { $kombinationen = []; @@ -122,6 +91,33 @@ class Verbraucher_extern extends IPSModule $this->kombinationenRekursiv($verbraucherListe, $aktuelleKombi, $kombinationen, $power); } + + + // Methode zum Setzen des aktuellen Stromverbrauchs + + public function SetAktuelle_Leistung(float $power) { + $this->CheckIdle($power); + + $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); + $kombinationen = $this->kombinationenRekursiv($verbraucherListe, $power); + + foreach ($verbraucherListe as $verbraucher) { + $writeVarID = $verbraucher['Write_Var']; + $pNenn = $verbraucher['P_Nenn']; + $this->SetValue($writeVarID, in_array($pNenn, $kombinationen) ? 1 : 0); + } + $this->SetValue("Leistung_Delta", $power - array_sum($kombinationen)); + } + + public function GetCurrentData(bool $Peak) + { + $this->SetValue("Is_Peak_Shaving", $Peak); + $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); + $kombinationen = $this->berechneKombinationen($verbraucherListe); + $this->SetValue("PowerSteps", implode(", ", $kombinationen)); + } + + public function CheckIdle($power) @@ -131,7 +127,6 @@ class Verbraucher_extern extends IPSModule $this->SetValue("Idle", false); $this->SetValue("IdleCounter",$this->ReadPropertyInteger("IdleCounterMax")); } - // IdleCounter auslesen und verarbeiten $idleCounter = $this->GetValue("IdleCounter"); if ($idleCounter > 0) { $this->SetValue("Idle", false);