From d05f177ea0b49e1dbe0bccb55677462feb133d8a Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Thu, 2 Oct 2025 09:54:21 +0200 Subject: [PATCH] no message --- Puffer_Speicher/module.php | 48 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/Puffer_Speicher/module.php b/Puffer_Speicher/module.php index fb33fed..d734a2d 100644 --- a/Puffer_Speicher/module.php +++ b/Puffer_Speicher/module.php @@ -59,25 +59,40 @@ class Puffer_Speicher extends IPSModule parent::ApplyChanges(); $this->SetTimerInterval("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000); + + // Nur Methodenaufruf + $this->LadeUndSortiereLeistungen(); + + IPS_LogMessage("LeistungArray", json_encode($this->leistungArray)); + + } + + private function LadeUndSortiereLeistungen() + { + // Array initialisieren, immer mit 0 + $this->leistungArray = [0]; + // JSON aus der Property auslesen $json = $this->ReadPropertyString("LeistungsStufen"); $leistungsStufen = json_decode($json, true); - if (is_array($leistungsStufen)) { foreach ($leistungsStufen as $stufe) { - if (isset($stufe['Leistung'])) { - $leistungArray[] = $stufe['Leistung']; - } else { - $leistungArray[] = 0; // falls 'Leistung' fehlt + $this->leistungArray[] = $stufe['Leistung'] ?? 0; + } + } + + // Array sortieren (Bubble Sort) + $len = count($this->leistungArray); + for ($i = 0; $i < $len - 1; $i++) { + for ($j = 0; $j < $len - $i - 1; $j++) { + if ($this->leistungArray[$j] > $this->leistungArray[$j + 1]) { + $temp = $this->leistungArray[$j]; + $this->leistungArray[$j] = $this->leistungArray[$j + 1]; + $this->leistungArray[$j + 1] = $temp; } } } - sort($leistungArray, SORT_NUMERIC); - // Optional: Debug-Ausgabe - IPS_LogMessage("LeistungArray", json_encode($leistungArray)); - - } public function RequestAction($Ident, $Value) @@ -250,20 +265,7 @@ class Puffer_Speicher extends IPSModule } } - private function ist_nachts() - { - date_default_timezone_set("Europe/Berlin"); // Setze hier deine Zeitzone - $aktuelle_zeit = strtotime(date("H:i")); // Aktuelle Zeit in Stunden und Minuten umwandeln - $start_nacht = strtotime("22:00"); // Startzeit der Nacht (22 Uhr) - $ende_nacht = strtotime("07:00"); // Endzeit der Nacht (7 Uhr) - - if ($aktuelle_zeit >= $start_nacht || $aktuelle_zeit < $ende_nacht) { - return true; - } else { - return false; - } - } } ?>