no message
This commit is contained in:
+25
-23
@@ -59,25 +59,40 @@ class Puffer_Speicher extends IPSModule
|
|||||||
parent::ApplyChanges();
|
parent::ApplyChanges();
|
||||||
$this->SetTimerInterval("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000);
|
$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 aus der Property auslesen
|
||||||
$json = $this->ReadPropertyString("LeistungsStufen");
|
$json = $this->ReadPropertyString("LeistungsStufen");
|
||||||
$leistungsStufen = json_decode($json, true);
|
$leistungsStufen = json_decode($json, true);
|
||||||
|
|
||||||
|
|
||||||
if (is_array($leistungsStufen)) {
|
if (is_array($leistungsStufen)) {
|
||||||
foreach ($leistungsStufen as $stufe) {
|
foreach ($leistungsStufen as $stufe) {
|
||||||
if (isset($stufe['Leistung'])) {
|
$this->leistungArray[] = $stufe['Leistung'] ?? 0;
|
||||||
$leistungArray[] = $stufe['Leistung'];
|
}
|
||||||
} else {
|
}
|
||||||
$leistungArray[] = 0; // falls 'Leistung' fehlt
|
|
||||||
|
// 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)
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user