From ab1f362a459fe74a56f21d26b5071941557b79c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Fri, 2 May 2025 15:12:52 +0200 Subject: [PATCH] no message --- Verbraucher_extern/module.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Verbraucher_extern/module.php b/Verbraucher_extern/module.php index 0aea825..013a5ef 100644 --- a/Verbraucher_extern/module.php +++ b/Verbraucher_extern/module.php @@ -88,6 +88,20 @@ class Verbraucher_extern extends IPSModule } + private function findCombination($power, $values) { + $result = []; + $found = findCombinationRecursive($power, $values, [], 0, $result); + return $found ? $result : null; + } + + private function findCombinationRecursive($power, $values, $currentCombination, $startIndex, &$result) { + if ($power == 0) { + $result = $currentCombination; + return true; + } + if ($power < 0) { + return false; + private function find($target, $values, $current, &$result) { if ($target == 0) { $result[] = $current; @@ -106,15 +120,17 @@ class Verbraucher_extern extends IPSModule { $values = json_decode($this->GetValue("PowerSteps")); $result = []; - - $this->find($this->GetValue("Power"), $values, [], $result); + + $firstCombination = $this->findCombination($this->GetValue("Power"), $this->GetValue("PowerSteps")); + + //$this->find($this->GetValue("Power"), $values, [], $result); $verbraucherListe = json_decode($this->ReadPropertyString("Verbraucher_Liste"), true); - $firstCombination = $result[0]; + //$firstCombination = $result[0]; - foreach ($verbraucherListe as &$verbraucher) { + foreach ($verbraucherListe as $verbraucher) { if (in_array($verbraucher['P_Nenn'], $firstCombination)) { RequestAction($verbraucher['Write_Var'], false); } else {