From 3f7de21ea6096044e5f0044c29333ebee14ce835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=A4fliger?= Date: Mon, 17 Mar 2025 15:28:43 +0100 Subject: [PATCH] =?UTF-8?q?leistungsintegral=20ver=C3=A4ndert=20damit=20da?= =?UTF-8?q?s=20takten=20nincht=20so=20schnell=20l=C3=A4funt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Batterie/module.php | 17 ++++++++++++++++- Boiler_2_Stufig_Mit_Fueler/module.php | 19 ++++++++++++++++++- Ladestation_Universal/module.php | 16 +++++++++++++++- Verbraucher_1_Stufig/module.php | 16 +++++++++++++++- WP_Steuerung/module.php | 17 +++++++++++++++-- library.json | 2 +- 6 files changed, 80 insertions(+), 7 deletions(-) diff --git a/Batterie/module.php b/Batterie/module.php index 0704aa1..e97ed84 100644 --- a/Batterie/module.php +++ b/Batterie/module.php @@ -59,6 +59,21 @@ class Batterie extends IPSModule $this->SetTimerInterval("Timer_Do_UserCalc_Battery",$this->ReadPropertyInteger("Interval")*1000); } + public function IntegratePower() { + + if (rand(1, 1000) === 1) { // 0.1% Chance + + $this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)))); + $this->SetValue("Bezogene_Energie_Zwischenwert", 0); + + }else{ + $this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + } + + return; // Falls nichts gespeichert wird + } + + private function GeneratePowerSteps($additionalValue) { $maxleistung = $this->ReadPropertyInteger("MaxBatterieleistung"); @@ -175,7 +190,7 @@ public function RequestAction($Ident, $Value) // Setze die neue aktuelle Leistung $this->SetValue("Aktuelle_Leistung", $power); - $this->SetValue("Bezogene_Energie", $this->GetValue("Bezogene_Energie")+($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + $this->IntegratePower(); // IdleCounter verarbeiten $this->ProcessIdleCounter(); diff --git a/Boiler_2_Stufig_Mit_Fueler/module.php b/Boiler_2_Stufig_Mit_Fueler/module.php index 0fbc7cc..f6c3ca6 100644 --- a/Boiler_2_Stufig_Mit_Fueler/module.php +++ b/Boiler_2_Stufig_Mit_Fueler/module.php @@ -35,6 +35,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule $this->RegisterVariableBoolean("Idle", "Idle", "", 0); $this->RegisterVariableInteger("Aktuelle_Leistung", "Aktuelle_Leistung", "", 0); $this->RegisterVariableFloat("Bezogene_Energie", "Bezogene_Energie", "", 0); + $this->RegisterVariableFloat("Bezogene_Energie_Zwischenwert", "Bezogene_Energie_Zwischenwert", "", 0); $this->RegisterVariableString("PowerSteps", "PowerSteps"); $this->RegisterVariableInteger("Power", "Power", '', 0); $this->RegisterVariableBoolean("Is_Peak_Shaving", "Is_Peak_Shaving", "", true); @@ -83,6 +84,22 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule } } + + public function IntegratePower() { + + if (rand(1, 1000) === 1) { // 0.1% Chance + + $this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)))); + $this->SetValue("Bezogene_Energie_Zwischenwert", 0); + + }else{ + $this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + } + + return; // Falls nichts gespeichert wird + } + + public function getNextTimeAndTemperature($zeitplan) { $arr = json_decode($zeitplan, true); if (empty($arr)) { @@ -161,7 +178,7 @@ class Boiler_2_Stufig_Mit_Fueler extends IPSModule // Setze die neue Aktuelle_Leistung $this->SetValue("Aktuelle_Leistung", $power); - $this->SetValue("Bezogene_Energie", $this->GetValue("Bezogene_Energie")+($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + $this->IntegratePower(); // IdleCounter verarbeiten $this->ProcessIdleCounter(); } diff --git a/Ladestation_Universal/module.php b/Ladestation_Universal/module.php index 54f4b4e..c4bf024 100644 --- a/Ladestation_Universal/module.php +++ b/Ladestation_Universal/module.php @@ -84,6 +84,20 @@ class Ladestation_Universal extends IPSModule } + public function IntegratePower() { + + if (rand(1, 1000) === 1) { // 0.1% Chance + + $this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)))); + $this->SetValue("Bezogene_Energie_Zwischenwert", 0); + + }else{ + $this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + } + + return; // Falls nichts gespeichert wird + } + public function SetAktuelle_Leistung(int $power) { @@ -91,7 +105,7 @@ class Ladestation_Universal extends IPSModule $internalPower = GetValue($this->GetIDForIdent("Aktuelle_Leistung")); // Aktuelle Leistungsvorgabe setzen SetValue($this->GetIDForIdent("Aktuelle_Leistung"), $power); - $this->SetValue("Bezogene_Energie", $this->GetValue("Bezogene_Energie")+($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + $this->IntegratePower(); if ($power != $internalPower) { // Setze die interne Leistungsvorgabe diff --git a/Verbraucher_1_Stufig/module.php b/Verbraucher_1_Stufig/module.php index 6365b72..ec5ee8b 100644 --- a/Verbraucher_1_Stufig/module.php +++ b/Verbraucher_1_Stufig/module.php @@ -78,6 +78,20 @@ class Verbraucher_1_Stufig extends IPSModule } } + public function IntegratePower() { + + if (rand(1, 1000) === 1) { // 0.1% Chance + + $this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)))); + $this->SetValue("Bezogene_Energie_Zwischenwert", 0); + + }else{ + $this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + } + + return; // Falls nichts gespeichert wird + } + // Methode zum Setzen der PowerSteps und Timer starten @@ -120,7 +134,7 @@ class Verbraucher_1_Stufig extends IPSModule $this->SetTimerOn(); } $this->SetValue("Aktuelle_Leistung", $power); - $this->SetValue("Bezogene_Energie", $this->GetValue("Bezogene_Energie")+($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + $this->IntegratePower(); $boilerLeistung = $this->ReadPropertyInteger("BoilerLeistung"); $schaltkontaktID = $this->ReadPropertyInteger("Schaltkontakt1"); diff --git a/WP_Steuerung/module.php b/WP_Steuerung/module.php index 32f447c..9e73077 100644 --- a/WP_Steuerung/module.php +++ b/WP_Steuerung/module.php @@ -84,6 +84,20 @@ class WP_Steuerung extends IPSModule } } + public function IntegratePower() { + + if (rand(1, 1000) === 1) { // 0.1% Chance + + $this->SetValue("Bezogene_Energie", ($this->GetValue("Bezogene_Energie") + $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600)))); + $this->SetValue("Bezogene_Energie_Zwischenwert", 0); + + }else{ + $this->SetValue("Bezogene_Energie_Zwischenwert", $this->GetValue("Bezogene_Energie_Zwischenwert") + ($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); + } + + return; // Falls nichts gespeichert wird + } + // Methode zum Setzen des aktuellen Stromverbrauchs public function SetAktuelle_Leistung(float $power) @@ -263,8 +277,7 @@ class WP_Steuerung extends IPSModule $this->SetValue("WP_Laufzeit_Zahler", $newCount + 1); } - $this->SetValue("Bezogene_Energie", $this->GetValue("Bezogene_Energie")+($this->GetValue("Aktuelle_Leistung")*($this->ReadPropertyInteger("Interval")/3600))); - + $this->IntegratePower(); } // Methode zum Abrufen der aktuellen Daten diff --git a/library.json b/library.json index 1d5d4e5..42f78e8 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "7.1" }, - "version": "1.192", + "version": "1.193", "build": 0, "date": 0 } \ No newline at end of file