From 3c40e386f2cbd125644caa72571e238f8add263a Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Thu, 2 Oct 2025 09:37:00 +0200 Subject: [PATCH] no message --- Puffer_Speicher/form.json | 70 +++++++++++++++----------------------- Puffer_Speicher/module.php | 24 ++++++++++--- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Puffer_Speicher/form.json b/Puffer_Speicher/form.json index e7e8bf4..4c6cdf3 100644 --- a/Puffer_Speicher/form.json +++ b/Puffer_Speicher/form.json @@ -50,49 +50,33 @@ "caption": "Puffer Teillast", "suffix": "Watt" }, - { - "type": "Select", - "name": "Stufen", - "caption": "Anzahl Stufen", - "options": [ - {"caption": "1-stufig", "value": 1}, - {"caption": "2-stufig", "value": 2}, - {"caption": "3-stufig", "value": 3}, - {"caption": "4-stufig", "value": 4} - ] - }, - { - "type": "NumberSpinner", - "name": "Stage1", - "caption": "1-stufig", - "minimum": 0, - "maximum": 100, - "visible": true - }, - { - "type": "NumberSpinner", - "name": "Stage2", - "caption": "2-stufig", - "minimum": 0, - "maximum": 100, - "visible": "this.Stufen >= 2" - }, - { - "type": "NumberSpinner", - "name": "Stage3", - "caption": "3-stufig", - "minimum": 0, - "maximum": 100, - "visible": "this.Stufen >= 3" - }, - { - "type": "NumberSpinner", - "name": "Stage4", - "caption": "4-stufig", - "minimum": 0, - "maximum": 100, - "visible": "this.Stufen >= 4" - }, + { + "type":"List", + "name":"LeistungsStufen", + "caption":"Anzahl Stufen mit den dazugehörigen Leistungen", + "add":true, + "delete":true, + "columns":[ + { + "caption":"Stufe", + "name":"Variablenname", + "width":"200px", + "add":"Stufe", + "edit":{ + "type":"ValidationTextBox" + } + }, + { + "caption":"Leistung in W", + "name":"Leistung", + "width":"300px", + "add":0, + "edit":{ + "type":"NumberSpinner" + } + } + ] + }, { "type": "Label", diff --git a/Puffer_Speicher/module.php b/Puffer_Speicher/module.php index 677086e..30b503e 100644 --- a/Puffer_Speicher/module.php +++ b/Puffer_Speicher/module.php @@ -8,10 +8,7 @@ class Puffer_Speicher extends IPSModule $this->RegisterPropertyInteger("PufferLeistung", 6000); $this->RegisterPropertyInteger("PufferTeilLeistung", 3000); - $this->RegisterPropertyInteger("Stage1", 1); - $this->RegisterPropertyInteger("Stage2", 2); - $this->RegisterPropertyInteger("Stage3", 3); - $this->RegisterPropertyInteger("Stage4", 4); + $this->RegisterPropertyString("LeistungsStufen", json_encode([])); // Bezeichnung der Liste $this->RegisterPropertyInteger("ZeitKonstante", 120); $this->RegisterPropertyInteger("Pufferfuehler_PT1", 0); $this->RegisterPropertyInteger("Heizkontakt2_Puffer", 0); @@ -61,6 +58,25 @@ class Puffer_Speicher extends IPSModule parent::ApplyChanges(); $this->SetTimerInterval("Timer_Do_UserCalc_Boiler",$this->ReadPropertyInteger("Interval")*1000); + // JSON aus der Property auslesen + $json = $this->ReadPropertyString("LeistungsStufen"); + $leistungsStufen = json_decode($json, true); + + // Array mit Werten aufbauen, erste Stufe = 0 + $leistungArray = [0]; // Startwert 0 + + if (is_array($leistungsStufen)) { + foreach ($leistungsStufen as $stufe) { + if (isset($stufe['Leistung'])) { + $leistungArray[] = $stufe['Leistung']; + } else { + $leistungArray[] = 0; // falls 'Leistung' fehlt + } + } + } + + // Optional: Debug-Ausgabe + IPS_LogMessage("LeistungArray", json_encode($leistungArray)); }