From bc916b313eb33fd53887d567df685dd7cbf64c88 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:10:57 +0100 Subject: [PATCH 01/17] =?UTF-8?q?Batterie=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Batterie/README.md | 0 Batterie/form.json | 51 +++++++++++ Batterie/modul.json | 12 +++ Batterie/module.php | 205 ++++++++++++++++++++++++++++++++++++++++++++ library.json | 2 +- 5 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 Batterie/README.md create mode 100644 Batterie/form.json create mode 100644 Batterie/modul.json create mode 100644 Batterie/module.php diff --git a/Batterie/README.md b/Batterie/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Batterie/form.json b/Batterie/form.json new file mode 100644 index 0000000..5ebfe70 --- /dev/null +++ b/Batterie/form.json @@ -0,0 +1,51 @@ +{ + "elements": [ + { + "type": "Label", + "caption": "Konfiguration der Batterie für Peakshaving" + }, + { + "type": "NumberSpinner", + "name": "IdleCounterMax", + "caption": "Zyklen zwischen zwei Leisutungsänderungen", + "suffix": "" + }, + { + "type": "NumberSpinner", + "name": "MaxBatterieleistung", + "caption": "Leistug Teillast", + "suffix": "" + }, + { + "type": "SelectVariable", + "name": "AufdasNachladen", + "caption": "Auf so viel Prozent nachladen", + "test": true + }, + { + "type": "SelectVariable", + "name": "MinimumEntladen", + "caption": "Minimum des Batterieladezustand", + "test": true + }, + { + "type": "SelectVariable", + "name": "Nachladestrom", + "caption": "Nachladestrom", + "test": true + }, + { + "type": "SelectVariable", + "name": "Ladestrom", + "caption": "Ladestrom", + "test": true + }, + { + "type": "SelectVariable", + "name": "Batterieladezustand", + "caption": "Batterieladezustand", + "test": true + } + + ] +} diff --git a/Batterie/modul.json b/Batterie/modul.json new file mode 100644 index 0000000..87369c5 --- /dev/null +++ b/Batterie/modul.json @@ -0,0 +1,12 @@ +{ + "id": "{17759E3B-3F45-69A5-E7C0-34DE6D7577CF}", + "name": "Batterie", + "type": 3, + "vendor": "Belevo AG", + "aliases": [], + "parentRequirements": [], + "childRequirements": [], + "implemented": [], + "prefix": "GEF", + "url": "" +} \ No newline at end of file diff --git a/Batterie/module.php b/Batterie/module.php new file mode 100644 index 0000000..177dd0a --- /dev/null +++ b/Batterie/module.php @@ -0,0 +1,205 @@ +RegisterPropertyInteger("MaxBatterieleistung", 0); + $this->RegisterPropertyInteger("Batteriespannung", 50); + + // Batterie spezifische Variablen + $this->RegisterVariableInteger("AufdasNachladen","AufdasNachladen","",0); + $this->RegisterVariableInteger("MinimumEntladen","MinimumEntladen","",0); + $this->RegisterVariableInteger("Entladestrom","Entladestrom","",0); + $this->RegisterVariableInteger("Ladestrom","Ladestrom","",0); + $this->RegisterVariableInteger("Batterieladezustand","Batterieladezustand","",0); + + // Variabeln für Kommunkation mit Manager + $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); + $this->RegisterVariableString("PowerSteps", "PowerSteps"); + + // Hilfsvariabeln für Idle zustand + $this->RegisterPropertyInteger("IdleCounterMax", 2); + $this->RegisterVariableInteger("IdleCounter", "IdleCounter", "", 0); + $this->SetValue("IdleCounter", 0); + + // Initialisiere Idle + $this->SetValue("Idle", true); + } + + public function ApplyChanges() + { + parent::ApplyChanges(); + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + $array_powersteps = []; + //Schrittgrösse + $stepSize = 250; + + + for ($i = 0; $i <= $maxleistung * 2; $i += $stepSize) { + $array_powersteps[] = $i; + } + + } + + + + public function RequestAction($Ident, $Value) + { + switch ($Ident) { + case "SetAktuelle_Leistung": + $this->SetAktuelle_Leistung($Value); + break; + case "GetCurrentData": + return $this->GetCurrentData($Value); + default: + throw new Exception("Invalid Ident"); + } + } + + public function SetAktuelle_Leistung(int $power){ + $spannung = $this->ReadPropertyInteger("Batteriespannung"); + $entladestrom = $this->ReadVariableInteger("Entladestrom"); + $ladestrom = $this->ReadVariableInteger("Ladestrom"); + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + + //Batterie entladen < MaxBatterieleistung &&&&& MaxBatterieleistung < Batterie laden + if ($power > $maxleistung) { + $ladestrom = ($power - $maxleistung) / $spannung; + $this->SetValue("Ladestrom", $ladestrom); + } else { + $entladestrom = $power / $spannung; + $this->SetValue("Entladestrom", $nachladestrom); + } + + + + // Prüfe auf Änderung der Power im Vergleich zur letzten Einstellung + $lastPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung")); + if ($power != $lastPower) { + $this->SetValue("Idle", false); + $this->SetValue( + "IdleCounter", + $this->ReadPropertyInteger("IdleCounterMax") + ); + } + + // Setze die neue Aktuelle_Leistung + $this->SetValue("Aktuelle_Leistung", $power); + + // IdleCounter verarbeiten + $this->ProcessIdleCounter(); + + } + + public function GetCurrentData(bool $Peak) + { + + // Werte der registrierten Variablen abrufen und in Variablen speichern + $aufdasnachladen = $this->ReadVariableInteger("AufdasNachladen"); + $minimumentladen = $this->ReadVariableInteger("Minimumentladen"); + $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + + if ($Peak) { + + + if ($batterieladezustand <= $minimumentladen){ + // Filterung des Arrays + $filtered_powersteps = array_filter($array_powersteps, function ($value) { + return $value > $maxleistung ; //Hochpassfiltern + }); + + $filtered_powersteps_laden = array_values($filtered_powersteps); + $this->SetValue( + "PowerSteps", + json_encode($filtered_powersteps_laden) + ); + + } elseif ($batterieladezustand >= $aufdasnachladen) { + + $filtered_powersteps_entladen = array_filter($array_powersteps, function ($value) { + return $value < $maxleistung ; //Tiefpassfiltern + }); + + $filtered_powersteps = array_values($filtered_powersteps); + $this->SetValue( + "PowerSteps", + json_encode($filtered_powersteps_entladen) + ); + + } elseif ($batterieladezustand < $aufdasnachladen && $batterieladezustand > $minimumentladen) { + $this->SetValue( + "PowerSteps", + json_encode($array_powersteps) + ); + + } else { + + $this->SetValue( + "PowerSteps", + json_encode($array_powersteps[0]) + ); + } + + } else {//Solar + + + // Filterung des Arrays + $filtered_powersteps = array_filter($array_powersteps, function ($value) { + return $value > $maxleistung ; //Hochpassfiltern + }); + $filtered_powersteps = array_values($filtered_powersteps); + $this->SetValue( + "PowerSteps", + json_encode($filtered_powersteps) + ); + } + + + + + + + private function CheckIdle($power) + { + $lastpower = GetValue("Aktuelle_Leistung"); + if ($lastpower != GetValue("Aktuelle_Leistung")) { + $this->SetValue("Idle", false); + $this->SetValue( + "IdleCounter", + $this->ReadPropertyInteger("IdleCounterMax") + ); + } + // IdleCounter auslesen und verarbeiten + $idleCounter = $this->GetValue("IdleCounter"); + if ($idleCounter > 0) { + $this->SetValue("Idle", false); + $this->SetValue("IdleCounter", $idleCounter - 1); + } else { + $this->SetValue("Idle", true); + } + } + + + private function ProcessIdleCounter() + { + // IdleCounter auslesen und verarbeiten + $idleCounter = $this->GetValue("IdleCounter"); + if ($idleCounter > 0) { + $this->SetValue("Idle", false); + $this->SetValue("IdleCounter", $idleCounter - 1); + } else { + $this->SetValue("Idle", true); + } + } + + + + } + +} +?> \ No newline at end of file diff --git a/library.json b/library.json index 910ffee..b5b5f2f 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.172", + "version": "0.173", "build": 0, "date": 0 } \ No newline at end of file From f793264325e5946e371be8db6d15a61ed8092ec4 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:22:03 +0100 Subject: [PATCH 02/17] ? --- Batterie/modul.json | 2 +- library.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Batterie/modul.json b/Batterie/modul.json index 87369c5..468e0f8 100644 --- a/Batterie/modul.json +++ b/Batterie/modul.json @@ -1,5 +1,5 @@ { - "id": "{17759E3B-3F45-69A5-E7C0-34DE6D7577CF}", + "id": "{F6C6A4B2-C5BB-4D94-2629-01D8B0D4CAF5}", "name": "Batterie", "type": 3, "vendor": "Belevo AG", diff --git a/library.json b/library.json index b5b5f2f..aaccca9 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.173", + "version": "0.174", "build": 0, "date": 0 } \ No newline at end of file From 1d3860cd1cdda708cedd2930783526f7ba1bbe90 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:24:59 +0100 Subject: [PATCH 03/17] modul/e --- Batterie/{modul.json => module.json} | 0 library.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename Batterie/{modul.json => module.json} (100%) diff --git a/Batterie/modul.json b/Batterie/module.json similarity index 100% rename from Batterie/modul.json rename to Batterie/module.json diff --git a/library.json b/library.json index aaccca9..d61f4d8 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.174", + "version": "0.175", "build": 0, "date": 0 } \ No newline at end of file From 40237638a0a6ff3c335ca279479f57b5be6d4538 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:31:46 +0100 Subject: [PATCH 04/17] ?? --- Batterie/module.php | 4 ++-- library.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 177dd0a..77e2ccc 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -163,7 +163,7 @@ class Batterie extends IPSModule - + /* private function CheckIdle($power) { $lastpower = GetValue("Aktuelle_Leistung"); @@ -183,7 +183,7 @@ class Batterie extends IPSModule $this->SetValue("Idle", true); } } - + */ private function ProcessIdleCounter() { diff --git a/library.json b/library.json index d61f4d8..ac11e13 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.175", + "version": "0.176", "build": 0, "date": 0 } \ No newline at end of file From b841df12df31ae185c6f1b2391546570928f89d7 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:33:36 +0100 Subject: [PATCH 05/17] public --- Batterie/module.php | 8 ++++---- library.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 77e2ccc..78ec167 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -163,8 +163,8 @@ class Batterie extends IPSModule - /* - private function CheckIdle($power) + + public function CheckIdle($power) { $lastpower = GetValue("Aktuelle_Leistung"); if ($lastpower != GetValue("Aktuelle_Leistung")) { @@ -183,9 +183,9 @@ class Batterie extends IPSModule $this->SetValue("Idle", true); } } - */ + - private function ProcessIdleCounter() + public function ProcessIdleCounter() { // IdleCounter auslesen und verarbeiten $idleCounter = $this->GetValue("IdleCounter"); diff --git a/library.json b/library.json index ac11e13..604545f 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.176", + "version": "0.177", "build": 0, "date": 0 } \ No newline at end of file From e759ac1e9dd37c0e624dd933e281cfebc094cb8f Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:36:58 +0100 Subject: [PATCH 06/17] Codefehler --- Batterie/module.php | 62 ++++++++++++++++++++++----------------------- library.json | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 78ec167..8f3aaf2 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -164,42 +164,42 @@ class Batterie extends IPSModule - public function CheckIdle($power) - { - $lastpower = GetValue("Aktuelle_Leistung"); - if ($lastpower != GetValue("Aktuelle_Leistung")) { - $this->SetValue("Idle", false); - $this->SetValue( - "IdleCounter", - $this->ReadPropertyInteger("IdleCounterMax") - ); - } - // IdleCounter auslesen und verarbeiten - $idleCounter = $this->GetValue("IdleCounter"); - if ($idleCounter > 0) { - $this->SetValue("Idle", false); - $this->SetValue("IdleCounter", $idleCounter - 1); - } else { - $this->SetValue("Idle", true); - } - } - - public function ProcessIdleCounter() - { - // IdleCounter auslesen und verarbeiten - $idleCounter = $this->GetValue("IdleCounter"); - if ($idleCounter > 0) { - $this->SetValue("Idle", false); - $this->SetValue("IdleCounter", $idleCounter - 1); - } else { - $this->SetValue("Idle", true); - } - } } + private function CheckIdle($power) + { + $lastpower = GetValue("Aktuelle_Leistung"); + if ($lastpower != GetValue("Aktuelle_Leistung")) { + $this->SetValue("Idle", false); + $this->SetValue( + "IdleCounter", + $this->ReadPropertyInteger("IdleCounterMax") + ); + } + // IdleCounter auslesen und verarbeiten + $idleCounter = $this->GetValue("IdleCounter"); + if ($idleCounter > 0) { + $this->SetValue("Idle", false); + $this->SetValue("IdleCounter", $idleCounter - 1); + } else { + $this->SetValue("Idle", true); + } + } + + private function ProcessIdleCounter() + { + // IdleCounter auslesen und verarbeiten + $idleCounter = $this->GetValue("IdleCounter"); + if ($idleCounter > 0) { + $this->SetValue("Idle", false); + $this->SetValue("IdleCounter", $idleCounter - 1); + } else { + $this->SetValue("Idle", true); + } + } } ?> \ No newline at end of file diff --git a/library.json b/library.json index 604545f..ab0e3c6 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.177", + "version": "0.178", "build": 0, "date": 0 } \ No newline at end of file From 3eae7fd56e034b591f26f106c371d208d1582ae5 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:40:44 +0100 Subject: [PATCH 07/17] fehler --- Batterie/module.php | 1 + library.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Batterie/module.php b/Batterie/module.php index 8f3aaf2..cfad474 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -20,6 +20,7 @@ class Batterie extends IPSModule // Variabeln für Kommunkation mit Manager $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); + $this->RegisterVariableBoolean("Idle", "Idle", "", 0); // Hilfsvariabeln für Idle zustand $this->RegisterPropertyInteger("IdleCounterMax", 2); diff --git a/library.json b/library.json index ab0e3c6..645ed58 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.178", + "version": "0.179", "build": 0, "date": 0 } \ No newline at end of file From 68636780d6549488e717f71f3e9ef60e02166f15 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:44:15 +0100 Subject: [PATCH 08/17] instanzfehler --- Batterie/form.json | 13 ++++++------- library.json | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Batterie/form.json b/Batterie/form.json index 5ebfe70..ce69f2b 100644 --- a/Batterie/form.json +++ b/Batterie/form.json @@ -13,20 +13,19 @@ { "type": "NumberSpinner", "name": "MaxBatterieleistung", - "caption": "Leistug Teillast", + "caption": "Maximale Batterieleistung", "suffix": "" }, { - "type": "SelectVariable", + "type": "NumberSpinner", "name": "AufdasNachladen", - "caption": "Auf so viel Prozent nachladen", - "test": true + "caption": "Auf so viel Prozent nachladen" + }, { - "type": "SelectVariable", + "type": "NumberSpinner", "name": "MinimumEntladen", - "caption": "Minimum des Batterieladezustand", - "test": true + "caption": "Minimum des Batterieladezustand" }, { "type": "SelectVariable", diff --git a/library.json b/library.json index 645ed58..fcc286e 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.179", + "version": "0.180", "build": 0, "date": 0 } \ No newline at end of file From 63be9ec3c4b9b895e91fa9ea5eb302cb52d0f9f4 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 15:59:56 +0100 Subject: [PATCH 09/17] div korrigiert --- Batterie/module.php | 102 +++++++++++++++++--------------------------- library.json | 2 +- 2 files changed, 40 insertions(+), 64 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index cfad474..af279a8 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -61,104 +61,80 @@ class Batterie extends IPSModule } } - public function SetAktuelle_Leistung(int $power){ - $spannung = $this->ReadPropertyInteger("Batteriespannung"); - $entladestrom = $this->ReadVariableInteger("Entladestrom"); - $ladestrom = $this->ReadVariableInteger("Ladestrom"); - $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); - - //Batterie entladen < MaxBatterieleistung &&&&& MaxBatterieleistung < Batterie laden + public function SetAktuelle_Leistung(int $power) + { + // Batterie-spezifische Eigenschaften abrufen + $spannung = $this->ReadPropertyInteger("Batteriespannung"); + $entladestrom = GetValue($this->GetIDForIdent("Entladestrom")); + $ladestrom = GetValue($this->GetIDForIdent("Ladestrom")); + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + + // Batterie entladen oder laden basierend auf der Leistung if ($power > $maxleistung) { $ladestrom = ($power - $maxleistung) / $spannung; $this->SetValue("Ladestrom", $ladestrom); } else { $entladestrom = $power / $spannung; - $this->SetValue("Entladestrom", $nachladestrom); + $this->SetValue("Entladestrom", $entladestrom); } - - - - // Prüfe auf Änderung der Power im Vergleich zur letzten Einstellung + + // Prüfe auf Änderung der Leistung im Vergleich zur letzten Einstellung $lastPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung")); if ($power != $lastPower) { $this->SetValue("Idle", false); $this->SetValue( "IdleCounter", $this->ReadPropertyInteger("IdleCounterMax") - ); - } + ); + } - // Setze die neue Aktuelle_Leistung + // Setze die neue aktuelle Leistung $this->SetValue("Aktuelle_Leistung", $power); // IdleCounter verarbeiten - $this->ProcessIdleCounter(); - + $this->ProcessIdleCounter(); } + public function GetCurrentData(bool $Peak) { - // Werte der registrierten Variablen abrufen und in Variablen speichern - $aufdasnachladen = $this->ReadVariableInteger("AufdasNachladen"); - $minimumentladen = $this->ReadVariableInteger("Minimumentladen"); - $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); - $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); - + $aufdasnachladen = GetValue($this->GetIDForIdent("AufdasNachladen")); + $minimumentladen = GetValue($this->GetIDForIdent("MinimumEntladen")); + $batterieladezustand = GetValue($this->GetIDForIdent("Batterieladezustand")); + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + if ($Peak) { - - - if ($batterieladezustand <= $minimumentladen){ - // Filterung des Arrays - $filtered_powersteps = array_filter($array_powersteps, function ($value) { - return $value > $maxleistung ; //Hochpassfiltern + if ($batterieladezustand <= $minimumentladen) { + $filtered_powersteps = array_filter($array_powersteps, function ($value) use ($maxleistung) { + return $value > $maxleistung; // Hochpass filtern }); - $filtered_powersteps_laden = array_values($filtered_powersteps); - $this->SetValue( - "PowerSteps", - json_encode($filtered_powersteps_laden) - ); + $this->SetValue("PowerSteps", json_encode($filtered_powersteps_laden)); } elseif ($batterieladezustand >= $aufdasnachladen) { - - $filtered_powersteps_entladen = array_filter($array_powersteps, function ($value) { - return $value < $maxleistung ; //Tiefpassfiltern + $filtered_powersteps_entladen = array_filter($array_powersteps, function ($value) use ($maxleistung) { + return $value < $maxleistung; // Tiefpass filtern }); + $this->SetValue("PowerSteps", json_encode($filtered_powersteps_entladen)); - $filtered_powersteps = array_values($filtered_powersteps); - $this->SetValue( - "PowerSteps", - json_encode($filtered_powersteps_entladen) - ); - } elseif ($batterieladezustand < $aufdasnachladen && $batterieladezustand > $minimumentladen) { - $this->SetValue( - "PowerSteps", - json_encode($array_powersteps) - ); - - } else { + $this->SetValue("PowerSteps", json_encode($array_powersteps)); - $this->SetValue( - "PowerSteps", - json_encode($array_powersteps[0]) - ); + } else { + $this->SetValue("PowerSteps", json_encode($array_powersteps[0])); } - } else {//Solar - + } else { // Solar - // Filterung des Arrays - $filtered_powersteps = array_filter($array_powersteps, function ($value) { - return $value > $maxleistung ; //Hochpassfiltern + $filtered_powersteps = array_filter($array_powersteps, function ($value) use ($maxleistung) { + return $value > $maxleistung; // Hochpass filtern }); - $filtered_powersteps = array_values($filtered_powersteps); - $this->SetValue( - "PowerSteps", - json_encode($filtered_powersteps) - ); + + $this->SetValue("PowerSteps", json_encode($filtered_powersteps)); } + } + diff --git a/library.json b/library.json index fcc286e..1b3942b 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.180", + "version": "0.181", "build": 0, "date": 0 } \ No newline at end of file From 0a35944e81423e9ace6f3b5a495a31764ef01bb5 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:02:33 +0100 Subject: [PATCH 10/17] klammer fehler --- Batterie/module.php | 9 --------- library.json | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index af279a8..f495ee2 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -137,15 +137,6 @@ class Batterie extends IPSModule - - - - - - - - - } private function CheckIdle($power) { $lastpower = GetValue("Aktuelle_Leistung"); diff --git a/library.json b/library.json index 1b3942b..31d870b 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.181", + "version": "0.182", "build": 0, "date": 0 } \ No newline at end of file From 56ca7379692c5f47167214be4138ce1423c7d859 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:04:39 +0100 Subject: [PATCH 11/17] ka --- Batterie/module.php | 4 ++-- library.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index f495ee2..0c0b0c4 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -127,11 +127,11 @@ class Batterie extends IPSModule } else { // Solar - $filtered_powersteps = array_filter($array_powersteps, function ($value) use ($maxleistung) { + $filtered_powersteps_solar = array_filter($array_powersteps, function ($value) use ($maxleistung) { return $value > $maxleistung; // Hochpass filtern }); - $this->SetValue("PowerSteps", json_encode($filtered_powersteps)); + $this->SetValue("PowerSteps", json_encode($filtered_powersteps_solar)); } } diff --git a/library.json b/library.json index 31d870b..6a9f608 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.182", + "version": "0.183", "build": 0, "date": 0 } \ No newline at end of file From 01506cbd4ddf0877deab58d3c4198e120b376fac Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:12:39 +0100 Subject: [PATCH 12/17] div fehler --- Batterie/form.json | 6 ++++-- library.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Batterie/form.json b/Batterie/form.json index ce69f2b..966d9a7 100644 --- a/Batterie/form.json +++ b/Batterie/form.json @@ -19,13 +19,15 @@ { "type": "NumberSpinner", "name": "AufdasNachladen", - "caption": "Auf so viel Prozent nachladen" + "caption": "Auf so viel Prozent nachladen", + "suffix": "" }, { "type": "NumberSpinner", "name": "MinimumEntladen", - "caption": "Minimum des Batterieladezustand" + "caption": "Minimum des Batterieladezustand", + "suffix": "" }, { "type": "SelectVariable", diff --git a/library.json b/library.json index 6a9f608..6f48c29 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.183", + "version": "0.184", "build": 0, "date": 0 } \ No newline at end of file From 7a5d34f2e335b4dc933d7f2a49bf675f4f4a9fd4 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:17:54 +0100 Subject: [PATCH 13/17] property fehler --- Batterie/module.php | 22 ++++++++++------------ library.json | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 0c0b0c4..83dee34 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -9,13 +9,11 @@ class Batterie extends IPSModule // Batterie spezifische Eigenschaften $this->RegisterPropertyInteger("MaxBatterieleistung", 0); $this->RegisterPropertyInteger("Batteriespannung", 50); - - // Batterie spezifische Variablen - $this->RegisterVariableInteger("AufdasNachladen","AufdasNachladen","",0); - $this->RegisterVariableInteger("MinimumEntladen","MinimumEntladen","",0); - $this->RegisterVariableInteger("Entladestrom","Entladestrom","",0); - $this->RegisterVariableInteger("Ladestrom","Ladestrom","",0); - $this->RegisterVariableInteger("Batterieladezustand","Batterieladezustand","",0); + $this->RegisterPropertyInteger("AufdasNachladen","AufdasNachladen","",0); + $this->RegisterPropertyInteger("MinimumEntladen","MinimumEntladen","",0); + $this->RegisterPropertyInteger("Entladestrom","Entladestrom","",0); + $this->RegisterPropertyInteger("Ladestrom","Ladestrom","",0); + $this->RegisterPropertyInteger("Batterieladezustand","Batterieladezustand","",0); // Variabeln für Kommunkation mit Manager $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); @@ -65,8 +63,8 @@ class Batterie extends IPSModule { // Batterie-spezifische Eigenschaften abrufen $spannung = $this->ReadPropertyInteger("Batteriespannung"); - $entladestrom = GetValue($this->GetIDForIdent("Entladestrom")); - $ladestrom = GetValue($this->GetIDForIdent("Ladestrom")); + $entladestrom = $this->ReadPropertyInteger("Entladestrom")); + $ladestrom = $this->ReadPropertyInteger("Ladestrom")); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Batterie entladen oder laden basierend auf der Leistung @@ -99,9 +97,9 @@ class Batterie extends IPSModule public function GetCurrentData(bool $Peak) { // Werte der registrierten Variablen abrufen und in Variablen speichern - $aufdasnachladen = GetValue($this->GetIDForIdent("AufdasNachladen")); - $minimumentladen = GetValue($this->GetIDForIdent("MinimumEntladen")); - $batterieladezustand = GetValue($this->GetIDForIdent("Batterieladezustand")); + $aufdasnachladen =$this->ReadPropertyInteger("AufdasNachladen")); + $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen")); + $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand")); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); if ($Peak) { diff --git a/library.json b/library.json index 6f48c29..f8745cc 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.184", + "version": "0.185", "build": 0, "date": 0 } \ No newline at end of file From de7f8a02c587c718c2741d6c6950eb6d4de38931 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:26:05 +0100 Subject: [PATCH 14/17] div fehler,ka --- Batterie/module.php | 36 +++++++++++++++++++++--------------- library.json | 2 +- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 83dee34..6f018ef 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -32,22 +32,27 @@ class Batterie extends IPSModule public function ApplyChanges() { parent::ApplyChanges(); - $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); - $array_powersteps = []; - //Schrittgrösse - $stepSize = 250; - - - for ($i = 0; $i <= $maxleistung * 2; $i += $stepSize) { - $array_powersteps[] = $i; - } + } + private function GeneratePowerSteps() +{ + $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); + $array_powersteps = []; + $stepSize = 250; // Schrittgröße + // Erstellen der PowerSteps + for ($i = 0; $i <= $maxleistung * 2; $i += $stepSize) { + $array_powersteps[] = $i; + } + + return $array_powersteps; +} public function RequestAction($Ident, $Value) { + switch ($Ident) { case "SetAktuelle_Leistung": $this->SetAktuelle_Leistung($Value); @@ -60,11 +65,11 @@ class Batterie extends IPSModule } public function SetAktuelle_Leistung(int $power) - { + { // Batterie-spezifische Eigenschaften abrufen $spannung = $this->ReadPropertyInteger("Batteriespannung"); - $entladestrom = $this->ReadPropertyInteger("Entladestrom")); - $ladestrom = $this->ReadPropertyInteger("Ladestrom")); + $entladestrom = $this->ReadPropertyInteger("Entladestrom"); + $ladestrom = $this->ReadPropertyInteger("Ladestrom"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Batterie entladen oder laden basierend auf der Leistung @@ -97,9 +102,10 @@ class Batterie extends IPSModule public function GetCurrentData(bool $Peak) { // Werte der registrierten Variablen abrufen und in Variablen speichern - $aufdasnachladen =$this->ReadPropertyInteger("AufdasNachladen")); - $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen")); - $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand")); + $array_powersteps = $this->GeneratePowerSteps(); + $aufdasnachladen =$this->ReadPropertyInteger("AufdasNachladen"); + $minimumentladen = $this->ReadPropertyInteger("MinimumEntladen"); + $batterieladezustand = $this->ReadPropertyInteger("Batterieladezustand"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); if ($Peak) { diff --git a/library.json b/library.json index f8745cc..16660ab 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.185", + "version": "0.186", "build": 0, "date": 0 } \ No newline at end of file From 4cef300dbc1356214b15b083962124df5b904663 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:27:57 +0100 Subject: [PATCH 15/17] div fehler --- Batterie/module.php | 10 +++++----- library.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 6f018ef..9e32cb0 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -9,11 +9,11 @@ class Batterie extends IPSModule // Batterie spezifische Eigenschaften $this->RegisterPropertyInteger("MaxBatterieleistung", 0); $this->RegisterPropertyInteger("Batteriespannung", 50); - $this->RegisterPropertyInteger("AufdasNachladen","AufdasNachladen","",0); - $this->RegisterPropertyInteger("MinimumEntladen","MinimumEntladen","",0); - $this->RegisterPropertyInteger("Entladestrom","Entladestrom","",0); - $this->RegisterPropertyInteger("Ladestrom","Ladestrom","",0); - $this->RegisterPropertyInteger("Batterieladezustand","Batterieladezustand","",0); + $this->RegisterPropertyInteger("AufdasNachladen",0); + $this->RegisterPropertyInteger("MinimumEntladen",0); + $this->RegisterPropertyInteger("Entladestrom",0); + $this->RegisterPropertyInteger("Ladestrom",0); + $this->RegisterPropertyInteger("Batterieladezustand",0); // Variabeln für Kommunkation mit Manager $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); diff --git a/library.json b/library.json index 16660ab..fab2fc0 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.186", + "version": "0.187", "build": 0, "date": 0 } \ No newline at end of file From a98bd5607f069bb141ef86d9d91a5b42d400568a Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:38:10 +0100 Subject: [PATCH 16/17] - --- Batterie/form.json | 4 ++-- library.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Batterie/form.json b/Batterie/form.json index 966d9a7..45af52e 100644 --- a/Batterie/form.json +++ b/Batterie/form.json @@ -31,8 +31,8 @@ }, { "type": "SelectVariable", - "name": "Nachladestrom", - "caption": "Nachladestrom", + "name": "Entladestrom", + "caption": "Entladestrom", "test": true }, { diff --git a/library.json b/library.json index fab2fc0..864830e 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.187", + "version": "0.188", "build": 0, "date": 0 } \ No newline at end of file From 04d67d2e0d688a8c20edd9a347dad2b09ea62229 Mon Sep 17 00:00:00 2001 From: "belevo\\mh" Date: Wed, 11 Dec 2024 16:47:53 +0100 Subject: [PATCH 17/17] - --- Batterie/module.php | 8 ++++---- library.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 9e32cb0..fc069e2 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -11,11 +11,11 @@ class Batterie extends IPSModule $this->RegisterPropertyInteger("Batteriespannung", 50); $this->RegisterPropertyInteger("AufdasNachladen",0); $this->RegisterPropertyInteger("MinimumEntladen",0); - $this->RegisterPropertyInteger("Entladestrom",0); - $this->RegisterPropertyInteger("Ladestrom",0); $this->RegisterPropertyInteger("Batterieladezustand",0); // Variabeln für Kommunkation mit Manager + $this->RegisterVariableInteger("Ladestrom", "Ladestrom", "", 0); + $this->RegisterVariableInteger("Entladestrom", "Entladestrom", "", 0); $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); $this->RegisterVariableBoolean("Idle", "Idle", "", 0); @@ -68,8 +68,8 @@ class Batterie extends IPSModule { // Batterie-spezifische Eigenschaften abrufen $spannung = $this->ReadPropertyInteger("Batteriespannung"); - $entladestrom = $this->ReadPropertyInteger("Entladestrom"); - $ladestrom = $this->ReadPropertyInteger("Ladestrom"); + $entladestrom = $this->ReadVariableInteger("Entladestrom"); + $ladestrom = $this->ReadVariableInteger("Ladestrom"); $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); // Batterie entladen oder laden basierend auf der Leistung diff --git a/library.json b/library.json index 864830e..6a186ff 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "0.188", + "version": "0.189", "build": 0, "date": 0 } \ No newline at end of file