no message

This commit is contained in:
dh
2025-05-02 15:12:52 +02:00
parent 08498c2a75
commit ab1f362a45
+20 -4
View File
@@ -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) { private function find($target, $values, $current, &$result) {
if ($target == 0) { if ($target == 0) {
$result[] = $current; $result[] = $current;
@@ -106,15 +120,17 @@ class Verbraucher_extern extends IPSModule
{ {
$values = json_decode($this->GetValue("PowerSteps")); $values = json_decode($this->GetValue("PowerSteps"));
$result = []; $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); $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)) { if (in_array($verbraucher['P_Nenn'], $firstCombination)) {
RequestAction($verbraucher['Write_Var'], false); RequestAction($verbraucher['Write_Var'], false);
} else { } else {